John, hi.

Instead of performing an AffineTransformOp every time the user scales the
image, you may be able to take advantage of the Graphics2D
drawRenderedImage( RenderedImage, AffineTransform ) method.  This method
applies the AffineTransform to the image when it is drawn.  Using this
method may not reduce the amount of work or memory that your app uses, but
it may simplify your code: you will only have to hang on to the original
or contrast adjusted image and not the scaled image.

One note for performance.  For an image as large as 9.3mg, you might want
to perform contrast adjustment using a lookuptable.

To (try) and answer you questions:

1) Yes.  An image that has been scaled will not be the same as the
original.  The degree to which the original and scaled images are the same
is a function of the interpolation algorithm (e.g. Bilinear, Bicubic,
Nearest Neighbor) and the degree of scaling.  Performing any operation on
an image that has been scaled will yield less "accurate" results than
performing the operation on the original image itself.

2) Yes.  Instead of scaling via an AffineTransformOp, just draw it scaled.

Do you have a stack trace showing the StackOverflowError?

Hope this helps.

--
Andrew M. Sheridan
LumenIQ, Inc.
[EMAIL PROTECTED]


On Mon, 26 Jul 2004 21:16:24 -0400, John Wells <[EMAIL PROTECTED]> wrote:

Guys,

First of all, hello.  I'm new to the list.  First post.

I'm working on an application that reads a BufferedImage from a variety
of sources and allows a user to either scale the image with
AffineTransformOp or brighten/darken it with RescaleOp.

I keep two copies of the image in memory...the original and the modified
version.  I keep the original because I was never really able to get an
image to revert to it's normal state after being reduced in size with
the AffineTransform.  I suspect this is because of some matrix algebra
that I don't understand fully, but I simply found it easier to just
reset to the original image before trying another operation.

Anyway, I'm running into problems when I zoom around 5 levels because
I'm overrunning the allocated memory for the stack.  I've written one of
my test images to file at its largest size and it's around 9.3 mb.  I'm
very interested in keeping my applications footprint as small as
possible, so this is simply not good.

So, I have a few questions.

1. Am I correct in assuming I need to keep the original around after
zooming/shrinking to provide accurate contrasting operations?
2. Are there any strategies for reducing the size of a BufferedImage
that I might not be aware of?

Thanks for any information you provide, whether links, pointers to
books, or first-hand experience.  It will be very much appreciated.

John

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
of the message "signoff JAVA2D-INTEREST".  For general help, send email
to
[EMAIL PROTECTED] and include in the body of the message "help".

=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to