Wait for first frame of image in image loader.
This commit is contained in:
parent
5025f5fb96
commit
19d4126b51
1 changed files with 13 additions and 4 deletions
|
@ -105,10 +105,12 @@ public class ImageGenerator {
|
||||||
Image img;
|
Image img;
|
||||||
int w, h;
|
int w, h;
|
||||||
boolean waiting;
|
boolean waiting;
|
||||||
|
boolean firstFrameLoaded;
|
||||||
|
|
||||||
ImageLoader (Image img) {
|
ImageLoader (Image img) {
|
||||||
this.img = img;
|
this.img = img;
|
||||||
waiting = true;
|
waiting = true;
|
||||||
|
firstFrameLoaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getWidth () {
|
int getWidth () {
|
||||||
|
@ -147,14 +149,21 @@ public class ImageGenerator {
|
||||||
w = width;
|
w = width;
|
||||||
if (h == -1 && (infoflags & HEIGHT) > 0)
|
if (h == -1 && (infoflags & HEIGHT) > 0)
|
||||||
h = height;
|
h = height;
|
||||||
if (h > -1 && w > -1) {
|
if ((infoflags & ALLBITS) > 0 ||
|
||||||
// we know all we want to know. notify waiting thread that
|
(infoflags & FRAMEBITS) > 0)
|
||||||
// the image is loaded and ready to be used.
|
firstFrameLoaded = true;
|
||||||
|
// check if we have everything we need
|
||||||
|
if (w > -1 && h > -1 && firstFrameLoaded) {
|
||||||
|
// we know both the width and the height of the image and
|
||||||
|
// the bits of the first frame have been loaded. notify waiting thread that
|
||||||
|
// the image is loaded and ready to be used and tell the loader thread
|
||||||
|
// that we need no further updates.
|
||||||
notifyAll ();
|
notifyAll ();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// check if there was an error
|
// check if there was an error
|
||||||
if (!waiting || (infoflags & ERROR) > 0 || (infoflags & ABORT) > 0) {
|
if (!waiting || (infoflags & ERROR) > 0 || (infoflags & ABORT) > 0) {
|
||||||
|
// we either timed out or there was an error.
|
||||||
notifyAll ();
|
notifyAll ();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue