Thanks, Chris! I actually tried using the TYPE_BILINEAR and it was equally blurry. Any ideas on why that might be the case? BTW, I'm using a JPEG file. I don't know if that could make a difference. I noticed that their are static constants for TYPE_UNIFORM_SCALE and TYPE_GENERAL_SCALE etc on the AffineTransform. Which one of these variables should I use and how do I use it? Are there any others that are important?
Lastly, if I want an image to scale proportionally then do I use the same scale factor for the X axis as for the Y axis? I'm currently using the same scale factor. Thanks again for any help you can provide! Regards, Randy ----- Original Message ----- From: "Chris Campbell" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, October 16, 2002 7:49 PM Subject: Re: [JAVA2D] Question on enlarging an image > 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".
