简体   繁体   中英

how to check whether image is 8 bit or 16 bit?

im making APP which do image proceesing using java SE.i want to check programeticly at run time that whether image is 8 bit or 16 bit? and then according that i do image processing on that.so, how can i check it in java?

If you read in the image as a BufferedImage , you can use the getType() method.

There is post here that is trying to read a 8-bit and 24-bit bmp file. http://www.javaworld.com/javaworld/javatips/jw-javatip43.html?page=2

Here it tries to get the number of bits like this:

int nbitcount = (((int)bi[15]&0xff)<<8) | (int)bi[14]&0xff

Once you get this count you can validate this what type of image it is based on this bit count.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM