Link to home
Start Free TrialLog in
Avatar of PhilAllen
PhilAllenFlag for Afghanistan

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PhilAllen

ASKER

:-) 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