Why does the 1bpp PNG image file size increase when the colors are inverted?

When I create black and white png images with an index color of 1 bit per pixel, it seems that the file size difference is noticeable if I prefer to use a black background over white. The attached images must have exactly the same information, and both of them are created by the .NET 4 Bitmap.Save () function.

Why is an image with a white background much larger when compressed?

Black Background: 4.62KB Black Background 4.62KB

White background: 5.67KB White background: 5.67KB

+4
source share
1 answer

The answer is perhaps surprising, but rather simple and lies in PNG format.

, PNG . , . , , .

. .

, , , . [...] , , .

- 0x00. 1- 4x4 .

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

, , .

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

.

0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1

, .

0x01 0x00, . .

+4

All Articles