At offset 22 number of palette color entries is stored as short little endian
"palNumEntries". In most cases the palette contains 256 (0100h) colors ( see
At offset 16 data chunk size is stored as long value. The size should be
calculated by formula:
data size =
palVersion + palNumEntries + palPalEntry =
2 + 2 + palPalEntry
where palPalEntry is the raw palette or color vector which size is calculated
number of color entries * 4
So for palette with 256 colors we expect
2 + 2 + 256 * 4 = 4 + 1024 = 1028 = 00000404h
Graphic tool Xnview version 2.40 produce instead 1028 a 1032 data size for 256
colors like in palette-logos.pal. Such example was created by menu "Image",
"Edit Palette...", "Save...", "file type" and "Windows Palette"
That means some pal files contain some (4) extra bytes after color
vector. This is not logical but not explicitly forbidden by documentation.
At offset 4 riff size is stored as long value. Then the following
formula should be true:
file size = riff size + 8 = data size + 12 + 8
But when we compare real size mentioned in output/ls-la.txt with calculated
bytes based on riff size in output/file.txt we see in Xnview generated
examples like iEditor.pal real file size is 4 bytes lower. So two errors
"equalize" each other. According to internal structures extra bytes should exist
here, but the bytes does not exist because of lowered file size. This
inconsistency in data apparently do not hurt, if software just reads number of
colors, then calculate color vector size and then reads this vector.
A consistent 256 color palette example is morewi~1.pal found on Windows 98 CD with
data chunk size 1028 and file size 1048.
Xnview also seems to generate pal files with 256 colors even if less colors
are used like in BWrgb.pal with 5 colors. But Xnview reads palette files with
less colors like BlackWhite12.pal with just two colors.
I hope that somebody check these minor bugs and correct it.
I append an pal.zip archive with the examples , the output of ls and file(1) command.
with best regards
Bugs found in XnView Classic. Please report only one bug per topic!
1 post • Page 1 of 1
- (6.75 KiB) Downloaded 10 times
Who is online
Users browsing this forum: No registered users and 1 guest