gdiplus: Don't copy bits into the buffer when a bitmap is locked write-only.

This commit is contained in:
Vincent Povirk 2011-02-24 16:12:43 -06:00 committed by Alexandre Julliard
parent 58eb96c9e7
commit 9497e9380b
1 changed files with 17 additions and 11 deletions

View File

@ -968,12 +968,15 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
}
/* Make sure we can convert to the requested format. */
if (flags & ImageLockModeRead)
{
stat = convert_pixels(0, 0, 0, NULL, format, 0, NULL, bitmap->format, NULL);
if (stat == NotImplemented)
{
FIXME("cannot read bitmap from %x to %x\n", bitmap->format, format);
return NotImplemented;
}
}
/* If we're opening for writing, make sure we'll be able to write back in
* the original format. */
@ -995,6 +998,8 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
if (!buff) return OutOfMemory;
if (flags & ImageLockModeRead)
{
stat = convert_pixels(bitmap->width, bitmap->height,
stride, buff, format,
bitmap->stride, bitmap->bits, bitmap->format, bitmap->image.palette_entries);
@ -1004,6 +1009,7 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
GdipFree(buff);
return stat;
}
}
lockeddata->Width = act_rect.Width;
lockeddata->Height = act_rect.Height;