简体   繁体   English

如何检查图像是8位还是16位?

[英]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?我正在制作使用 java SE 进行图像处理的应用程序。我想在运行时以编程方式检查图像是 8 位还是 16 位? and then according that i do image processing on that.so, how can i check it in java?然后根据我对它进行图像处理。那么,我如何在 java 中查看它?

If you read in the image as a BufferedImage , you can use the getType() method.如果您将图像作为BufferedImage读入,则可以使用getType()方法。

There is post here that is trying to read a 8-bit and 24-bit bmp file.这里有帖子试图读取 8 位和 24 位 bmp 文件。 http://www.javaworld.com/javaworld/javatips/jw-javatip43.html?page=2 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.一旦你得到这个计数,你就可以根据这个比特数来验证它是什么类型的图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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