Try this:

/**
  * Returns a scaled instance of an image.
  *
  * @param image the image to scale
  * @param scale the amount to scale it by
  *
  * @return the scaled version of the image
  */
public BufferedImage scaleImage(BufferedImage image, float scale)
{
    WritableRaster raster =
image.getRaster().createCompatibleWritableRaster(width,height);
    BufferedImage newImage = new
BufferedImage(image.getColorModel(),raster,false,null);

    // perform scale
    AffineTransformOp trans = new
AffineTransformOp(AffineTransform.getScaleInstance(scale,scale),AffineTransformOp.TYPE_BILINEAR);
    trans.filter(image,newImage);

    return newImage;
} // scaleImage()

This is easy to modify to perform a non-uniform scale.

At 06:06 PM 2/28/2002 -0800, you wrote:
>Hi all,
>     1.   I want to scale a BufferedImage. I tried
>using getScaledInstance() method of the Image class,
>which returns an Image. But I want a BufferedImage.
>     2.   How can we scale an image without using the
>loader.getScaledImage(width, height) method.
>
>Thanks in advance,
>Sagar.

=========================
Scott Rutledge, Lead Programmer
3D Design Division
BEQ Technologies Inc.
http://www.beq.ca
=========================

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

Reply via email to