MCPcopy Create free account
hub / github.com/CruiserOne/Astrolog / WritePNGChunk

Function WritePNGChunk

xdevice.cpp:1147–1167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1145// Output a PNG chunk to a PNG file being composed.
1146
1147void WritePNGChunk(FILE *file, CONST char szType[5], byte *rgb, dword cb,
1148 CONST dword rglCrc[256])
1149{
1150 dword dwT, crc, n;
1151
1152 dwT = LFlipB(cb);
1153 fwrite(&dwT, 1, 4, file);
1154 fwrite(szType, 1, 4, file);
1155 if (cb > 0)
1156 fwrite(rgb, 1, cb, file);
1157
1158 // Compute CRC for this chunk.
1159 crc = 0xffffffffL;
1160 for (n = 0; n < 4; n++)
1161 crc = rglCrc[(crc ^ szType[n]) & 0xff] ^ (crc >> 8);
1162 for (n = 0; n < cb; n++)
1163 crc = rglCrc[(crc ^ rgb[n]) & 0xff] ^ (crc >> 8);
1164 crc ^= 0xffffffffL;
1165 crc = LFlipB(crc);
1166 fwrite(&crc, 1, 4, file);
1167}
1168
1169
1170// Output a bitmap to file in Portable Network Graphics (PNG) format. Note

Callers 1

WritePNGFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected