Java Image Width

R

rickendall

What units does the getWidth() method of the BufferedImage class
return the width of an image in, I have a 2048x1536 pixel image loaded
but it returns the width as 4194304.
 
A

Andrew Thompson

"rickendall" ...
What units does the getWidth() method of the BufferedImage class
return the width of an image in,
pixels.

..I have a 2048x1536 pixel image loaded
but it returns the width as 4194304.

Sounds like your image is either corrupt
or at least suspect. Trty another image.
 
R

rickendall

Sounds like your image is either corrupt
or at least suspect. Trty another image.

This seems to be the case, for some reason every image that has been
taken with a Minolta DImage Xt digital camera has the width and height
stored incorrectly.

Has anybody else experienced similar difficulties?
 
A

Andrew Thompson

"rickendall" ...
This seems to be the case, for some reason every image that has been
taken with a Minolta DImage Xt digital camera has the width and height
stored incorrectly.

Bad, bad camera.

You might try the images in any old paint
program. If they can load the images OK,
save them to new names, that will probably
fix the problem.

There are probably 'bulk image processing'
apps out there that could do the entire lot in
a single pass.
Has anybody else experienced similar difficulties?

Yes. It was only an occasional image, and it
was long ago. I fixed them with the first
suggestion above.

HTH
 
N

nos

rickendall said:
What units does the getWidth() method of the BufferedImage class
return the width of an image in, I have a 2048x1536 pixel image loaded
but it returns the width as 4194304.

Note: 2048 left shift 11 bits gives 4194304, so I think the width
is actually stored in this shifted way. I have a hunch that if you
look at the height and do an "and" with 0x7ff
that your result will be 1536.

int w = getWidth() >> 11;
int h = getHeight() & 0x7ff;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top