Skip to main content

Preserving lines in scaled bitmapped images

1 reply [Last post]
Anonymous

I have some bitmapped images of characters I scale down and draw onto
a Graphics2D object. I am losing detail and the characters are hard to
read.

What is the best way to keep these images sharp and preserve lines so
that d does not become c?

MArk

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Chris Nokleberg

Hi Mark,

On 12/14/06, Mark Stephens wrote:
> I have some bitmapped images of characters I scale down and draw onto
> a Graphics2D object. I am losing detail and the characters are hard to
> read.

There is no perfect solution, but here are some suggestions:

1) If you are not already, use one of the interpolation
RenderingHints, e.g. VALUE_INTERPOLATION_BICUBIC

2) Instead of scaling in one go, do multiple passes over the image,
scaling down a little bit each time. This should eliminate some of the
aliasing.

3) Use Image.getScaledInstance using the SCALE_AREA_AVERAGING hint. Be
aware that this is deprecated/discouraged/something similarly
negative, and quite slow.

4) Vote for this bug to get better downscaling interpolation methods
added to the JDK:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6500894
and then wait a few years.

Chris

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".