Skip to main content

BufferedImage gettype always returns 0

3 replies [Last post]
shihabkb
Offline
Joined: 2008-12-31
Points: 0

Dear friends,

I have written the following code. My problem is the getType of BufferedImage always returns as 0. I can display the image in the label.

String imgpath = "G:\\eclipse\\DSCN1234.jpg";
File file = new File(imgpath);
BufferedImage img = ImageIO.read(file);
System.out.println(img.getType());

But when I am trying to do the following code it fails due to the prevImage.getType() returns 0. Some body please help.

BufferedImage scaledImage = new BufferedImage(imageW, imageH, );
Graphics2D g2d = scaledImage.createGraphics();

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
marcojacob
Offline
Joined: 2006-07-10
Points: 0

Sorry, but I don't get the connection between the two code snippets.
It seems there is some code missing to understand your problem.

Maybe you can provide more information, code or the StackTrace you get
running your code.

shihabkb
Offline
Joined: 2008-12-31
Points: 0

my question is why getType always returs 0.

marcojacob
Offline
Joined: 2006-07-10
Points: 0

It seems to me that your Nikon camera stores a custom color profile
with the JPEG image so the type is always TYPE_CUSTOM.

It _might_ be that the format is TYPE_INT_RGB and you can just draw it but maybe the result is not sophisticating.

If you need a special colorspace to write into, you can e.g. convert
to TYPE_INT_RGB with JAI operation ColorConvert. Please consult
the JAI list for more help with JAI.