java - How to get exact bitmap file size? -



java - How to get exact bitmap file size? -

i'm trying right width , height of bitmap file via hex info. i've got width , height specified in header, need adjust width due padding , calculate size of file in bytes.

the formula i'm using right is

(width * height * colordepth)/8 + 54

first of all, formula correct, , second, how adjust width padding?

calculating total size of bmp file not simple. formula provided leads me believe looking specific bmp file type :

a simple bitmapinfoheader (v3 bmp); no compression (bi_rgb).

this gives header size of 54 bytes.

in bmp file, each rows of pixels rounded multiple of 4 bytes (the row padded). hence obtain real size of bmp need calculate row size padding, multiply image height , add together header size.

to calculate row size padding (in bytes) utilize formula : ceiling(width * bpp / 32) * 32 / 8.

to calculate total size (in bytes) of bmp can utilize : (height * ceiling(width * bpp / 32) * 32) / 8 + 54.

where bpp bits-per-pixel (color depth).

java bitmap

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -