Merge pull request #1397 from CosmosOS/quajak-patch-1

Add support for BITMAPV3INFOHEADER
This commit is contained in:
valentinbreiz 2020-07-10 13:24:20 +02:00 committed by GitHub
commit d517805fa2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -182,7 +182,7 @@ namespace Cosmos.System.Graphics
//now reading size of BITMAPINFOHEADER should be 40 - bytes 14 -> 18 //now reading size of BITMAPINFOHEADER should be 40 - bytes 14 -> 18
stream.Read(_int, 0, 4); stream.Read(_int, 0, 4);
uint infoHeaderSize = BitConverter.ToUInt32(_int, 0); uint infoHeaderSize = BitConverter.ToUInt32(_int, 0);
if (infoHeaderSize != 40) if (infoHeaderSize != 40 && infoHeaderSize != 56) // 56 - is BITMAPV3INFOHEADER, where we ignore the additional values see https://web.archive.org/web/20150127132443/https://forums.adobe.com/message/3272950
{ {
throw new Exception("Info header size has the wrong value!"); throw new Exception("Info header size has the wrong value!");
} }
@ -201,6 +201,7 @@ namespace Cosmos.System.Graphics
{ {
throw new Exception("Number of planes is not 1! Can not read file!"); throw new Exception("Number of planes is not 1! Can not read file!");
} }
//now reading size of bits per pixel (1, 4, 8, 24, 32) - bytes 28 - 30 //now reading size of bits per pixel (1, 4, 8, 24, 32) - bytes 28 - 30
stream.Read(_short, 0, 2); stream.Read(_short, 0, 2);
ushort pixelSize = BitConverter.ToUInt16(_short, 0); ushort pixelSize = BitConverter.ToUInt16(_short, 0);
@ -213,7 +214,7 @@ namespace Cosmos.System.Graphics
stream.Read(_int, 0, 4); stream.Read(_int, 0, 4);
uint compression = BitConverter.ToUInt32(_int, 0); uint compression = BitConverter.ToUInt32(_int, 0);
//TODO: Be able to handle compressed files //TODO: Be able to handle compressed files
if (compression != 0) if (compression != 0 && compression != 3) //3 is BI_BITFIELDS again ignore for now is for Adobe Images
{ {
Global.mDebugger.Send("Can only handle uncompressed files!"); Global.mDebugger.Send("Can only handle uncompressed files!");
throw new NotImplementedException("Can only handle uncompressed files!"); throw new NotImplementedException("Can only handle uncompressed files!");