gdiplus: Implement GdipGetImageRawFormat.

This commit is contained in:
Vincent Povirk 2009-09-14 11:23:45 -05:00 committed by Alexandre Julliard
parent 160d7dfb91
commit 0595fc5e03
4 changed files with 24 additions and 22 deletions

View File

@ -208,6 +208,7 @@ struct GpAdustableArrowCap{
struct GpImage{ struct GpImage{
IPicture* picture; IPicture* picture;
ImageType type; ImageType type;
GUID format;
UINT flags; UINT flags;
}; };

View File

@ -1235,6 +1235,7 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete,
(*metafile)->image.type = ImageTypeMetafile; (*metafile)->image.type = ImageTypeMetafile;
memcpy(&(*metafile)->image.format, &ImageFormatWMF, sizeof(GUID));
(*metafile)->bounds.X = ((REAL) placeable->BoundingBox.Left) / ((REAL) placeable->Inch); (*metafile)->bounds.X = ((REAL) placeable->BoundingBox.Left) / ((REAL) placeable->Inch);
(*metafile)->bounds.Y = ((REAL) placeable->BoundingBox.Right) / ((REAL) placeable->Inch); (*metafile)->bounds.Y = ((REAL) placeable->BoundingBox.Right) / ((REAL) placeable->Inch);
(*metafile)->bounds.Width = ((REAL) (placeable->BoundingBox.Right (*metafile)->bounds.Width = ((REAL) (placeable->BoundingBox.Right

View File

@ -413,6 +413,9 @@ GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage)
GdipDisposeImage(*cloneImage); GdipDisposeImage(*cloneImage);
*cloneImage = NULL; *cloneImage = NULL;
} }
memcpy(&(*cloneImage)->format, &image->format, sizeof(GUID));
return stat; return stat;
} }
else else
@ -858,6 +861,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
} }
(*bitmap)->image.type = ImageTypeBitmap; (*bitmap)->image.type = ImageTypeBitmap;
memcpy(&(*bitmap)->image.format, &ImageFormatMemoryBMP, sizeof(GUID));
(*bitmap)->image.flags = ImageFlagsNone; (*bitmap)->image.flags = ImageFlagsNone;
(*bitmap)->width = width; (*bitmap)->width = width;
(*bitmap)->height = height; (*bitmap)->height = height;
@ -1144,23 +1148,11 @@ GpStatus WINGDIPAPI GdipGetImagePixelFormat(GpImage *image, PixelFormat *format)
GpStatus WINGDIPAPI GdipGetImageRawFormat(GpImage *image, GUID *format) GpStatus WINGDIPAPI GdipGetImageRawFormat(GpImage *image, GUID *format)
{ {
static int calls;
if(!image || !format) if(!image || !format)
return InvalidParameter; return InvalidParameter;
if(!(calls++)) memcpy(format, &image->format, sizeof(GUID));
FIXME("stub\n");
/* 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; return Ok;
} }
@ -1647,7 +1639,15 @@ GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream* stream, GpImage **image)
if (FAILED(hr)) return hresult_to_status(hr); if (FAILED(hr)) return hresult_to_status(hr);
/* call on the image decoder to do the real work */ /* 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 */ /* FIXME: no ICM */

View File

@ -486,7 +486,7 @@ static void test_GdipCreateBitmapFromHBITMAP(void)
stat = GdipCreateBitmapFromHBITMAP(hbm, NULL, &gpbm); stat = GdipCreateBitmapFromHBITMAP(hbm, NULL, &gpbm);
expect(Ok, stat); expect(Ok, stat);
/* raw format */ /* raw format */
expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)gpbm, __LINE__, TRUE); expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)gpbm, __LINE__, FALSE);
expect(Ok, GdipGetImageDimension((GpImage*) gpbm, &width, &height)); expect(Ok, GdipGetImageDimension((GpImage*) gpbm, &width, &height));
expectf(WIDTH2, width); 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 */ /* Create an image, clone it, delete the original, make sure the copy works */
stat = GdipCreateBitmapFromScan0(WIDTH, HEIGHT, 0, PixelFormat24bppRGB, NULL, &bm); stat = GdipCreateBitmapFromScan0(WIDTH, HEIGHT, 0, PixelFormat24bppRGB, NULL, &bm);
expect(Ok, stat); expect(Ok, stat);
expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bm, __LINE__, TRUE); expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bm, __LINE__, FALSE);
image_src = ((GpImage*)bm); image_src = ((GpImage*)bm);
stat = GdipCloneImage(image_src, &image_dest); stat = GdipCloneImage(image_src, &image_dest);
expect(Ok, stat); expect(Ok, stat);
expect_rawformat(&ImageFormatMemoryBMP, image_dest, __LINE__, TRUE); expect_rawformat(&ImageFormatMemoryBMP, image_dest, __LINE__, FALSE);
stat = GdipDisposeImage((GpImage*)bm); stat = GdipDisposeImage((GpImage*)bm);
expect(Ok, stat); expect(Ok, stat);
@ -646,7 +646,7 @@ static void test_fromhicon(void)
stat = GdipGetImagePixelFormat((GpImage*)bitmap, &format); stat = GdipGetImagePixelFormat((GpImage*)bitmap, &format);
expect(PixelFormat32bppARGB, format); expect(PixelFormat32bppARGB, format);
/* raw format */ /* raw format */
expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bitmap, __LINE__, TRUE); expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bitmap, __LINE__, FALSE);
GdipDisposeImage((GpImage*)bitmap); GdipDisposeImage((GpImage*)bitmap);
} }
DestroyIcon(hIcon); DestroyIcon(hIcon);
@ -682,7 +682,7 @@ static void test_fromhicon(void)
stat = GdipGetImagePixelFormat((GpImage*)bitmap, &format); stat = GdipGetImagePixelFormat((GpImage*)bitmap, &format);
expect(PixelFormat32bppARGB, format); expect(PixelFormat32bppARGB, format);
/* raw format */ /* raw format */
expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bitmap, __LINE__, TRUE); expect_rawformat(&ImageFormatMemoryBMP, (GpImage*)bitmap, __LINE__, FALSE);
GdipDisposeImage((GpImage*)bitmap); GdipDisposeImage((GpImage*)bitmap);
} }
DestroyIcon(hIcon); DestroyIcon(hIcon);
@ -735,10 +735,10 @@ static const unsigned char jpgimage[285] = {
}; };
static void test_getrawformat(void) static void test_getrawformat(void)
{ {
test_bufferrawformat((void*)pngimage, sizeof(pngimage), &ImageFormatPNG, __LINE__, TRUE); test_bufferrawformat((void*)pngimage, sizeof(pngimage), &ImageFormatPNG, __LINE__, FALSE);
test_bufferrawformat((void*)gifimage, sizeof(gifimage), &ImageFormatGIF, __LINE__, TRUE); test_bufferrawformat((void*)gifimage, sizeof(gifimage), &ImageFormatGIF, __LINE__, FALSE);
test_bufferrawformat((void*)bmpimage, sizeof(bmpimage), &ImageFormatBMP, __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) static void test_createhbitmap(void)