开发者

Is is possible to use Java to read bitmap file header?

I found a problem when loading a bitmap file in my working company software. It crashes the software when I drop in the bitmap file. However, I am trying to create a Java app开发者_StackOverflow社区 to read the bitmap file header and display the header information. So I know what might causing the problem.

Can anyone suggest the idea how can I grab the bitmap file header information or which class should I use to achieve this goal?


Yes it is possible, I wrote code to do something like this with jpeg headers some months ago.

Basically, you need to learn a bit about the bitmap file format.

Then you need to open the file (for reading bytes).

Finally, you read enough bytes to get to the right field in the header, and decompose that to the Java data type you want.

There may be a class that already does this, in which case I would suggest Google for finding it.


The apache sanselan project provides a BmpImageParser class for parsing BMP files. You can take a look at the source here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜