[File] [PATCH] of Magdir/images for Windows 3.x bitmap (*.bmp *.rle *.sys)

Jörg Jenderek joerg.jen.der.ek at gmx.net
Thu Jul 4 00:06:30 UTC 2019


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,
some days ago i handle some Windows 3.x bitmap variant. When i run
file command version 5.37 for these examples and other test files i
get an output like:

98SE2ME3.BMP:                 PC bitmap, Windows 3.x format,
	320 x 400 x 8
badplanes.bmp:                PC bitmap, Windows 3.x format,
	127 x 64 x 1
EGALOGO.RLE:                  PC bitmap, Windows 3.x format,
	640 x 350 x 4
fmt-116-signature-id-118.dib: PC bitmap, Windows 3.x format,
	-1414812757 x -1414812757 x 1
fmt-117-signature-id-119.dib: PC bitmap, Windows 3.x format,
	-1414812757 x -1414812757 x 16
HERCLOGO.RLE:                 PC bitmap, Windows 3.x format,
	720 x 348 x 4
logo.sys:                     PC bitmap, Windows 3.x format,
	320 x 400 x 8
logos.sys:                    PC bitmap, Windows 3.x format,
	320 x 400 x 8
logow.sys:                    PC bitmap, Windows 3.x format,
	320 x 400 x 8
NASABALL.BMP:                 PC bitmap, Windows 3.x format,
	800 x 600 x 4
pal1wb.bmp:                   PC bitmap, Windows 3.x format,
	127 x 64 x 1
pal2color.bmp:                PC bitmap, Windows 3.x format,
	127 x 64 x 2
rgb16-880.bmp:                PC bitmap, Windows 3.x format,
	127 x 64 x 16
rgb24largepal.bmp:            PC bitmap, Windows 3.x format,
	127 x 64 x 24
rgba32abf.bmp:                PC bitmap, Windows 3.x format,
	127 x 64 x 32
rletopdown.bmp:               PC bitmap, Windows 3.x format,
	127 x -64 x 8

Unfortunately test lines are not unique enough. Droid test skeletons
like fmt-116-signature-id-118.dib and fmt-117-signature-id-119.dib
are misidentified. So addtional test lines are needed.

Furthermore with --extension option ??? is displayed. And with
- --apple option UNKNUNKN is shown. With -i option deprecated
"image/x-ms-bmp" mime type is shown.

So i add/change lines in Magdir/images. I also add more lines to
display more details like the variable offBits by line
 >>>10	ulelong			x	\b, bits offset %u
That is the offset to bitmap data with value like 36h 76h BEh 236h
406h 436h 4E6h for  Windows 3.x bitmap. At first glance this is not
so interesting for users, but so i see that this value is relative
low. This is no explicitly mentioned in the documentation and this
information can be used as additional test.

I also show variable cbSize by line
 >>>2	ulelong		x		\b, cbSize %u
For  Windows 3.x bitmap this is often the file size, but in rare
cases this value is lower. So in the end i use this information as
additional test by jumping 4 bytes before end of file/header and
check for accessing these 4 bytes by line
 >>(2.l-4)	ulong	x		PC bitmap, Windows 3.x format
So bad examples like fmt-116-signature-id-118.dib are skipped.
Now afterward show new mime type and apple id by lines
 !:mime		image/bmp
 !:apple	????BMPp

According to https://en.wikipedia.org/wiki/LOGO.SYS the described
bitmap format is also used for Windows 9M boot and shutdown logos,
which have "sys" filename extension instead of usual "bmp". Such
logos have a dimension of 320 x 400. So test for these dimensions
and then show 2 possibles file name extensions by lines
 >>>18	ulequad		=0x0000019000000140	x
 !:ext	bmp/sys

The other examples are matched by branch starting with line
 >>>18	ulequad		!0x0000019000000140

Later i also show stored compression method as numeric by line
 >>>30	ulelong		>0		\b, %u compression
Value 1 means "RLE 8-bit/pixel" compression. 2 means "RLE
4-bit/pixel" compression. 3 means Huffman 1D compression.
Some times instead bmp file name extension rle is used for run
length encoding compressed bitmaps. I found examples like
EGALOGO.RLE with compression method 2 value. This is now described
in second branch by lines
 >>>>30	ulelong		2		x
 !:ext	bmp/rle
 >>>>30	default		x		x
 !:ext	bmp

After applying the above mentioned modifications by patch
file-5.37-images-bmp_rle.diff then observed misidentification
vanish and more details are displayed like

98SE2ME3.BMP:                 PC bitmap, Windows 3.x format,
	320 x 400 x 8, image size 128000,
	236 important colors,
	cbSize 129082, bits offset 1078
badplanes.bmp:                PC bitmap, Windows 3.x format,
	127 x 64 x 1, image size 1024,
	resolution 2835 x 2835 px/m,
	cbSize 1086, bits offset 62
EGALOGO.RLE:                  PC bitmap, Windows 3.x format,
	640 x 350 x 4, 2 compression, image size 17240,
	16 important colors,
	cbSize 17358, bits offset 118
fmt-116-signature-id-118.dib: data
fmt-117-signature-id-119.dib: data
HERCLOGO.RLE:                 PC bitmap, Windows 3.x format,
	720 x 348 x 4, 2 compression, image size 15950,
	16 important colors,
	cbSize 16068, bits offset 118
logo.sys:                     PC bitmap, Windows 3.x format,
	320 x 400 x 8, image size 128000,
	236 important colors,
	cbSize 129082, bits offset 1078
logos.sys:                    PC bitmap, Windows 3.x format,
	320 x 400 x 8,
	cbSize 129078, bits offset 1078
logow.sys:                    PC bitmap, Windows 3.x format,
	320 x 400 x 8,
	cbSize 129078, bits offset 1078
NASABALL.BMP:                 PC bitmap, Windows 3.x format,
	800 x 600 x 4, 2 compression, image size 53450,
	16 important colors,
	cbSize 53568, bits offset 118
pal1wb.bmp:                   PC bitmap, Windows 3.x format,
	127 x 64 x 1, image size 1024,
	resolution 2835 x 2835 px/m,
	cbSize 1086, bits offset 62
pal2color.bmp:                PC bitmap, Windows 3.x format,
	127 x 64 x 2, image size 2048,
	resolution 2835 x 2835 px/m,
	cbSize 2118, bits offset 70
rgb16-880.bmp:                PC bitmap, Windows 3.x format,
	127 x 64 x 16, 3 compression, image size 16384,
	resolution 2835 x 2835 px/m,
	cbSize 16450, bits offset 66
rgb24largepal.bmp:            PC bitmap, Windows 3.x format,
	127 x 64 x 24, image size 24576,
	resolution 2835 x 2835 px/m,
	cbSize 25830, bits offset 1254
rgba32abf.bmp:                PC bitmap, Windows 3.x format,
	127 x 64 x 32, 6 compression, image size 32512,
	resolution 2835 x 2835 px/m,
	cbSize 32582, bits offset 70
rletopdown.bmp:               PC bitmap, Windows 3.x format,
	127 x -64 x 8, 1 compression, image size 7726,
	resolution 2835 x 2835 px/m,
	cbSize 8788, bits offset 1062

I hope my diff file can be applied in future version of
file utility.

With best wishes
Jörg Jenderek
- --
Jörg Jenderek


-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iF0EARECAB0WIQS5/qNWKD4ASGOJGL+v8rHJQhrU1gUCXR1C7QAKCRCv8rHJQhrU
1qRvAKCU2oQSs025KPsKSNJM2n8q/Zwn+QCeK33bjZd5ZEH3v2NP71lZq9qconI=
=jjE3
-----END PGP SIGNATURE-----
-------------- next part --------------
--- file-5.37/magic/Magdir/images.old	2019-04-19 00:42:27 +0000
+++ file-5.37/magic/Magdir/images	2019-07-03 21:22:25 +0000
@@ -583,7 +583,44 @@
 >>20	leshort		x		%d
->14	leshort		40		PC bitmap, Windows 3.x format
-!:mime	image/x-ms-bmp
->>18	lelong		x		\b, %d x
->>22	lelong		x		%d x
->>28	leshort		x		%d
+>14	leshort		40
+# jump 4 bytes before end of file/header to skip fmt-116-signature-id-118.dib
+>>(2.l-4)	ulong	x		PC bitmap, Windows 3.x format
+!:mime	image/bmp
+!:apple	????BMPp
+>>>18	lelong		x		\b, %d x
+>>>22	lelong		x		%d
+# 320 x 400		https://en.wikipedia.org/wiki/LOGO.SYS
+>>>18	ulequad		=0x0000019000000140	x
+!:ext	bmp/sys
+>>>18	ulequad		!0x0000019000000140
+# compression method 2~RLE 4-bit/pixel implies also extension rle
+>>>>30	ulelong		2		x
+!:ext	bmp/rle
+>>>>30	default		x		x
+!:ext	bmp
+# number of bits per pixel (color depth); found 1 2 4 8 16 24 32
+>>>28	leshort		x		%d
+# x, y coordinates of the hotspot; there is no hotspot in bitmaps, so values 0
+#>>>6	uleshort	>0		\b, hotspot %ux
+#>>>>8	uleshort	x		\b%u
+# number of color planes (must be 1), except badplanes.bmp for testing
+#>>>26	uleshort	>1		\b, %u color planes
+# compression method: 0~no 1~RLE 8-bit/pixel 2~RLE 4-bit/pixel 3~Huffman 1D 6~RGBA bit field masks
+#>>>30	ulelong		3		\b, Huffman 1D compression
+>>>30	ulelong		>0		\b, %u compression
+# image size is the size of raw bitmap; a dummy 0 can be given for BI_RGB bitmaps
+>>>34	ulelong		>0		\b, image size %u
+# horizontal and vertical resolution of the image (pixel per metre, signed integer) 
+>>>38	lelong		>0		\b, resolution %d x
+>>>>42	lelong		x		%d px/m
+# number of colors in palette 16 256, or 0 to default to 2**n
+#>>>46	ulelong		>0		\b, %u colors
+# number of important colors used, or 0 when every color is important
+>>>50	ulelong		>0		\b, %u important colors
+# cbSize; often size of file
+>>>2	ulelong		x		\b, cbSize %u
+#>>>2	ulelong		x		\b, cbSize 0x%x
+# offBits; offset to bitmap data like 36h 76h BEh 236h 406h 436h 4E6h
+>>>10	ulelong			x	\b, bits offset %u
+#>>>10	ulelong			x	\b, bits offset 0x%x
+#>>>(10.l) ubequad		!0	\b, bits 0x%16.16llxd
 >14	leshort		124		PC bitmap, Windows 98/2000 and newer format
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.37-images-bmp_rle.diff.sig
Type: application/octet-stream
Size: 95 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20190704/8a2d0079/attachment.obj>


More information about the File mailing list