IMAGE SCALING in JAVA..(please don give the thumnail.java code)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chetanankola
    New Member
    • Jan 2008
    • 1

    #1

    IMAGE SCALING in JAVA..(please don give the thumnail.java code)

    BufferedImage image = null;
    image = ImageIO.read(ne w File("D:\testim age.jpg"));

    width=640;
    height=480;
    int[] rgbdata = new int[width*height];
    image.getRGB(0, 0,width,height, rgbdata,0,width );

    bytes = new byte[rgbdata.length];
    pixelValues = new double[rgbdata.length];

    for ( int i = 0; i < bytes.length; i++) {
    bytes[i] = (byte) (rgbdata[i] & 0xFF);
    pixelValues[i] = (double)(rgbdat a[i]);
    }



    this is the code to read a test image s pixels into some array[]
    now what wod be the code to scale the image to some desired resolution
    say newwidth and newheight?

    so that the testimage which was havin resolution 640*480 is now having newwidth*newhei ght as
    its resolution wit newwidth*newhei ght already set beforehand.


    its like i want the image to be scaled even before the pixels are manipulated for some purpose
  • BigDaddyLH
    Recognized Expert Top Contributor
    • Dec 2007
    • 1216

    #2
    You can scale a BufferedImage using java.awt.image. AffineTransform Op. The AffineTransform would be a scale instance, of course.

    Comment

    Working...