Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Fixed issues that prevented visibly drawing many WMF files#135

Merged
akoeplinger merged 2 commits intomono:masterfrom
akoeplinger:pr-28-cleanup-metafile
Nov 24, 2017
Merged

Fixed issues that prevented visibly drawing many WMF files#135
akoeplinger merged 2 commits intomono:masterfrom
akoeplinger:pr-28-cleanup-metafile

Conversation

@akoeplinger
Copy link
Member

  • Added a new drawing instruction / record (METAFILE_RECORD_DIBSTRETCHBLT) which is substantially the same as METAFILE_RECORD_STRETCHDIBITS
  • Corrected parsing of certain values so that they're treated as signed instead of unsigned, including adding a GETS macro to complement the existing GETW but returning a SHORT instead of a WORD
  • Fixed scaling for drawing to a specified size and improved translation at the same time
  • Corrected handling of the DIB BitmapInfoHandler ImageSize field -- it now calculates the value when compression is not used (Compression field = 0 / RGB)

Note: these are the extracted WMF changes from #28 + cleanup, let's see what CI says 😄

 * Added a new drawing instruction / record (METAFILE_RECORD_DIBSTRETCHBLT) which is substantially the same as METAFILE_RECORD_STRETCHDIBITS
 * Corrected parsing of certain values so that they're treated as signed instead of unsigned, including adding a GETS macro to complement the existing GETW but returning a SHORT instead of a WORD
 * Fixed scaling for drawing to a specified size and improved translation at the same time
 * Corrected handling of the DIB BitmapInfoHandler ImageSize field -- it now calculates the value when compression is not used (Compression field = 0 / RGB)
@akoeplinger
Copy link
Member Author

@hughbe not sure if you played with the WMF code before but if you did I'd appreciate a review from you :)

src/metafile.c Outdated
// Per the spec, if compression is RGB ImageSize must be ignored (and it should be zero anyway)
// and calculated according to the following formula.
ms.size = (((lpBitsInfo->bmiHeader.biWidth * lpBitsInfo->bmiHeader.biPlanes *
lpBitsInfo->bmiHeader.biBitCount + 31) & ~31) / 8) * abs(lpBitsInfo->bmiHeader.biHeight);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the thing that is being multiplied by abs(lpBits...) needs to be floored according to https://en.m.wikipedia.org/wiki/BMP_file_format#Pixel_Storage

src/metafile.c Outdated
#endif
ms.ptr = (BYTE*)lpBitsInfo;
ms.size = lpBitsInfo->bmiHeader.biSizeImage;
if (lpBitsInfo->bmiHeader.biCompression == 0) { // 0 == RGB
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use BI_RGB macro here

@akoeplinger
Copy link
Member Author

@hughbe fixed, thanks!

@hughbe
Copy link
Contributor

hughbe commented Nov 24, 2017

Looks great thanks! I don’t understand the rest of the #28 changes that aren’t related to metafiles

@akoeplinger akoeplinger merged commit e940864 into mono:master Nov 24, 2017
@akoeplinger akoeplinger deleted the pr-28-cleanup-metafile branch November 24, 2017 13:07
@akoeplinger akoeplinger mentioned this pull request Nov 24, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants