Commit 65750fab authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

gdiplus: Handle negative stride in GdipCreateBitmapFromScan0.

parent 4a8e1fee
......@@ -496,12 +496,6 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
if(scan0 && !stride)
return InvalidParameter;
/* FIXME: windows allows negative stride (reads backwards from scan0) */
if(stride < 0){
FIXME("negative stride\n");
return InvalidParameter;
}
*bitmap = GdipAlloc(sizeof(GpBitmap));
if(!*bitmap) return OutOfMemory;
......@@ -527,16 +521,29 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
bmih->biSize = sizeof(BITMAPINFOHEADER);
bmih->biWidth = width;
bmih->biHeight = -height;
/* FIXME: use the rest of the data from format */
bmih->biBitCount = PIXELFORMATBPP(format);
bmih->biCompression = BI_RGB;
bmih->biSizeImage = datalen;
if(scan0)
memcpy(bmih + 1, scan0, datalen);
if (scan0)
{
if (stride > 0)
{
bmih->biHeight = -height;
memcpy(bmih + 1, scan0, datalen);
}
else
{
bmih->biHeight = height;
memcpy(bmih + 1, scan0 + stride * (height - 1), datalen);
}
}
else
{
bmih->biHeight = height;
memset(bmih + 1, 0, datalen);
}
if(CreateStreamOnHGlobal(buff, TRUE, &stream) != S_OK){
ERR("could not make stream\n");
......
......@@ -129,10 +129,8 @@ static void test_Scan0(void)
bm = NULL;
stat = GdipCreateBitmapFromScan0(10, 10, -8, PixelFormat24bppRGB, buff, &bm);
todo_wine{
expect(Ok, stat);
ok(NULL != bm, "Expected bitmap to be initialized\n");
}
expect(Ok, stat);
ok(NULL != bm, "Expected bitmap to be initialized\n");
if (stat == Ok)
GdipDisposeImage((GpImage*)bm);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment