Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

Images not displaying fast first time if created with FilteredImageSource and ImageProducer In JDK 1.1.8

I have an applet which downloads some images, using media tracker to control this.
Then some of the images are rotated 90 degrees right and assigned to the array of images

When I first display the images, using standard buffer methods, those that have not been rotated appear immediately, the other appear slowly. I would estimate that about 50 screen repaints take place before the rotated ones appear in their full glory

however once the rotated images have been  drawn on screen then next time they are used they appear super fast , same as the normal ones

Here's some code:

tracker = new MediaTracker(this);
for (int i = 0; i < Config.NumOfImages; i++)
{
tracker.addImage(ImagesName.Cards[i], i);
}
try
{
tracker.waitForAll();
if (!LoadImages.RotatedCardsPrepared)
{
ImageFilter filter = new RotateFilter(Math.PI / 2);
ImageProducer producer;
for (int i =0; i < 52 ; i++ )
{
producer = new FilteredImageSource(ImagesName.Cards[i + Config.StartOfCardImages].getSource(),filter);
ImagesName.Cards[i + Config.NumOfImages] = createImage(producer);
}
LoadImages.RotatedCardsPrepared = true;
}
} catch (InterruptedException e2)

i am assuming that for some reason the rotated images are not quite ready to display ... have hunted around and tried putting the rotate code inside the Media Tracker loop as I saw that as a method

public class RotateFilter extends ImageFilter {

I found on the web, it overrides ImageFilter in places and adds some stuff to allow rotation

Any ideas on how to make sure that the rotated images are finalised ready for fast display ?

Phil
0
PhilAllen
Asked:
PhilAllen
  • 2
1 Solution
 
objectsCommented:
you need to also use MediaTracker to wait for the rotations to complete.
you could either do it individually for each image after:

ImagesName.Cards[i + Config.NumOfImages] = createImage(producer);

or use a seperate loop to wait for them all after your conversoion loop.
0
 
PhilAllenAuthor Commented:
:-) what a man I was hoping you would be about

Thanks a lot

Tried or use a seperate loop to wait for them all after your conversoion loop.

And that worked a dream :-)

Regards

Phil

0
 
objectsCommented:
:)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now