[3738] in java-interest

home help back first fref pref prev next nref lref last post

What do x,y in java.awt.Graphics.drawImage() refer to?

daemon@ATHENA.MIT.EDU (Ian Rogers)
Fri Nov 24 20:48:13 1995

Date: Fri, 24 Nov 1995 16:05:23 -0800
From: Ian Rogers <irogers@biggun.com>
CC: java@mt.e-technik.uni-kassel.de, java-interest@java.sun.com,
        thwendt@mt.e-technik.uni-kassel.de, jvillaci@cs.indiana.edu

I'm confused.  In java.awt.Graphics.drawImage(Image img, int x, int y,
ImageObserver this), are x and y the coordinates of where to draw in the
graphics context, or are they where to begin to pull from the Image?  It
seems to work as both, in different sources:


    public void paint(Graphics g) { update(g); }

    public void update(Graphics g) {
      if ((img != null) && (loopslot < nimgs)) {
        g.clipRect(0,0,w,h);
        g.drawImage(img, 0, (-loopslot)*h, this);
      }
    }

(from http://www.uni-kassel.de/fb16/ipm/mt/java/beta/javalogo.txt)

as if by specifying x,y in drawImage you can draw just a portion of
Image img.  It works, even without the clipRect().  The API says
drawImage() "Draws the specified image at the specified coordinate (x,
y)."  So why does (x,y) seem to reference *within* the image in the
above example?  Obviously I'm missing something.  (are these numbers
*really* less than 0?)

I've been using drawImage() like so:

	  g.drawImage(image, 100, 100, this);

as if to draw the image at 100,100 in the Graphics Context.  It draws
the entire image at 100,100 in the GC.  

See my confusion?

Now, I'd like to do *both* of the above.  That is, draw from imgX,imgY
in the Image at gcX,GCy in the graphics context.  So I can include
within the larger context a small animation where all the animation
frames are included in one image file.  How can this be done? 

I'm using the Beta JDK under Solaris.

Still grasping,
ian
-- 
ian c rogers                         http://www.filmzone.com/
Big Gun Project                      http://www.crashsite.com/Crash/
irogers@biggun.com                   http://www.nando.net/music/gm/
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post