Hi Randy,

Your code snippet looks fine, but I'd suggest using
AffineTransformOp.TYPE_BILINEAR rather than TYPE_NEAREST_NEIGHBOR.  This
filtering method can be more computationally expensive, but produces
more visually pleasing results.  Note that the image will look slightly
blurred, but this is typically more pleasing than a blocky-looking image
(like NEAREST_NEIGHBOR produces).

The approach that Rob mentioned will also get the job done just fine
(getScaledInstance(SCALE_SMOOTH) uses a bilinear filter), but
AffineTransformOp.filter() is more likely to be "natively" accelerated
(in Sun's implementation anyway).

BTW, you can search the java2d-interest archive online at:
http://archives.java.sun.com/java2d-interest.html

Thanks,
Chris

Rob Ratcliff wrote:
> Randy,
>
> I've had good luck with this:
>
> Image newImage =
> oldImage().getScaledInstance(scaledWidth,scaledHeight,Image.SCALE_SMOOTH));
>
> At 04:49 PM 10/16/2002 -0500, you wrote:
>
>> I wasn't able to locate an archive to search so apologize if this is a
>> duplicate question.
>> I am using an AffineTransform to make an image larger.  Unfortunately
>> the image is blurred and not sharp or crisp as the original.
>> I use the same scale both for X and Y.  Is that correct?
>> I'm going to paste the code below.
>>
>>  transform.setToScale(scaleX, scaleY);
>>  AffineTransformOp op = new AffineTransformOp(transform,
>> AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
>>  Graphics2D biDestG2D = biDest.createGraphics();
>>  biDestG2D.clearRect(0, 0, scaledWidth, scaledHeight);
>>  op.filter(biSrc, biDest);
>>  bufImage = biDest;
>> Is there a way to enlarge an image and keep the quality of the image?
>>
>> TIA for any help you can offer.  This seems like it should be fairly
>> straight forward and I just can't get it to work.
>> Regards,
>> Randy C.
>
> ===========================================================================
> 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".

--
Chris Campbell                     408-276-6429
[EMAIL PROTECTED]       x16429
Sun Microsystems, Java 2D          USCA22-212

===========================================================================
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