Memoryconsumption while zooming

C

CooperFan9390

Hello,

I have aan application which loads a .BMP and displays it on the screen
using memoryImageSource and as an ImageIcon on a JLabel in a
JScrollPane.
I have written a very basic zoom function which multiplies every pixel
whith the zoomFactor, so its lossless zooming.
The problem is I can't zoom further than 3x ( a pixel turns into 3
pixels x and y ), because I get an outOfMemoryError. The minimum
heapsize is 32MB and the maximum is 256.

I would like to zoom as far as I want, lossless, and I suppose I have
to use some drawmethod.
How can this be done?
Any help would be greatly appreciated.
 
A

Andrey Kuznetsov

I have aan application which loads a .BMP and displays it on the screen
using memoryImageSource and as an ImageIcon on a JLabel in a
JScrollPane.
I have written a very basic zoom function which multiplies every pixel
whith the zoomFactor, so its lossless zooming.
The problem is I can't zoom further than 3x ( a pixel turns into 3
pixels x and y ), because I get an outOfMemoryError. The minimum
heapsize is 32MB and the maximum is 256.

I would like to zoom as far as I want, lossless, and I suppose I have
to use some drawmethod.
How can this be done?

you should zoom only part of image which is currently displayed.
 
A

Andrey Kuznetsov

I have aan application which loads a .BMP and displays it on the screen
And how do I do that without losing the JScrollBar Functionality?

your view component can be as big as you want, but your displayed image is
only as big as viewport.
compute viewport content in another thread and set some variable (e.g.
imageReady) when it is ready.
in the paintComponent() method of view you write something like:
if(imageReady) {
g.drawImage(image, 0, 0, null);
}

BTW don't start computing direct from scroll listener - use Timer.

Andrey
 
C

CooperFan9390

Andrey said:
your view component can be as big as you want, but your displayed image is
only as big as viewport.
compute viewport content in another thread and set some variable (e.g.
imageReady) when it is ready.
in the paintComponent() method of view you write something like:
if(imageReady) {
g.drawImage(image, 0, 0, null);
}

BTW don't start computing direct from scroll listener - use Timer.

Why wouldn't I want to compute directly from scroll listener? Will
there be no delay with a timer?
 
A

Andrey Kuznetsov

I have aan application which loads a .BMP and displays it on the
Why wouldn't I want to compute directly from scroll listener? Will
there be no delay with a timer?

small delay is better then performance problems

Andrey
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,265
Messages
2,571,069
Members
48,771
Latest member
ElysaD

Latest Threads

Top