Calculate the size of BI_BITFIELDS dib sections via the width and

height.
This commit is contained in:
Jason Edmeades 2004-03-07 03:47:55 +00:00 committed by Alexandre Julliard
parent 03210d446c
commit af83e4cf91
1 changed files with 12 additions and 6 deletions

View File

@ -3907,16 +3907,20 @@ done:
*/ */
static void X11DRV_DIB_DoProtectDIBSection( BITMAPOBJ *bmp, DWORD new_prot ) static void X11DRV_DIB_DoProtectDIBSection( BITMAPOBJ *bmp, DWORD new_prot )
{ {
DWORD old_prot;
INT totalSize;
DIBSECTION *dib = bmp->dib; DIBSECTION *dib = bmp->dib;
INT effHeight = dib->dsBm.bmHeight >= 0? dib->dsBm.bmHeight INT effHeight = dib->dsBm.bmHeight >= 0? dib->dsBm.bmHeight
: -dib->dsBm.bmHeight; : -dib->dsBm.bmHeight;
/* use the biSizeImage data as the memory size only if we're dealing with a /* use the biSizeImage data as the memory size only if we're dealing with a
compressed image where the value is set. Otherwise, calculate based on compressed image where the value is set. Otherwise, calculate based on
width * height */ width * height */
INT totalSize = dib->dsBmih.biSizeImage && dib->dsBmih.biCompression != BI_RGB if (dib->dsBmih.biSizeImage &&
? dib->dsBmih.biSizeImage (dib->dsBmih.biCompression == BI_RLE4 || dib->dsBmih.biCompression == BI_RLE8))
: dib->dsBm.bmWidthBytes * effHeight; totalSize = dib->dsBmih.biSizeImage;
DWORD old_prot; else
totalSize = dib->dsBm.bmWidthBytes * effHeight;
VirtualProtect(dib->dsBm.bmBits, totalSize, new_prot, &old_prot); VirtualProtect(dib->dsBm.bmBits, totalSize, new_prot, &old_prot);
TRACE("Changed protection from %ld to %ld\n", old_prot, new_prot); TRACE("Changed protection from %ld to %ld\n", old_prot, new_prot);
@ -4532,8 +4536,10 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
/* Get storage location for DIB bits. Only use biSizeImage if it's valid and /* Get storage location for DIB bits. Only use biSizeImage if it's valid and
we're dealing with a compressed bitmap. Otherwise, use width * height. */ we're dealing with a compressed bitmap. Otherwise, use width * height. */
totalSize = bi->biSizeImage && bi->biCompression != BI_RGB if (bi->biSizeImage && (bi->biCompression == BI_RLE4 || bi->biCompression == BI_RLE8))
? bi->biSizeImage : bm.bmWidthBytes * effHeight; totalSize = bi->biSizeImage;
else
totalSize = bm.bmWidthBytes * effHeight;
if (section) if (section)
{ {