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, ...@@ -496,12 +496,6 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
if(scan0 && !stride) if(scan0 && !stride)
return InvalidParameter; return InvalidParameter;
/* FIXME: windows allows negative stride (reads backwards from scan0) */
if(stride < 0){
FIXME("negative stride\n");
return InvalidParameter;
}
*bitmap = GdipAlloc(sizeof(GpBitmap)); *bitmap = GdipAlloc(sizeof(GpBitmap));
if(!*bitmap) return OutOfMemory; if(!*bitmap) return OutOfMemory;
...@@ -527,16 +521,29 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, ...@@ -527,16 +521,29 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
bmih->biSize = sizeof(BITMAPINFOHEADER); bmih->biSize = sizeof(BITMAPINFOHEADER);
bmih->biWidth = width; bmih->biWidth = width;
bmih->biHeight = -height;
/* FIXME: use the rest of the data from format */ /* FIXME: use the rest of the data from format */
bmih->biBitCount = PIXELFORMATBPP(format); bmih->biBitCount = PIXELFORMATBPP(format);
bmih->biCompression = BI_RGB; bmih->biCompression = BI_RGB;
bmih->biSizeImage = datalen; bmih->biSizeImage = datalen;
if(scan0) if (scan0)
memcpy(bmih + 1, scan0, datalen); {
if (stride > 0)
{
bmih->biHeight = -height;
memcpy(bmih + 1, scan0, datalen);
}
else
{
bmih->biHeight = height;
memcpy(bmih + 1, scan0 + stride * (height - 1), datalen);
}
}
else else
{
bmih->biHeight = height;
memset(bmih + 1, 0, datalen); memset(bmih + 1, 0, datalen);
}
if(CreateStreamOnHGlobal(buff, TRUE, &stream) != S_OK){ if(CreateStreamOnHGlobal(buff, TRUE, &stream) != S_OK){
ERR("could not make stream\n"); ERR("could not make stream\n");
......
...@@ -129,10 +129,8 @@ static void test_Scan0(void) ...@@ -129,10 +129,8 @@ static void test_Scan0(void)
bm = NULL; bm = NULL;
stat = GdipCreateBitmapFromScan0(10, 10, -8, PixelFormat24bppRGB, buff, &bm); stat = GdipCreateBitmapFromScan0(10, 10, -8, PixelFormat24bppRGB, buff, &bm);
todo_wine{ expect(Ok, stat);
expect(Ok, stat); ok(NULL != bm, "Expected bitmap to be initialized\n");
ok(NULL != bm, "Expected bitmap to be initialized\n");
}
if (stat == Ok) if (stat == Ok)
GdipDisposeImage((GpImage*)bm); 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