PhilAllen
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(ImagesNam e.Cards[i] , i);
}
try
{
tracker.waitForAll();
if (!LoadImages.RotatedCardsP repared)
{
ImageFilter filter = new RotateFilter(Math.PI / 2);
ImageProducer producer;
for (int i =0; i < 52 ; i++ )
{
producer = new FilteredImageSource(Images Name.Cards [i + Config.StartOfCardImages]. getSource( ),filter);
ImagesName.Cards[i + Config.NumOfImages] = createImage(producer);
}
LoadImages.RotatedCardsPre pared = 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
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(ImagesNam
}
try
{
tracker.waitForAll();
if (!LoadImages.RotatedCardsP
{
ImageFilter filter = new RotateFilter(Math.PI / 2);
ImageProducer producer;
for (int i =0; i < 52 ; i++ )
{
producer = new FilteredImageSource(Images
ImagesName.Cards[i + Config.NumOfImages] = createImage(producer);
}
LoadImages.RotatedCardsPre
}
} 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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:)
ASKER
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