resizing image in java

Thread Starter

onebird

Joined Mar 27, 2010
16
I am working on a small hobby project, in which i need to re-size my images to a fixed size of 180x230 pixels. To do that, I'm using the method below:

Rich (BB code):
private Image scale(Image src) {        
        int w = 180;       
        int h = 230;
        int type = BufferedImage.TYPE_INT_RGB;
        BufferedImage dst = new BufferedImage(w, h, type);
        Graphics2D g2 = dst.createGraphics();
        g2.drawImage(src, 0, 0, w, h,null);
        g2.dispose();
                       
        return (new ImageIcon(dst)).getImage();
    }
For some reason, my images are returning all blacked out, I have no idea why. But if I use my images without resizing them with this method, they are displayed correctly. Any hints or pointers on how I can fix this problem? any help would be greatly appreciated
 

Thread Starter

onebird

Joined Mar 27, 2010
16
I don't know, if I am unclear in my question. But I'm wondering if its just that no-one can help me or what
 

redimage

Joined May 8, 2013
2
here is some codes in C# image reisize
public static void ResizeImageDemo()
{
string fileName = "c:/Sample.png";

REImage reImage = REFile.OpenImageFile(fileName);

ImageProcessing.applyResize(reImage, 500, 500);

REFile.SaveImageFile(reImage,"c:/reimage.png", new PNGEncoder());
}
 

Michael620

Joined May 8, 2013
7
I don't know, if I am unclear in my question. But I'm wondering if its just that no-one can help me or what
 
Last edited by a moderator:
Top