png - Understanding image (its hex values) -


i trying understand hex values of 10 x 10 pixel png image file.

for example: using image http://www.sweethome3d.com/blog/common/images/feed-icon-10x10.png?. opened in sublime text 2 , saw following values

8950 4e47 0d0a 1a0a 0000 000d 4948 4452 0000 000a 0000 000a 0806 0000 008d 32cf bd00 0000 0467 414d 4100 00af c837 058a e900 0000 1974 4558 7453 6f66 7477 6172 6500 4164 6f62 6520 496d 6167 6552 6561 6479 71c9 653c 0000 0167 4944 4154 78da 2c90 3b48 1c51 1885 bf7b 6766 5d7c 63a1 ae5a 180b 9140 086a 213e 106c 042b c1c6 5641 49bb 8d8d 76a6 491b d248 40d2 2888 a585 2058 a960 a168 a128 be90 557c e26b d575 7667 e6de 9b99 5d8b c3df 7cff 3987 23ce 26be 8dc4 9dd8 3fa7 c8c1 7244 2889 0caf b40b 0a7c c5f3 7d66 545c 4db6 1bbb ac9a 928e 41cc c331 3ab5 8e15 fb7c 0841 6109 dc77 b023 27bb a29c f8d7 3eac 9a1f 98dc 1bc1 f62c e660 310f a99c 469a 9089 e2c4 c72d eeca 34d2 bda5 a873 1ca7 3b89 ae6e c65b fd89 9751 686d 45a0 c46e 68a1 6478 06f3 7683 dafc 8d7a 39c5 ea9d c29c 6ee3 6f2d 6144 e81a 15e7 6e97 dcdc 10e6 e904 bbff 172a f38a b7b3 10ba 8f11 b8aa 101f 15b6 abea 717a 9298 9365 f4f9 1a76 5792 8f8d 7964 651d b2ae 0de5 9b02 282b 13c8 c65e 681a c05d ff8b ac48 1064 35ea e91a e74b 7b1e 14af 7fba 4dbc d8a0 abbe e35d 1ee1 3da7 11b5 ad64 cf0f a134 819f 4e63 b20f c868 cc68 273f b58f 7273 61f1 18fe c51e 681f f598 ca43 ca09 46ff 0b30 0081 6599 b7e4 9326 ee00 0000 0049 454e 44ae 4260 82 

i intend display particular image on led matrix , before move forward displaying on led matrix, intend develop program can decode png file , use rgb values program leds. please explain how understand above values , extract every pixel's rgb value.

thank you.

a hex dump of png isn't human-readable. "od" comes closer:

od -c *.png 0000000 211   p   n   g  \r  \n 032  \n  \0  \0  \0  \r     h   d   r 0000020  \0  \0  \0  \n  \0  \0  \0  \n  \b 006  \0  \0  \0 215   2 317 0000040 275  \0  \0  \0 004   g     m    \0  \0 257 310   7 005 212 0000060 351  \0  \0  \0 031   t   e   x   t   s   o   f   t   w     r 0000100   e  \0     d   o   b   e         m     g   e   r   e   0000120   d   y   q 311   e   <  \0  \0 001   g     d     t   x 332 0000140   , 220   ;   h 034   q 030 205 277   {   g   f   ]   |   c 241 .... 0000660 030 376 305 036   h 037 365 230 312   c 312  \t   f 377  \v   0 0000700  \0 201   e 231 267 344 223   & 356  \0  \0  \0  \0     e   n 0000720   d 256   b   ` 202 

the first line 8-byte png signature, 4-byte number 13 (length of ihdr chunk), "ihdr".

the second line 13 bytes of ihdr data (width, height, bit depth, color type, etc.), followed 4-byte crc (cyclical redundancy check).

the third line gama chunk 4-byte length (4), "gama", 4-byte gamma value, , 4-byte crc

the fourth , fifth lines contain text chunk identifying software created png, 4-byte length, 4-byte chunk name "text", text, 4-byte crc.

the next line begins idat chunk contains zlib-compressed representation of pixels, again 4-byte length.

the final 2 lines contain crc idat chunk followed iend chunk mark end of png: 0000 data length, iend chunk name, , 256 b ` 202 four-byte crc iend chunk.

all of explained in png format specification, can read @ http://www.w3.org/tr/png

i second mark setchell's recommendation convert file trivial ppm format , work that; that's though i'm quite familiar png , libpng.

here's image looks ppm:

convert *.png -compress none ppm:- p3 10 10 255 221 117 45 229 122 51 234 129 56 237 134 57 240 139 59 242 144 60 244 148 61 246 152 62 242 147 59 225 125 48  229 122 51 233 135 73 244 190 152 243 170 114 241 139 53 244 145 54 247 150 56 249 154 57 250 157 58 241 145 58 [8 more long lines omitted] 

that's "p3" (means rgb, ascii format); 10 10 (width, height); 255 (maximum intensity value each channel); r g b r g b r g b.... until 100 rgb pixels have been transmitted

note alpha channel, if present, gets lost in conversion ppm. can convert netpbm's pam format http://en.m.wikipedia.org/wiki/netpbm#pam_graphics_format similar ppm has been extended include alpha (opacity) channel (but unfortunately not human-readable), or imagemagick's txt format instead; supports alpha quite verbose:

convert *.png txt:- # imagemagick pixel enumeration: 10,10,255,srgba 0,0: (221,117,45,0.376471)  #dd752d60  srgba(221,117,45,0.376471) 1,0: (229,122,51,1)  #e57a33  srgba(229,122,51,1) 2,0: (234,129,56,1)  #ea8138  srgba(234,129,56,1) etc., through 7,9: (226,113,53,1)  #e27135  srgba(226,113,53,1) 8,9: (223,109,49,1)  #df6d31  srgba(223,109,49,1) 9,9: (220,114,45,0.376471)  #dc722d60  srgba(220,114,45,0.376471) 

another useful application "pngcheck" lists png chunks , checks crc errors:

pngcheck -v *.png file: feed-icon-10x10.png (469 bytes)   chunk ihdr @ offset 0x0000c, length 13     10 x 10 image, 32-bit rgb+alpha, non-interlaced   chunk gama @ offset 0x00025, length 4: 0.45000   chunk text @ offset 0x00035, length 25, keyword: software   chunk idat @ offset 0x0005a, length 359     zlib: deflated, 32k window, maximum compression   chunk iend @ offset 0x001cd, length 0 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -