|FROM ||Ruben Safir
|SUBJECT ||Subject: [Learn] PNG Graphic formats and CRCs
|From learn-bounces-at-nylxs.com Mon Nov 14 20:28:50 2016
Received: from www.mrbrklyn.com (www.mrbrklyn.com [184.108.40.206])
by mrbrklyn.com (Postfix) with ESMTP id 48960161316;
Mon, 14 Nov 2016 20:28:50 -0500 (EST)
Received: from [10.0.0.62] (flatbush.mrbrklyn.com [10.0.0.62])
by mrbrklyn.com (Postfix) with ESMTP id B1021160E77;
Mon, 14 Nov 2016 20:28:41 -0500 (EST)
To: learn-at-mrbrklyn.com, Hangout
From: Ruben Safir
Date: Mon, 14 Nov 2016 20:28:41 -0500
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Subject: [Learn] PNG Graphic formats and CRCs
Content-Type: text/plain; charset="us-ascii"
First, I just want to apologize for being a bit quiet this last 48 hours.
Years ago, my beloved Grandmother said to me that she was going to die
in the month of July because the heat made her suffer. It was about
correct. For me, I'm going to die this month, in fall. I love the
fall, but in NY I am allergic to something in the environment. It is
likely mode. It can't breath, and suffer horribly. To make it worse,
then I go fishing, the crabs that are stored in coolers, and a breathing
and living vector for infectious disease, and the mold develops all over
there shells. When black fishing, it gets into my eyes and into my
lungs, and this year has been particularly bad. It has created a mucus
plug in my long and I've gotten nearly no sleep this week. I finally
broke down this past 24 hours and I haven't been able to even think
straight. I went to the MD this morning. It has made me appreciate
what my asthma patients have gone through. I couldn't even read today,
let alone to write code.
I've tried to focus what energy I could on the PNG file format. This is
my project for the parallel programming class. I've got to manipulate
this format in parallel and I've try to tackle this also in C++. I had
an arterial motive for choosing this.
When the PNG format came out as a free alternative to the gif format, I
adopted it with excitement. The libraries had bugs in them and I have
many early graphics which I haven't been able to fix with existing
software on Linux, although they do view great with unfixed libs,
including those on non-free platforms. SO in an attempt to fix it, I've
thought I need to explore these files myself and see what I can fix.
In that regard, I've picked up two texts on this topic:
Compressed Image File Formats: JPEG, PNG, GIF, XBM, and BMP - John Miano.
This is a text that is part of the ACM Books, from the SIGGRAPH which is
very cool. As someone who has spent more than a few years organizing
and trying our hand as club based publications, I'm very impressed and
enjoying this text. It happens to be concise and well written.
The other text is an animal book
PNG: The definitive guide - by Greg Roelofs
This is a larger text that covers many uses of PNG files including front
end software like the GIMP and many graphics standards and theories. HE
does include a basic C program that reads PNGs and I will look at that
in detail. I have only a month left to finish this project.
The first challenge I've run into is the discussion of the CRC check.
I'm reading this and see I don't understand how this works. First, it
is a modulo 2 polynominial division on the input data. <<=== that
sentence I don't understand.
The polynumerial that PNG uses is
x^32 + x^26 + x^23 + xx^22 + x16 + x^12 + x^11 + x^10 + x^8 + x^7 + x^5
+ x^4 + x^2 + x + 1
which that say is essentially the value
1 0000 0100 1100 0001 0001 1101 1011 0111 base 2
I can see how this maps, each binary position being affiliated with a
different power from 32 -> 0
I don't know why.
Then it saysin PNG software, the CRC registr is initialized with all
bits set to 1. After the last byte has been processed the final CRC
value is the 1s-complement of the value in the CRC register. And then
there is code
unsigned long CrcRegister ;
void CrcByte (unsigned char data)
unsigned int index = (CrcRegister ^ data) & 0xFF ;
CrcRegister = CrcTable [index] ^ ((CrcRegister >> 8) & 0x00FFFFFF) ;
unsigned long Crc (UBYTE1 type , UBYTE1 buffer , unsigned int length)
CrcRegister = 0xFFFFFFFFL ;
for (unsigned int ii = 0 ; ii < 4 ; ++ ii)
CrcByte (type [ii]) ;
for (unsigned int jj = 0 ; jj < length ; ++ jj)
CrcByte (buffer [jj]) ;
return ~CrcRegister ;
void MakeCrcTable ()
for (unsigned int ii = 0 ; ii < 256 ; ++ ii)
CrcTable [ii] = ii ;
for (unsigned int jj = 0 ; jj < 8 ; ++ jj)
if ((CrcTable [ii] & 0x1) == 0)
CrcTable [ii] >>= 1 ;
CrcTable [ii] = 0xEDB88320L ^ (CrcTable [ii] >> 1) ;
I'm fairly lost on this. There is a collision of a few items of
knowledge but overall, I'd like to understand exactly what this code is
So many immigrant groups have swept through our town
that Brooklyn, like Atlantis, reaches mythological
proportions in the mind of the world - RI Safir 1998
DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
http://www.nylxs.com - Leadership Development in Free Software
http://www2.mrbrklyn.com/resources - Unpublished Archive
http://www.coinhangout.com - coins!
Being so tracked is for FARM ANIMALS and and extermination camps,
but incompatible with living as a free human being. -RI Safir 2013
Learn mailing list