Article View: borland.public.jbuilder.java.api
Article #3336Re: gif in application
From: Dan Acton
Date: Tue, 10 Feb 1998 00:00
Date: Tue, 10 Feb 1998 00:00
62 lines
2352 bytes
2352 bytes
Pass an ImageObserver to i1.getWidth() and i1.getHeight(). Since Component
implements ImageObserver, you can pass anything that is derived from
Component, like a Canvas or Frame.
To create the i2 image, you can again use the Component method
createImage(), eg.
Image i3 = myCanvas.createImage(i1.getWidth(myCanvas),
i1.getHeight(myCanvas));
You need to make sure your images are fully loaded before calling getWidth()
and getHeight(). The easiest way to do this is to call a utility routine
like the following, after each call to getImage():
public static void waitForImage(Component component,
Image image) {
MediaTracker tracker = new MediaTracker(component);
try {
tracker.addImage(image, 0);
tracker.waitForID(0);
}
catch(InterruptedException e) { }
}
And finally, the last parameter to pass to drawImage is (you guessed it)
another ImageObserver. Following the example from above, you would call:
g1.drawImage(i1, 0, 0, myCanvas);
Hope this helps.
Dan Acton
Beak International Inc.
Tycho Luyben wrote in message <6bj03i$bfg1@forums.borland.com>...
>Hi,
>
>I'm playing around with gif in applications that do not show anything on
the
>screen (like CGI etc); I need to do the following;
>
>Image i1 = toolkit.getdefaulttoolkit.getimage("image1.gif");
>Image i2 = toolkit.getdefaulttoolkit.getimage("image2.gif");
>Image i3 = createimage(i1.getwidth(???),i1.getheight(???));
>Graphics g1 = i3.getgraphics();
>g1.drawimage(i1,0,0,???);
>g1.drawimage(i2,0,0,???);
>
>and then write it to a file... The writing to a file was no problem, but i
>don't know what to put instead of the ???...
>
>Has someone written an servlet that does this and can that someone help me?
>
>Thanks...
>
>Please Post & Reply...
>
>
>
>
Technical Details
Message-ID:
<6bptnm$ea41@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<6bj03i$bfg1@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,5fd79e96fbdfc21d X-Google-Attributes: gid1089d0,public From: "Dan Acton" <dacton@beak.com> Subject: Re: gif in application Date: 1998/02/10 Message-ID: <6bptnm$ea41@forums.borland.com> X-Deja-AN: 323781391 References: <6bj03i$bfg1@forums.borland.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 Organization: Beak International Inc. Newsgroups: borland.public.jbuilder.java.api