Commit 0595fc5e authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

gdiplus: Implement GdipGetImageRawFormat.

parent 160d7dfb
......@@ -208,6 +208,7 @@ struct GpAdustableArrowCap{
struct GpImage{
IPicture* picture;
ImageType type;
GUID format;
UINT flags;
};
......
......@@ -1235,6 +1235,7 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete,
(*metafile)->image.type = ImageTypeMetafile;
memcpy(&(*metafile)->image.format, &ImageFormatWMF, sizeof(GUID));
(*metafile)->bounds.X = ((REAL) placeable->BoundingBox.Left) / ((REAL) placeable->Inch);
(*metafile)->bounds.Y = ((REAL) placeable->BoundingBox.Right) / ((REAL) placeable->Inch);
(*metafile)->bounds.Width = ((REAL) (placeable->BoundingBox.Right
......
......@@ -413,6 +413,9 @@ GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage)
GdipDisposeImage(*cloneImage);
*cloneImage = NULL;
}
memcpy(&(*cloneImage)->format, &image->format, sizeof(GUID));
return stat;
}
else
......@@ -858,6 +861,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
}
(*bitmap)->image.type = ImageTypeBitmap;
memcpy(&(*bitmap)->image.format, &ImageFormatMemoryBMP, sizeof(GUID));
(*bitmap)->image.flags = ImageFlagsNone;
(*bitmap)->width = width;
(*bitmap)->height = height;
......@@ -1144,23 +1148,11 @@ GpStatus WINGDIPAPI GdipGetImagePixelFormat(GpImage *image, PixelFormat *format)
GpStatus WINGDIPAPI GdipGetImageRawFormat(GpImage *image, GUID *format)
{
static int calls;
if(!image || !format)
return InvalidParameter;
if(!(calls++))
FIXME("stub\n");
memcpy(format, &image->format, sizeof(GUID));
/* FIXME: should be detected from embedded picture or stored separately */
switch (image->type)
{
case ImageTypeBitmap: *format = ImageFormatBMP; break;
case ImageTypeMetafile: *format = ImageFormatEMF; break;
default:
WARN("unknown type %u\n", image->type);
*format = ImageFormatUndefined;
}
return Ok;
}
......@@ -1647,7 +1639,15 @@ GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream* stream, GpImage **image)
if (FAILED(hr)) return hresult_to_status(hr);
/* call on the image decoder to do the real work */
return codec->decode_func(stream, &codec->info.Clsid, image);
stat = codec->decode_func(stream, &codec->info.Clsid, image);
/* take note of the original data format */
if (stat == Ok)
{
memcpy(&(*image)->format, &codec->info.FormatID, sizeof(GUID));
}
return stat;
}
/* FIXME: no ICM */
......
......@@ -486,7 +486,7 @@ static void test_GdipCreateBitmapFromHBITMAP(void)
stat = GdipCreateBitmapFromHBITMAP(hbm, NULL, &gpbm);
expect(Ok, stat);
/* raw format */
expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)gpbm, __LINE__, TRUE);
expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)gpbm, __LINE__, FALSE);
expect(Ok, GdipGetImageDimension((GpImage*) gpbm, &width, &height));
expectf(WIDTH2, width);
......@@ -564,12 +564,12 @@ static void test_GdipCloneImage(void)
/* Create an image, clone it, delete the original, make sure the copy works */
stat = GdipCreateBitmapFromScan0(WIDTH, HEIGHT, 0, PixelFormat24bppRGB, NULL, &bm);
expect(Ok, stat);
expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bm, __LINE__, TRUE);
expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bm, __LINE__, FALSE);
image_src = ((GpImage*)bm);
stat = GdipCloneImage(image_src, &image_dest);
expect(Ok, stat);
expect_rawformat(&ImageFormatMemoryBMP, image_dest, __LINE__, TRUE);
expect_rawformat(&ImageFormatMemoryBMP, image_dest, __LINE__, FALSE);
stat = GdipDisposeImage((GpImage*)bm);
expect(Ok, stat);
......@@ -646,7 +646,7 @@ static void test_fromhicon(void)
stat = GdipGetImagePixelFormat((GpImage*)bitmap, &format);
expect(PixelFormat32bppARGB, format);
/* raw format */
expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bitmap, __LINE__, TRUE);
expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bitmap, __LINE__, FALSE);
GdipDisposeImage((GpImage*)bitmap);
}
DestroyIcon(hIcon);
......@@ -682,7 +682,7 @@ static void test_fromhicon(void)
stat = GdipGetImagePixelFormat((GpImage*)bitmap, &format);
expect(PixelFormat32bppARGB, format);
/* raw format */
expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bitmap, __LINE__, TRUE);
expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bitmap, __LINE__, FALSE);
GdipDisposeImage((GpImage*)bitmap);
}
DestroyIcon(hIcon);
......@@ -735,10 +735,10 @@ static const unsigned char jpgimage[285] = {
};
static void test_getrawformat(void)
{
test_bufferrawformat((void*)pngimage, sizeof(pngimage), &ImageFormatPNG, __LINE__, TRUE);
test_bufferrawformat((void*)gifimage, sizeof(gifimage), &ImageFormatGIF, __LINE__, TRUE);
test_bufferrawformat((void*)pngimage, sizeof(pngimage), &ImageFormatPNG, __LINE__, FALSE);
test_bufferrawformat((void*)gifimage, sizeof(gifimage), &ImageFormatGIF, __LINE__, FALSE);
test_bufferrawformat((void*)bmpimage, sizeof(bmpimage), &ImageFormatBMP, __LINE__, FALSE);
test_bufferrawformat((void*)jpgimage, sizeof(jpgimage), &ImageFormatJPEG, __LINE__, TRUE);
test_bufferrawformat((void*)jpgimage, sizeof(jpgimage), &ImageFormatJPEG, __LINE__, FALSE);
}
static void test_createhbitmap(void)
......
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