harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Igor Stolyarov" <igorvstolya...@gmail.com>
Subject Re: A problem, when load the picture
Date Tue, 04 Dec 2007 06:52:19 GMT
> For example, the picture load mechanism. When we start to load a .png,
> there
> are two main threads: EventDispatchThread and ImageLoadThread. Here we can
>
> see harmony use a single interface to insure the asynchronous picture
> loading problem. A single interface  means that EventDispatchThread
> communicating with the ImageLoadThread by using BufferedImage.getWidth()
> method. But without a management, how can you assure that whether
> ImageLoadThread loaded the picture has done, when it return the image
> instance.


Hi, Jorcco,

Regarding management of image loading. There is interface ImageObserver (
java.awt.ImageObserver). That interface is an asynchronous update interface
for receiving notifications about Image information as the Image is
constructed. When you created Image instance, for example:
Image img = Toolkit.getDefaultToolkit().createImage("image.png");

You haven't yet any image data until you whether ask image size or start
draw image, for example:

int width = img.getWidth(ImageObserver instance);

or

Graphics.drawImage(Image, x, y, ImageObserver);

After that image loading process starts and ImageObserver interface allows
you traking all image loading stages.
Also there are two useful Toolkit methods prepareImage and checkImage. First
method starts image loading process and returns true if image fully loaded,
second one allows recieved image loading states.

If you have else questions, wellcome.

Thanks,
Igor

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message