?
Solved

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

Posted on 2005-03-15
3
Medium Priority
?
205 Views
Last Modified: 2012-05-05
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
Comment
Question by:PhilAllen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 13549846
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
 

Author Comment

by:PhilAllen
ID: 13550201
:-) 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
 
LVL 92

Expert Comment

by:objects
ID: 13550273
:)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month13 days, 6 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question