Results 1 to 3 of 3
  1. #1
    legsmacgee is offline Member
    Join Date
    Jul 2008
    Posts
    1
    Rep Power
    0

    Talking BufferedImage: Uneven rescale

    Hello,

    I want to resize a buffered image such that, for example, the left edge of the bufferedimage is half the original height and the right side is 1/3 the original height. How might I accomplish this? Thanks!

    --James

  2. #2
    strati1991 is offline Member
    Join Date
    Mar 2009
    Posts
    13
    Rep Power
    0

    Default

    create a BufferedImage with the height you want get the graphics from it and draw the image you want to rescale on the graphics of the BufferedImage..

    Image originalImage;
    int scaledWidth = (int)(image.getWidth() *scaleFactorX);
    int scaledHeight = (int)(image.getHeight() * ScaleFactorY);
    BufferedImage bi = new BufferedImage(scaledWidth,scaledHeight,1);
    Graphics2D g2 = (Graphics2D)bi.getGraphics();
    g2.drawImage(originalImage, 0, 0, scaledWidth , scaledHeight , null);
    try{
    ImageIO.write(bi,"bmp",new File(out));
    }catch(Exception e){
    }

  3. #3
    rexicon is offline Member
    Join Date
    Apr 2009
    Posts
    10
    Rep Power
    0

Similar Threads

  1. Replies: 0
    Last Post: 07-02-2008, 09:06 PM
  2. Convert Byte [] to BufferedImage
    By Smily in forum Advanced Java
    Replies: 3
    Last Post: 04-28-2008, 06:54 PM
  3. BufferedImage to Byte
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-22-2008, 09:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •