Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-26-2008, 11:53 PM
Member
 
Join Date: Jul 2008
Posts: 1
Rep Power: 0
legsmacgee is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 03-12-2009, 08:26 AM
Member
 
Join Date: Mar 2009
Posts: 13
Rep Power: 0
strati1991 is on a distinguished road
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){
}
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-24-2009, 10:48 AM
Member
 
Join Date: Apr 2009
Posts: 10
Rep Power: 0
rexicon is on a distinguished road
Default
Worked for me
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert between SWT Image and AWT BufferedImage Java Tip SWT 0 07-02-2008 08:06 PM
Convert Byte [] to BufferedImage Smily Advanced Java 3 04-28-2008 05:54 PM
BufferedImage to Byte Java Tip Java Tips 0 01-22-2008 08:17 PM


All times are GMT +2. The time now is 08:32 AM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org