F
flarosa
I'm trying to resize an image in a server application using AWT
functions. Since my application doesn't have a UI, I set the
java.awt.headless=true option.
To resize the image, I'm calling Image.getScaledInstance(). Since this
is an asynchronous function, I have to wait for it to complete before I
can use the image. To do that, I am calling Toolkit.prepareImage() with
an ImageObserver. When the image observer receives the ALLBITS flag, I
stop waiting.
The bottom line is, it works, but it is often painfully slow -- I'm
talking 30, 40, 50 seconds to resize a simple image. During this time
my ImageObserver gets called every few seconds with the SOMEBITS flag.
But other times it scales images in one or two seconds. All the image
data is in memory, so there aren't any network delays going on (the
original image is constructed from a byte array, not a URL or a
stream).
Is there some kind of thread priority, or other parameter I need to set
to make this work better? Or am I just doing something fundamentally
wrong?
Thanks.
functions. Since my application doesn't have a UI, I set the
java.awt.headless=true option.
To resize the image, I'm calling Image.getScaledInstance(). Since this
is an asynchronous function, I have to wait for it to complete before I
can use the image. To do that, I am calling Toolkit.prepareImage() with
an ImageObserver. When the image observer receives the ALLBITS flag, I
stop waiting.
The bottom line is, it works, but it is often painfully slow -- I'm
talking 30, 40, 50 seconds to resize a simple image. During this time
my ImageObserver gets called every few seconds with the SOMEBITS flag.
But other times it scales images in one or two seconds. All the image
data is in memory, so there aren't any network delays going on (the
original image is constructed from a byte array, not a URL or a
stream).
Is there some kind of thread priority, or other parameter I need to set
to make this work better? Or am I just doing something fundamentally
wrong?
Thanks.