2 * Copyright (C) 2007 Google (Evan Stade)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define NONAMELESSUNION
36 #include "gdiplus_private.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus
);
41 #define PIXELFORMATBPP(x) ((x) ? ((x) >> 8) & 255 : 24)
43 static INT
ipicture_pixel_height(IPicture
*pic
)
48 IPicture_get_Height(pic
, &y
);
52 y
= MulDiv(y
, GetDeviceCaps(hdcref
, LOGPIXELSY
), INCH_HIMETRIC
);
58 static INT
ipicture_pixel_width(IPicture
*pic
)
63 IPicture_get_Width(pic
, &x
);
67 x
= MulDiv(x
, GetDeviceCaps(hdcref
, LOGPIXELSX
), INCH_HIMETRIC
);
74 GpStatus WINGDIPAPI
GdipBitmapApplyEffect(GpBitmap
* bitmap
, CGpEffect
* effect
,
75 RECT
* roi
, BOOL useAuxData
, VOID
** auxData
, INT
* auxDataSize
)
77 FIXME("(%p %p %p %d %p %p): stub\n", bitmap
, effect
, roi
, useAuxData
, auxData
, auxDataSize
);
79 * Note: According to Jose Roca's GDI+ docs, this function is not
80 * implemented in Windows's GDI+.
82 return NotImplemented
;
85 GpStatus WINGDIPAPI
GdipBitmapCreateApplyEffect(GpBitmap
** inputBitmaps
,
86 INT numInputs
, CGpEffect
* effect
, RECT
* roi
, RECT
* outputRect
,
87 GpBitmap
** outputBitmap
, BOOL useAuxData
, VOID
** auxData
, INT
* auxDataSize
)
89 FIXME("(%p %d %p %p %p %p %d %p %p): stub\n", inputBitmaps
, numInputs
, effect
, roi
, outputRect
, outputBitmap
, useAuxData
, auxData
, auxDataSize
);
91 * Note: According to Jose Roca's GDI+ docs, this function is not
92 * implemented in Windows's GDI+.
94 return NotImplemented
;
97 GpStatus WINGDIPAPI
GdipBitmapGetPixel(GpBitmap
* bitmap
, INT x
, INT y
,
101 TRACE("%p %d %d %p\n", bitmap
, x
, y
, color
);
103 if(!bitmap
|| !color
)
104 return InvalidParameter
;
107 FIXME("not implemented\n");
111 return NotImplemented
;
114 GpStatus WINGDIPAPI
GdipBitmapSetPixel(GpBitmap
* bitmap
, INT x
, INT y
,
118 TRACE("bitmap:%p, x:%d, y:%d, color:%08x\n", bitmap
, x
, y
, color
);
121 return InvalidParameter
;
124 FIXME("not implemented\n");
126 return NotImplemented
;
129 /* This function returns a pointer to an array of pixels that represents the
130 * bitmap. The *entire* bitmap is locked according to the lock mode specified by
131 * flags. It is correct behavior that a user who calls this function with write
132 * privileges can write to the whole bitmap (not just the area in rect).
134 * FIXME: only used portion of format is bits per pixel. */
135 GpStatus WINGDIPAPI
GdipBitmapLockBits(GpBitmap
* bitmap
, GDIPCONST GpRect
* rect
,
136 UINT flags
, PixelFormat format
, BitmapData
* lockeddata
)
139 INT stride
, bitspp
= PIXELFORMATBPP(format
);
141 HBITMAP hbm
, old
= NULL
;
145 GpRect act_rect
; /* actual rect to be used */
147 TRACE("%p %p %d %d %p\n", bitmap
, rect
, flags
, format
, lockeddata
);
149 if(!lockeddata
|| !bitmap
)
150 return InvalidParameter
;
153 if(rect
->X
< 0 || rect
->Y
< 0 || (rect
->X
+ rect
->Width
> bitmap
->width
) ||
154 (rect
->Y
+ rect
->Height
> bitmap
->height
) || !flags
)
155 return InvalidParameter
;
160 act_rect
.X
= act_rect
.Y
= 0;
161 act_rect
.Width
= bitmap
->width
;
162 act_rect
.Height
= bitmap
->height
;
165 if(flags
& ImageLockModeUserInputBuf
)
166 return NotImplemented
;
171 if (bitmap
->bits
&& bitmap
->format
== format
)
173 /* no conversion is necessary; just use the bits directly */
174 lockeddata
->Width
= act_rect
.Width
;
175 lockeddata
->Height
= act_rect
.Height
;
176 lockeddata
->PixelFormat
= format
;
177 lockeddata
->Reserved
= flags
;
178 lockeddata
->Stride
= bitmap
->stride
;
179 lockeddata
->Scan0
= bitmap
->bits
+ (bitspp
/ 8) * act_rect
.X
+
180 bitmap
->stride
* act_rect
.Y
;
182 bitmap
->lockmode
= flags
;
188 hbm
= bitmap
->hbitmap
;
190 bm_is_selected
= (hdc
!= 0);
192 pbmi
= GdipAlloc(sizeof(BITMAPINFOHEADER
) + 256 * sizeof(RGBQUAD
));
195 pbmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
196 pbmi
->bmiHeader
.biBitCount
= 0;
199 hdc
= CreateCompatibleDC(0);
200 old
= SelectObject(hdc
, hbm
);
204 GetDIBits(hdc
, hbm
, 0, 0, NULL
, pbmi
, DIB_RGB_COLORS
);
206 abs_height
= abs(pbmi
->bmiHeader
.biHeight
);
207 stride
= pbmi
->bmiHeader
.biWidth
* bitspp
/ 8;
208 stride
= (stride
+ 3) & ~3;
210 buff
= GdipAlloc(stride
* abs_height
);
212 pbmi
->bmiHeader
.biBitCount
= bitspp
;
215 GetDIBits(hdc
, hbm
, 0, abs_height
, buff
, pbmi
, DIB_RGB_COLORS
);
218 SelectObject(hdc
, old
);
227 lockeddata
->Width
= act_rect
.Width
;
228 lockeddata
->Height
= act_rect
.Height
;
229 lockeddata
->PixelFormat
= format
;
230 lockeddata
->Reserved
= flags
;
232 if(pbmi
->bmiHeader
.biHeight
> 0){
233 lockeddata
->Stride
= -stride
;
234 lockeddata
->Scan0
= buff
+ (bitspp
/ 8) * act_rect
.X
+
235 stride
* (abs_height
- 1 - act_rect
.Y
);
238 lockeddata
->Stride
= stride
;
239 lockeddata
->Scan0
= buff
+ (bitspp
/ 8) * act_rect
.X
+ stride
* act_rect
.Y
;
242 bitmap
->lockmode
= flags
;
245 bitmap
->bitmapbits
= buff
;
251 GpStatus WINGDIPAPI
GdipBitmapSetResolution(GpBitmap
* bitmap
, REAL xdpi
, REAL ydpi
)
253 FIXME("(%p, %.2f, %.2f)\n", bitmap
, xdpi
, ydpi
);
255 return NotImplemented
;
258 GpStatus WINGDIPAPI
GdipBitmapUnlockBits(GpBitmap
* bitmap
,
259 BitmapData
* lockeddata
)
262 HBITMAP hbm
, old
= NULL
;
266 if(!bitmap
|| !lockeddata
)
267 return InvalidParameter
;
269 if(!bitmap
->lockmode
)
272 if(lockeddata
->Reserved
& ImageLockModeUserInputBuf
)
273 return NotImplemented
;
275 if(lockeddata
->Reserved
& ImageLockModeRead
){
276 if(!(--bitmap
->numlocks
))
277 bitmap
->lockmode
= 0;
279 GdipFree(bitmap
->bitmapbits
);
280 bitmap
->bitmapbits
= NULL
;
284 if (!bitmap
->bitmapbits
)
286 /* we passed a direct reference; no need to do anything */
287 bitmap
->lockmode
= 0;
291 hbm
= bitmap
->hbitmap
;
293 bm_is_selected
= (hdc
!= 0);
295 pbmi
= GdipAlloc(sizeof(BITMAPINFOHEADER
) + 256 * sizeof(RGBQUAD
));
296 pbmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
297 pbmi
->bmiHeader
.biBitCount
= 0;
300 hdc
= CreateCompatibleDC(0);
301 old
= SelectObject(hdc
, hbm
);
304 GetDIBits(hdc
, hbm
, 0, 0, NULL
, pbmi
, DIB_RGB_COLORS
);
305 pbmi
->bmiHeader
.biBitCount
= PIXELFORMATBPP(lockeddata
->PixelFormat
);
306 SetDIBits(hdc
, hbm
, 0, abs(pbmi
->bmiHeader
.biHeight
),
307 bitmap
->bitmapbits
, pbmi
, DIB_RGB_COLORS
);
310 SelectObject(hdc
, old
);
315 GdipFree(bitmap
->bitmapbits
);
316 bitmap
->bitmapbits
= NULL
;
317 bitmap
->lockmode
= 0;
322 GpStatus WINGDIPAPI
GdipCloneBitmapArea(REAL x
, REAL y
, REAL width
, REAL height
,
323 PixelFormat format
, GpBitmap
* srcBitmap
, GpBitmap
** dstBitmap
)
325 FIXME("(%f,%f,%f,%f,%i,%p,%p): stub\n", x
, y
, width
, height
, format
, srcBitmap
, dstBitmap
);
327 return NotImplemented
;
330 GpStatus WINGDIPAPI
GdipCloneBitmapAreaI(INT x
, INT y
, INT width
, INT height
,
331 PixelFormat format
, GpBitmap
* srcBitmap
, GpBitmap
** dstBitmap
)
333 FIXME("(%i,%i,%i,%i,%i,%p,%p): stub\n", x
, y
, width
, height
, format
, srcBitmap
, dstBitmap
);
335 return NotImplemented
;
338 GpStatus WINGDIPAPI
GdipCloneImage(GpImage
*image
, GpImage
**cloneImage
)
340 GpStatus stat
= GenericError
;
342 TRACE("%p, %p\n", image
, cloneImage
);
344 if (!image
|| !cloneImage
)
345 return InvalidParameter
;
354 hr
= CreateStreamOnHGlobal(0, TRUE
, &stream
);
358 hr
= IPicture_SaveAsFile(image
->picture
, stream
, FALSE
, &size
);
361 WARN("Failed to save image on stream\n");
365 /* Set seek pointer back to the beginning of the picture */
367 hr
= IStream_Seek(stream
, move
, STREAM_SEEK_SET
, NULL
);
371 stat
= GdipLoadImageFromStream(stream
, cloneImage
);
372 if (stat
!= Ok
) WARN("Failed to load image from stream\n");
375 IStream_Release(stream
);
378 else if (image
->type
== ImageTypeBitmap
)
380 GpBitmap
*bitmap
= (GpBitmap
*)image
;
381 BitmapData lockeddata_src
, lockeddata_dst
;
385 stat
= GdipBitmapLockBits(bitmap
, NULL
, ImageLockModeRead
, bitmap
->format
,
387 if (stat
!= Ok
) return stat
;
389 stat
= GdipCreateBitmapFromScan0(lockeddata_src
.Width
, lockeddata_src
.Height
,
390 0, lockeddata_src
.PixelFormat
, NULL
, (GpBitmap
**)cloneImage
);
393 stat
= GdipBitmapLockBits((GpBitmap
*)*cloneImage
, NULL
, ImageLockModeWrite
,
394 lockeddata_src
.PixelFormat
, &lockeddata_dst
);
398 /* copy the image data */
399 row_size
= (lockeddata_src
.Width
* PIXELFORMATBPP(lockeddata_src
.PixelFormat
) +7)/8;
400 for (i
=0; i
<lockeddata_src
.Height
; i
++)
401 memcpy((BYTE
*)lockeddata_dst
.Scan0
+lockeddata_dst
.Stride
*i
,
402 (BYTE
*)lockeddata_src
.Scan0
+lockeddata_src
.Stride
*i
,
405 GdipBitmapUnlockBits((GpBitmap
*)*cloneImage
, &lockeddata_dst
);
408 GdipBitmapUnlockBits(bitmap
, &lockeddata_src
);
413 GdipDisposeImage(*cloneImage
);
420 ERR("GpImage with no IPicture or bitmap?!\n");
421 return NotImplemented
;
425 GpStatus WINGDIPAPI
GdipCreateBitmapFromFile(GDIPCONST WCHAR
* filename
,
431 TRACE("(%s) %p\n", debugstr_w(filename
), bitmap
);
433 if(!filename
|| !bitmap
)
434 return InvalidParameter
;
436 stat
= GdipCreateStreamOnFile(filename
, GENERIC_READ
, &stream
);
441 stat
= GdipCreateBitmapFromStream(stream
, bitmap
);
443 IStream_Release(stream
);
448 GpStatus WINGDIPAPI
GdipCreateBitmapFromGdiDib(GDIPCONST BITMAPINFO
* info
,
449 VOID
*bits
, GpBitmap
**bitmap
)
451 DWORD height
, stride
;
454 FIXME("(%p, %p, %p) - partially implemented\n", info
, bits
, bitmap
);
456 height
= abs(info
->bmiHeader
.biHeight
);
457 stride
= ((info
->bmiHeader
.biWidth
* info
->bmiHeader
.biBitCount
+ 31) >> 3) & ~3;
459 if(info
->bmiHeader
.biHeight
> 0) /* bottom-up */
461 bits
= (BYTE
*)bits
+ (height
- 1) * stride
;
465 switch(info
->bmiHeader
.biBitCount
) {
467 format
= PixelFormat1bppIndexed
;
470 format
= PixelFormat4bppIndexed
;
473 format
= PixelFormat8bppIndexed
;
476 format
= PixelFormat24bppRGB
;
479 FIXME("don't know how to handle %d bpp\n", info
->bmiHeader
.biBitCount
);
481 return InvalidParameter
;
484 return GdipCreateBitmapFromScan0(info
->bmiHeader
.biWidth
, height
, stride
, format
,
490 GpStatus WINGDIPAPI
GdipCreateBitmapFromFileICM(GDIPCONST WCHAR
* filename
,
493 TRACE("(%s) %p\n", debugstr_w(filename
), bitmap
);
495 return GdipCreateBitmapFromFile(filename
, bitmap
);
498 GpStatus WINGDIPAPI
GdipCreateBitmapFromResource(HINSTANCE hInstance
,
499 GDIPCONST WCHAR
* lpBitmapName
, GpBitmap
** bitmap
)
502 GpStatus stat
= InvalidParameter
;
504 TRACE("%p (%s) %p\n", hInstance
, debugstr_w(lpBitmapName
), bitmap
);
506 if(!lpBitmapName
|| !bitmap
)
507 return InvalidParameter
;
510 hbm
= LoadImageW(hInstance
, lpBitmapName
, IMAGE_BITMAP
, 0, 0,
511 LR_CREATEDIBSECTION
);
514 stat
= GdipCreateBitmapFromHBITMAP(hbm
, NULL
, bitmap
);
521 GpStatus WINGDIPAPI
GdipCreateHBITMAPFromBitmap(GpBitmap
* bitmap
,
522 HBITMAP
* hbmReturn
, ARGB background
)
525 HBITMAP result
, oldbitmap
;
528 GpGraphics
*graphics
;
529 BITMAPINFOHEADER bih
;
531 TRACE("(%p,%p,%x)\n", bitmap
, hbmReturn
, background
);
533 if (!bitmap
|| !hbmReturn
) return InvalidParameter
;
535 GdipGetImageWidth((GpImage
*)bitmap
, &width
);
536 GdipGetImageHeight((GpImage
*)bitmap
, &height
);
538 bih
.biSize
= sizeof(bih
);
540 bih
.biHeight
= height
;
543 bih
.biCompression
= BI_RGB
;
545 bih
.biXPelsPerMeter
= 0;
546 bih
.biYPelsPerMeter
= 0;
548 bih
.biClrImportant
= 0;
550 hdc
= CreateCompatibleDC(NULL
);
551 if (!hdc
) return GenericError
;
553 result
= CreateDIBSection(hdc
, (BITMAPINFO
*)&bih
, DIB_RGB_COLORS
, &bits
,
558 oldbitmap
= SelectObject(hdc
, result
);
560 stat
= GdipCreateFromHDC(hdc
, &graphics
);
563 stat
= GdipGraphicsClear(graphics
, background
);
566 stat
= GdipDrawImage(graphics
, (GpImage
*)bitmap
, 0, 0);
568 GdipDeleteGraphics(graphics
);
571 SelectObject(hdc
, oldbitmap
);
578 if (stat
!= Ok
&& result
)
580 DeleteObject(result
);
589 GpStatus WINGDIPAPI
GdipConvertToEmfPlus(const GpGraphics
* ref
,
590 GpMetafile
* metafile
, BOOL
* succ
, EmfType emfType
,
591 const WCHAR
* description
, GpMetafile
** out_metafile
)
595 if(!ref
|| !metafile
|| !out_metafile
)
596 return InvalidParameter
;
599 *out_metafile
= NULL
;
602 FIXME("not implemented\n");
604 return NotImplemented
;
607 /* FIXME: this should create a bitmap in the given size with the attributes
608 * (resolution etc.) of the graphics object */
609 GpStatus WINGDIPAPI
GdipCreateBitmapFromGraphics(INT width
, INT height
,
610 GpGraphics
* target
, GpBitmap
** bitmap
)
615 if(!target
|| !bitmap
)
616 return InvalidParameter
;
619 FIXME("hacked stub\n");
621 ret
= GdipCreateBitmapFromScan0(width
, height
, 0, PixelFormat24bppRGB
,
627 GpStatus WINGDIPAPI
GdipCreateBitmapFromHICON(HICON hicon
, GpBitmap
** bitmap
)
635 BitmapData lockeddata
;
640 BITMAPINFOHEADER bih
;
645 TRACE("%p, %p\n", hicon
, bitmap
);
647 if(!bitmap
|| !GetIconInfo(hicon
, &iinfo
))
649 DeleteObject(iinfo
.hbmColor
);
650 DeleteObject(iinfo
.hbmMask
);
651 return InvalidParameter
;
654 /* get the size of the icon */
655 ret
= GetObjectA(iinfo
.hbmColor
? iinfo
.hbmColor
: iinfo
.hbmMask
, sizeof(bm
), &bm
);
657 DeleteObject(iinfo
.hbmColor
);
658 DeleteObject(iinfo
.hbmMask
);
665 height
= abs(bm
.bmHeight
);
666 else /* combined bitmap + mask */
667 height
= abs(bm
.bmHeight
) / 2;
669 bits
= HeapAlloc(GetProcessHeap(), 0, 4*width
*height
);
671 DeleteObject(iinfo
.hbmColor
);
672 DeleteObject(iinfo
.hbmMask
);
676 stat
= GdipCreateBitmapFromScan0(width
, height
, 0, PixelFormat32bppARGB
, NULL
, bitmap
);
678 DeleteObject(iinfo
.hbmColor
);
679 DeleteObject(iinfo
.hbmMask
);
680 HeapFree(GetProcessHeap(), 0, bits
);
687 rect
.Height
= height
;
689 stat
= GdipBitmapLockBits(*bitmap
, &rect
, ImageLockModeWrite
, PixelFormat32bppARGB
, &lockeddata
);
691 DeleteObject(iinfo
.hbmColor
);
692 DeleteObject(iinfo
.hbmMask
);
693 HeapFree(GetProcessHeap(), 0, bits
);
694 GdipDisposeImage((GpImage
*)*bitmap
);
698 bih
.biSize
= sizeof(bih
);
700 bih
.biHeight
= -height
;
703 bih
.biCompression
= BI_RGB
;
705 bih
.biXPelsPerMeter
= 0;
706 bih
.biYPelsPerMeter
= 0;
708 bih
.biClrImportant
= 0;
713 GetDIBits(screendc
, iinfo
.hbmColor
, 0, height
, bits
, (BITMAPINFO
*)&bih
, DIB_RGB_COLORS
);
715 if (bm
.bmBitsPixel
== 32)
719 /* If any pixel has a non-zero alpha, ignore hbmMask */
721 for (x
=0; x
<width
&& !has_alpha
; x
++)
722 for (y
=0; y
<height
&& !has_alpha
; y
++)
723 if ((*src
++ & 0xff000000) != 0)
726 else has_alpha
= FALSE
;
730 GetDIBits(screendc
, iinfo
.hbmMask
, 0, height
, bits
, (BITMAPINFO
*)&bih
, DIB_RGB_COLORS
);
734 /* copy the image data to the Bitmap */
736 dst_row
= lockeddata
.Scan0
;
737 for (y
=0; y
<height
; y
++)
739 memcpy(dst_row
, src
, width
*4);
741 dst_row
+= lockeddata
.Stride
;
748 /* read alpha data from the mask */
750 GetDIBits(screendc
, iinfo
.hbmMask
, 0, height
, bits
, (BITMAPINFO
*)&bih
, DIB_RGB_COLORS
);
752 GetDIBits(screendc
, iinfo
.hbmMask
, height
, height
, bits
, (BITMAPINFO
*)&bih
, DIB_RGB_COLORS
);
755 dst_row
= lockeddata
.Scan0
;
756 for (y
=0; y
<height
; y
++)
758 dst
= (DWORD
*)dst_row
;
759 for (x
=0; x
<height
; x
++)
761 DWORD src_value
= *src
++;
765 *dst
++ |= 0xff000000;
767 dst_row
+= lockeddata
.Stride
;
772 /* set constant alpha of 255 */
774 for (y
=0; y
<height
; y
++)
776 dst
= (DWORD
*)dst_row
;
777 for (x
=0; x
<height
; x
++)
778 *dst
++ |= 0xff000000;
779 dst_row
+= lockeddata
.Stride
;
784 ReleaseDC(0, screendc
);
786 DeleteObject(iinfo
.hbmColor
);
787 DeleteObject(iinfo
.hbmMask
);
789 GdipBitmapUnlockBits(*bitmap
, &lockeddata
);
791 HeapFree(GetProcessHeap(), 0, bits
);
796 GpStatus WINGDIPAPI
GdipCreateBitmapFromScan0(INT width
, INT height
, INT stride
,
797 PixelFormat format
, BYTE
* scan0
, GpBitmap
** bitmap
)
799 BITMAPINFOHEADER bmih
;
801 INT row_size
, dib_stride
;
806 TRACE("%d %d %d %d %p %p\n", width
, height
, stride
, format
, scan0
, bitmap
);
808 if (!bitmap
) return InvalidParameter
;
810 if(width
<= 0 || height
<= 0 || (scan0
&& (stride
% 4))){
812 return InvalidParameter
;
816 return InvalidParameter
;
818 row_size
= (width
* PIXELFORMATBPP(format
)+7) / 8;
819 dib_stride
= (row_size
+ 3) & ~3;
824 bmih
.biSize
= sizeof(BITMAPINFOHEADER
);
825 bmih
.biWidth
= width
;
826 bmih
.biHeight
= -height
;
828 /* FIXME: use the rest of the data from format */
829 bmih
.biBitCount
= PIXELFORMATBPP(format
);
830 bmih
.biCompression
= BI_RGB
;
831 bmih
.biSizeImage
= 0;
832 bmih
.biXPelsPerMeter
= 0;
833 bmih
.biYPelsPerMeter
= 0;
835 bmih
.biClrImportant
= 0;
837 hdc
= CreateCompatibleDC(NULL
);
838 if (!hdc
) return GenericError
;
840 hbitmap
= CreateDIBSection(hdc
, (BITMAPINFO
*)&bmih
, DIB_RGB_COLORS
, (void**)&bits
,
845 if (!hbitmap
) return GenericError
;
847 /* copy bits to the dib if necessary */
848 /* FIXME: should reference the bits instead of copying them */
850 for (i
=0; i
<height
; i
++)
851 memcpy(bits
+i
*dib_stride
, scan0
+i
*stride
, row_size
);
853 *bitmap
= GdipAlloc(sizeof(GpBitmap
));
856 DeleteObject(hbitmap
);
860 (*bitmap
)->image
.type
= ImageTypeBitmap
;
861 (*bitmap
)->image
.flags
= ImageFlagsNone
;
862 (*bitmap
)->width
= width
;
863 (*bitmap
)->height
= height
;
864 (*bitmap
)->format
= format
;
865 (*bitmap
)->image
.picture
= NULL
;
866 (*bitmap
)->hbitmap
= hbitmap
;
867 (*bitmap
)->hdc
= NULL
;
868 (*bitmap
)->bits
= bits
;
869 (*bitmap
)->stride
= dib_stride
;
874 GpStatus WINGDIPAPI
GdipCreateBitmapFromStream(IStream
* stream
,
879 TRACE("%p %p\n", stream
, bitmap
);
881 stat
= GdipLoadImageFromStream(stream
, (GpImage
**) bitmap
);
886 if((*bitmap
)->image
.type
!= ImageTypeBitmap
){
887 GdipDisposeImage(&(*bitmap
)->image
);
889 return GenericError
; /* FIXME: what error to return? */
896 GpStatus WINGDIPAPI
GdipCreateBitmapFromStreamICM(IStream
* stream
,
899 TRACE("%p %p\n", stream
, bitmap
);
901 return GdipCreateBitmapFromStream(stream
, bitmap
);
904 GpStatus WINGDIPAPI
GdipCreateCachedBitmap(GpBitmap
*bitmap
, GpGraphics
*graphics
,
905 GpCachedBitmap
**cachedbmp
)
909 TRACE("%p %p %p\n", bitmap
, graphics
, cachedbmp
);
911 if(!bitmap
|| !graphics
|| !cachedbmp
)
912 return InvalidParameter
;
914 *cachedbmp
= GdipAlloc(sizeof(GpCachedBitmap
));
918 stat
= GdipCloneImage(&(bitmap
->image
), &(*cachedbmp
)->image
);
920 GdipFree(*cachedbmp
);
927 GpStatus WINGDIPAPI
GdipCreateHICONFromBitmap(GpBitmap
*bitmap
, HICON
*hicon
)
929 FIXME("(%p, %p)\n", bitmap
, hicon
);
931 return NotImplemented
;
934 GpStatus WINGDIPAPI
GdipDeleteCachedBitmap(GpCachedBitmap
*cachedbmp
)
936 TRACE("%p\n", cachedbmp
);
939 return InvalidParameter
;
941 GdipDisposeImage(cachedbmp
->image
);
947 GpStatus WINGDIPAPI
GdipDrawCachedBitmap(GpGraphics
*graphics
,
948 GpCachedBitmap
*cachedbmp
, INT x
, INT y
)
950 TRACE("%p %p %d %d\n", graphics
, cachedbmp
, x
, y
);
952 if(!graphics
|| !cachedbmp
)
953 return InvalidParameter
;
955 return GdipDrawImage(graphics
, cachedbmp
->image
, (REAL
)x
, (REAL
)y
);
958 GpStatus WINGDIPAPI
GdipEmfToWmfBits(HENHMETAFILE hemf
, UINT cbData16
,
959 LPBYTE pData16
, INT iMapMode
, INT eFlags
)
961 FIXME("(%p, %d, %p, %d, %d): stub\n", hemf
, cbData16
, pData16
, iMapMode
, eFlags
);
962 return NotImplemented
;
965 GpStatus WINGDIPAPI
GdipDisposeImage(GpImage
*image
)
967 TRACE("%p\n", image
);
970 return InvalidParameter
;
973 IPicture_Release(image
->picture
);
974 if (image
->type
== ImageTypeBitmap
)
976 GdipFree(((GpBitmap
*)image
)->bitmapbits
);
977 DeleteDC(((GpBitmap
*)image
)->hdc
);
984 GpStatus WINGDIPAPI
GdipFindFirstImageItem(GpImage
*image
, ImageItemData
* item
)
987 return InvalidParameter
;
989 return NotImplemented
;
992 GpStatus WINGDIPAPI
GdipGetImageBounds(GpImage
*image
, GpRectF
*srcRect
,
995 TRACE("%p %p %p\n", image
, srcRect
, srcUnit
);
997 if(!image
|| !srcRect
|| !srcUnit
)
998 return InvalidParameter
;
999 if(image
->type
== ImageTypeMetafile
){
1000 *srcRect
= ((GpMetafile
*)image
)->bounds
;
1001 *srcUnit
= ((GpMetafile
*)image
)->unit
;
1003 else if(image
->type
== ImageTypeBitmap
){
1004 srcRect
->X
= srcRect
->Y
= 0.0;
1005 srcRect
->Width
= (REAL
) ((GpBitmap
*)image
)->width
;
1006 srcRect
->Height
= (REAL
) ((GpBitmap
*)image
)->height
;
1007 *srcUnit
= UnitPixel
;
1010 srcRect
->X
= srcRect
->Y
= 0.0;
1011 srcRect
->Width
= ipicture_pixel_width(image
->picture
);
1012 srcRect
->Height
= ipicture_pixel_height(image
->picture
);
1013 *srcUnit
= UnitPixel
;
1016 TRACE("returning (%f, %f) (%f, %f) unit type %d\n", srcRect
->X
, srcRect
->Y
,
1017 srcRect
->Width
, srcRect
->Height
, *srcUnit
);
1022 GpStatus WINGDIPAPI
GdipGetImageDimension(GpImage
*image
, REAL
*width
,
1025 TRACE("%p %p %p\n", image
, width
, height
);
1027 if(!image
|| !height
|| !width
)
1028 return InvalidParameter
;
1030 if(image
->type
== ImageTypeMetafile
){
1033 *height
= convert_unit(hdc
, ((GpMetafile
*)image
)->unit
) *
1034 ((GpMetafile
*)image
)->bounds
.Height
;
1036 *width
= convert_unit(hdc
, ((GpMetafile
*)image
)->unit
) *
1037 ((GpMetafile
*)image
)->bounds
.Width
;
1042 else if(image
->type
== ImageTypeBitmap
){
1043 *height
= ((GpBitmap
*)image
)->height
;
1044 *width
= ((GpBitmap
*)image
)->width
;
1047 *height
= ipicture_pixel_height(image
->picture
);
1048 *width
= ipicture_pixel_width(image
->picture
);
1051 TRACE("returning (%f, %f)\n", *height
, *width
);
1055 GpStatus WINGDIPAPI
GdipGetImageGraphicsContext(GpImage
*image
,
1056 GpGraphics
**graphics
)
1060 TRACE("%p %p\n", image
, graphics
);
1062 if(!image
|| !graphics
)
1063 return InvalidParameter
;
1065 if(image
->type
!= ImageTypeBitmap
){
1066 FIXME("not implemented for image type %d\n", image
->type
);
1067 return NotImplemented
;
1070 hdc
= ((GpBitmap
*)image
)->hdc
;
1073 hdc
= CreateCompatibleDC(0);
1074 SelectObject(hdc
, ((GpBitmap
*)image
)->hbitmap
);
1075 ((GpBitmap
*)image
)->hdc
= hdc
;
1078 return GdipCreateFromHDC(hdc
, graphics
);
1081 GpStatus WINGDIPAPI
GdipGetImageHeight(GpImage
*image
, UINT
*height
)
1083 TRACE("%p %p\n", image
, height
);
1085 if(!image
|| !height
)
1086 return InvalidParameter
;
1088 if(image
->type
== ImageTypeMetafile
){
1091 *height
= roundr(convert_unit(hdc
, ((GpMetafile
*)image
)->unit
) *
1092 ((GpMetafile
*)image
)->bounds
.Height
);
1096 else if(image
->type
== ImageTypeBitmap
)
1097 *height
= ((GpBitmap
*)image
)->height
;
1099 *height
= ipicture_pixel_height(image
->picture
);
1101 TRACE("returning %d\n", *height
);
1106 GpStatus WINGDIPAPI
GdipGetImageHorizontalResolution(GpImage
*image
, REAL
*res
)
1111 return InvalidParameter
;
1114 FIXME("not implemented\n");
1116 return NotImplemented
;
1119 GpStatus WINGDIPAPI
GdipGetImagePaletteSize(GpImage
*image
, INT
*size
)
1121 FIXME("%p %p\n", image
, size
);
1124 return InvalidParameter
;
1126 return NotImplemented
;
1129 /* FIXME: test this function for non-bitmap types */
1130 GpStatus WINGDIPAPI
GdipGetImagePixelFormat(GpImage
*image
, PixelFormat
*format
)
1132 TRACE("%p %p\n", image
, format
);
1134 if(!image
|| !format
)
1135 return InvalidParameter
;
1137 if(image
->type
!= ImageTypeBitmap
)
1138 *format
= PixelFormat24bppRGB
;
1140 *format
= ((GpBitmap
*) image
)->format
;
1145 GpStatus WINGDIPAPI
GdipGetImageRawFormat(GpImage
*image
, GUID
*format
)
1149 if(!image
|| !format
)
1150 return InvalidParameter
;
1155 /* FIXME: should be detected from embedded picture or stored separately */
1156 switch (image
->type
)
1158 case ImageTypeBitmap
: *format
= ImageFormatBMP
; break;
1159 case ImageTypeMetafile
: *format
= ImageFormatEMF
; break;
1161 WARN("unknown type %u\n", image
->type
);
1162 *format
= ImageFormatUndefined
;
1167 GpStatus WINGDIPAPI
GdipGetImageType(GpImage
*image
, ImageType
*type
)
1169 TRACE("%p %p\n", image
, type
);
1172 return InvalidParameter
;
1174 *type
= image
->type
;
1179 GpStatus WINGDIPAPI
GdipGetImageVerticalResolution(GpImage
*image
, REAL
*res
)
1184 return InvalidParameter
;
1187 FIXME("not implemented\n");
1189 return NotImplemented
;
1192 GpStatus WINGDIPAPI
GdipGetImageWidth(GpImage
*image
, UINT
*width
)
1194 TRACE("%p %p\n", image
, width
);
1196 if(!image
|| !width
)
1197 return InvalidParameter
;
1199 if(image
->type
== ImageTypeMetafile
){
1202 *width
= roundr(convert_unit(hdc
, ((GpMetafile
*)image
)->unit
) *
1203 ((GpMetafile
*)image
)->bounds
.Width
);
1207 else if(image
->type
== ImageTypeBitmap
)
1208 *width
= ((GpBitmap
*)image
)->width
;
1210 *width
= ipicture_pixel_width(image
->picture
);
1212 TRACE("returning %d\n", *width
);
1217 GpStatus WINGDIPAPI
GdipGetMetafileHeaderFromMetafile(GpMetafile
* metafile
,
1218 MetafileHeader
* header
)
1222 if(!metafile
|| !header
)
1223 return InvalidParameter
;
1226 FIXME("not implemented\n");
1231 GpStatus WINGDIPAPI
GdipGetAllPropertyItems(GpImage
*image
, UINT size
,
1232 UINT num
, PropertyItem
* items
)
1237 FIXME("not implemented\n");
1239 return InvalidParameter
;
1242 GpStatus WINGDIPAPI
GdipGetPropertyCount(GpImage
*image
, UINT
* num
)
1247 FIXME("not implemented\n");
1249 return InvalidParameter
;
1252 GpStatus WINGDIPAPI
GdipGetPropertyIdList(GpImage
*image
, UINT num
, PROPID
* list
)
1257 FIXME("not implemented\n");
1259 return InvalidParameter
;
1262 GpStatus WINGDIPAPI
GdipGetPropertyItem(GpImage
*image
, PROPID id
, UINT size
,
1263 PropertyItem
* buffer
)
1268 FIXME("not implemented\n");
1270 return InvalidParameter
;
1273 GpStatus WINGDIPAPI
GdipGetPropertyItemSize(GpImage
*image
, PROPID pid
,
1278 TRACE("%p %x %p\n", image
, pid
, size
);
1281 return InvalidParameter
;
1284 FIXME("not implemented\n");
1286 return NotImplemented
;
1289 GpStatus WINGDIPAPI
GdipGetPropertySize(GpImage
*image
, UINT
* size
, UINT
* num
)
1294 FIXME("not implemented\n");
1296 return InvalidParameter
;
1299 GpStatus WINGDIPAPI
GdipImageGetFrameCount(GpImage
*image
,
1300 GDIPCONST GUID
* dimensionID
, UINT
* count
)
1304 if(!image
|| !dimensionID
|| !count
)
1305 return InvalidParameter
;
1308 FIXME("not implemented\n");
1310 return NotImplemented
;
1313 GpStatus WINGDIPAPI
GdipImageGetFrameDimensionsCount(GpImage
*image
,
1316 if(!image
|| !count
)
1317 return InvalidParameter
;
1326 GpStatus WINGDIPAPI
GdipImageGetFrameDimensionsList(GpImage
* image
,
1327 GUID
* dimensionIDs
, UINT count
)
1331 if(!image
|| !dimensionIDs
)
1332 return InvalidParameter
;
1335 FIXME("not implemented\n");
1340 GpStatus WINGDIPAPI
GdipImageSelectActiveFrame(GpImage
*image
,
1341 GDIPCONST GUID
* dimensionID
, UINT frameidx
)
1345 if(!image
|| !dimensionID
)
1346 return InvalidParameter
;
1349 FIXME("not implemented\n");
1354 GpStatus WINGDIPAPI
GdipLoadImageFromFile(GDIPCONST WCHAR
* filename
,
1360 TRACE("(%s) %p\n", debugstr_w(filename
), image
);
1362 if (!filename
|| !image
)
1363 return InvalidParameter
;
1365 stat
= GdipCreateStreamOnFile(filename
, GENERIC_READ
, &stream
);
1370 stat
= GdipLoadImageFromStream(stream
, image
);
1372 IStream_Release(stream
);
1377 /* FIXME: no icm handling */
1378 GpStatus WINGDIPAPI
GdipLoadImageFromFileICM(GDIPCONST WCHAR
* filename
,GpImage
**image
)
1380 TRACE("(%s) %p\n", debugstr_w(filename
), image
);
1382 return GdipLoadImageFromFile(filename
, image
);
1385 static const WICPixelFormatGUID
*wic_pixel_formats
[] = {
1386 &GUID_WICPixelFormat16bppBGR555
,
1387 &GUID_WICPixelFormat24bppBGR
,
1388 &GUID_WICPixelFormat32bppBGR
,
1389 &GUID_WICPixelFormat32bppBGRA
,
1390 &GUID_WICPixelFormat32bppPBGRA
,
1394 static const PixelFormat wic_gdip_formats
[] = {
1395 PixelFormat16bppRGB555
,
1396 PixelFormat24bppRGB
,
1397 PixelFormat32bppRGB
,
1398 PixelFormat32bppARGB
,
1399 PixelFormat32bppPARGB
,
1402 static GpStatus
decode_image_wic(IStream
* stream
, REFCLSID clsid
, GpImage
**image
)
1407 IWICBitmapDecoder
*decoder
;
1408 IWICBitmapFrameDecode
*frame
;
1409 IWICBitmapSource
*source
=NULL
;
1410 WICPixelFormatGUID wic_format
;
1411 PixelFormat gdip_format
=0;
1414 BitmapData lockeddata
;
1418 initresult
= CoInitialize(NULL
);
1420 hr
= CoCreateInstance(clsid
, NULL
, CLSCTX_INPROC_SERVER
,
1421 &IID_IWICBitmapDecoder
, (void**)&decoder
);
1422 if (FAILED(hr
)) goto end
;
1424 hr
= IWICBitmapDecoder_Initialize(decoder
, (IStream
*)stream
, WICDecodeMetadataCacheOnLoad
);
1426 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &frame
);
1428 if (SUCCEEDED(hr
)) /* got frame */
1430 hr
= IWICBitmapFrameDecode_GetPixelFormat(frame
, &wic_format
);
1434 for (i
=0; wic_pixel_formats
[i
]; i
++)
1436 if (IsEqualGUID(&wic_format
, wic_pixel_formats
[i
]))
1438 source
= (IWICBitmapSource
*)frame
;
1439 IWICBitmapSource_AddRef(source
);
1440 gdip_format
= wic_gdip_formats
[i
];
1446 /* unknown format; fall back on 32bppARGB */
1447 hr
= WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGRA
, (IWICBitmapSource
*)frame
, &source
);
1448 gdip_format
= PixelFormat32bppARGB
;
1452 if (SUCCEEDED(hr
)) /* got source */
1454 hr
= IWICBitmapSource_GetSize(source
, &width
, &height
);
1457 status
= GdipCreateBitmapFromScan0(width
, height
, 0, gdip_format
,
1460 if (SUCCEEDED(hr
) && status
== Ok
) /* created bitmap */
1462 status
= GdipBitmapLockBits(bitmap
, NULL
, ImageLockModeWrite
,
1463 gdip_format
, &lockeddata
);
1464 if (status
== Ok
) /* locked bitmap */
1469 for (i
=0; i
<height
; i
++)
1472 hr
= IWICBitmapSource_CopyPixels(source
, &wrc
, abs(lockeddata
.Stride
),
1473 abs(lockeddata
.Stride
), (BYTE
*)lockeddata
.Scan0
+lockeddata
.Stride
*i
);
1474 if (FAILED(hr
)) break;
1477 GdipBitmapUnlockBits(bitmap
, &lockeddata
);
1480 if (SUCCEEDED(hr
) && status
== Ok
)
1481 *image
= (GpImage
*)bitmap
;
1485 GdipDisposeImage((GpImage
*)bitmap
);
1489 IWICBitmapSource_Release(source
);
1492 IWICBitmapFrameDecode_Release(frame
);
1495 IWICBitmapDecoder_Release(decoder
);
1498 if (SUCCEEDED(initresult
)) CoUninitialize();
1500 if (FAILED(hr
) && status
== Ok
) status
= hresult_to_status(hr
);
1505 static GpStatus
decode_image_icon(IStream
* stream
, REFCLSID clsid
, GpImage
**image
)
1507 return decode_image_wic(stream
, &CLSID_WICIcoDecoder
, image
);
1510 static GpStatus
decode_image_jpeg(IStream
* stream
, REFCLSID clsid
, GpImage
**image
)
1512 return decode_image_wic(stream
, &CLSID_WICJpegDecoder
, image
);
1515 static GpStatus
decode_image_gif(IStream
* stream
, REFCLSID clsid
, GpImage
**image
)
1517 return decode_image_wic(stream
, &CLSID_WICGifDecoder
, image
);
1520 static GpStatus
decode_image_olepicture_bitmap(IStream
* stream
, REFCLSID clsid
, GpImage
**image
)
1524 BITMAPCOREHEADER
* bmch
;
1528 TRACE("%p %p\n", stream
, image
);
1530 if(!stream
|| !image
)
1531 return InvalidParameter
;
1533 if(OleLoadPicture(stream
, 0, FALSE
, &IID_IPicture
,
1534 (LPVOID
*) &pic
) != S_OK
){
1535 TRACE("Could not load picture\n");
1536 return GenericError
;
1539 pbmi
= GdipAlloc(sizeof(BITMAPINFOHEADER
) + 256 * sizeof(RGBQUAD
));
1542 *image
= GdipAlloc(sizeof(GpBitmap
));
1547 (*image
)->type
= ImageTypeBitmap
;
1549 (*((GpBitmap
**) image
))->width
= ipicture_pixel_width(pic
);
1550 (*((GpBitmap
**) image
))->height
= ipicture_pixel_height(pic
);
1552 /* get the pixel format */
1553 IPicture_get_Handle(pic
, (OLE_HANDLE
*)&hbm
);
1554 IPicture_get_CurDC(pic
, &hdc
);
1556 (*((GpBitmap
**) image
))->hbitmap
= hbm
;
1557 (*((GpBitmap
**) image
))->hdc
= hdc
;
1558 (*((GpBitmap
**) image
))->bits
= NULL
;
1560 bmch
= (BITMAPCOREHEADER
*) (&pbmi
->bmiHeader
);
1561 bmch
->bcSize
= sizeof(BITMAPCOREHEADER
);
1565 hdc
= CreateCompatibleDC(0);
1566 old
= SelectObject(hdc
, hbm
);
1567 GetDIBits(hdc
, hbm
, 0, 0, NULL
, pbmi
, DIB_RGB_COLORS
);
1568 SelectObject(hdc
, old
);
1572 GetDIBits(hdc
, hbm
, 0, 0, NULL
, pbmi
, DIB_RGB_COLORS
);
1574 switch(bmch
->bcBitCount
)
1577 (*((GpBitmap
**) image
))->format
= PixelFormat1bppIndexed
;
1580 (*((GpBitmap
**) image
))->format
= PixelFormat4bppIndexed
;
1583 (*((GpBitmap
**) image
))->format
= PixelFormat8bppIndexed
;
1586 (*((GpBitmap
**) image
))->format
= PixelFormat16bppRGB565
;
1589 (*((GpBitmap
**) image
))->format
= PixelFormat24bppRGB
;
1592 (*((GpBitmap
**) image
))->format
= PixelFormat32bppRGB
;
1595 (*((GpBitmap
**) image
))->format
= PixelFormat48bppRGB
;
1598 FIXME("Bit depth %d is not fully supported yet\n", bmch
->bcBitCount
);
1599 (*((GpBitmap
**) image
))->format
= (bmch
->bcBitCount
<< 8) | PixelFormatGDI
;
1605 (*image
)->picture
= pic
;
1606 (*image
)->flags
= ImageFlagsNone
;
1611 static GpStatus
decode_image_olepicture_metafile(IStream
* stream
, REFCLSID clsid
, GpImage
**image
)
1615 TRACE("%p %p\n", stream
, image
);
1617 if(!stream
|| !image
)
1618 return InvalidParameter
;
1620 if(OleLoadPicture(stream
, 0, FALSE
, &IID_IPicture
,
1621 (LPVOID
*) &pic
) != S_OK
){
1622 TRACE("Could not load picture\n");
1623 return GenericError
;
1626 /* FIXME: missing initialization code */
1627 *image
= GdipAlloc(sizeof(GpMetafile
));
1628 if(!*image
) return OutOfMemory
;
1629 (*image
)->type
= ImageTypeMetafile
;
1630 (*image
)->picture
= pic
;
1631 (*image
)->flags
= ImageFlagsNone
;
1636 typedef GpStatus (*encode_image_func
)(GpImage
*image
, IStream
* stream
,
1637 GDIPCONST CLSID
* clsid
, GDIPCONST EncoderParameters
* params
);
1639 typedef GpStatus (*decode_image_func
)(IStream
*stream
, REFCLSID clsid
, GpImage
** image
);
1641 typedef struct image_codec
{
1642 ImageCodecInfo info
;
1643 encode_image_func encode_func
;
1644 decode_image_func decode_func
;
1658 static const struct image_codec codecs
[NUM_CODECS
];
1660 static GpStatus
get_decoder_info(IStream
* stream
, const struct image_codec
**result
)
1668 /* seek to the start of the stream */
1670 hr
= IStream_Seek(stream
, seek
, STREAM_SEEK_SET
, NULL
);
1671 if (FAILED(hr
)) return hresult_to_status(hr
);
1673 /* read the first 8 bytes */
1674 /* FIXME: This assumes all codecs have one signature <= 8 bytes in length */
1675 hr
= IStream_Read(stream
, signature
, 8, &bytesread
);
1676 if (FAILED(hr
)) return hresult_to_status(hr
);
1677 if (hr
== S_FALSE
|| bytesread
== 0) return GenericError
;
1679 for (i
= 0; i
< NUM_CODECS
; i
++) {
1680 if ((codecs
[i
].info
.Flags
& ImageCodecFlagsDecoder
) &&
1681 bytesread
>= codecs
[i
].info
.SigSize
)
1683 for (j
=0; j
<codecs
[i
].info
.SigSize
; j
++)
1684 if ((signature
[j
] & codecs
[i
].info
.SigMask
[j
]) != codecs
[i
].info
.SigPattern
[j
])
1686 if (j
== codecs
[i
].info
.SigSize
)
1688 *result
= &codecs
[i
];
1694 TRACE("no match for %i byte signature %x %x %x %x %x %x %x %x\n", bytesread
,
1695 signature
[0],signature
[1],signature
[2],signature
[3],
1696 signature
[4],signature
[5],signature
[6],signature
[7]);
1698 return GenericError
;
1701 GpStatus WINGDIPAPI
GdipLoadImageFromStream(IStream
* stream
, GpImage
**image
)
1706 const struct image_codec
*codec
=NULL
;
1708 /* choose an appropriate image decoder */
1709 stat
= get_decoder_info(stream
, &codec
);
1710 if (stat
!= Ok
) return stat
;
1712 /* seek to the start of the stream */
1714 hr
= IStream_Seek(stream
, seek
, STREAM_SEEK_SET
, NULL
);
1715 if (FAILED(hr
)) return hresult_to_status(hr
);
1717 /* call on the image decoder to do the real work */
1718 return codec
->decode_func(stream
, &codec
->info
.Clsid
, image
);
1722 GpStatus WINGDIPAPI
GdipLoadImageFromStreamICM(IStream
* stream
, GpImage
**image
)
1724 TRACE("%p %p\n", stream
, image
);
1726 return GdipLoadImageFromStream(stream
, image
);
1729 GpStatus WINGDIPAPI
GdipRemovePropertyItem(GpImage
*image
, PROPID propId
)
1734 return InvalidParameter
;
1737 FIXME("not implemented\n");
1739 return NotImplemented
;
1742 GpStatus WINGDIPAPI
GdipSetPropertyItem(GpImage
*image
, GDIPCONST PropertyItem
* item
)
1747 FIXME("not implemented\n");
1749 return NotImplemented
;
1752 GpStatus WINGDIPAPI
GdipSaveImageToFile(GpImage
*image
, GDIPCONST WCHAR
* filename
,
1753 GDIPCONST CLSID
*clsidEncoder
,
1754 GDIPCONST EncoderParameters
*encoderParams
)
1759 TRACE("%p (%s) %p %p\n", image
, debugstr_w(filename
), clsidEncoder
, encoderParams
);
1761 if (!image
|| !filename
|| !clsidEncoder
)
1762 return InvalidParameter
;
1764 stat
= GdipCreateStreamOnFile(filename
, GENERIC_WRITE
, &stream
);
1766 return GenericError
;
1768 stat
= GdipSaveImageToStream(image
, stream
, clsidEncoder
, encoderParams
);
1770 IStream_Release(stream
);
1774 /*************************************************************************
1775 * Encoding functions -
1776 * These functions encode an image in different image file formats.
1778 #define BITMAP_FORMAT_BMP 0x4d42 /* "BM" */
1779 #define BITMAP_FORMAT_JPEG 0xd8ff
1780 #define BITMAP_FORMAT_GIF 0x4947
1781 #define BITMAP_FORMAT_PNG 0x5089
1782 #define BITMAP_FORMAT_APM 0xcdd7
1784 static GpStatus
encode_image_WIC(GpImage
*image
, IStream
* stream
,
1785 GDIPCONST CLSID
* clsid
, GDIPCONST EncoderParameters
* params
)
1789 IWICBitmapEncoder
*encoder
;
1790 IWICBitmapFrameEncode
*frameencode
;
1791 IPropertyBag2
*encoderoptions
;
1794 PixelFormat gdipformat
=0;
1795 WICPixelFormatGUID wicformat
;
1797 BitmapData lockeddata
;
1801 if (image
->type
!= ImageTypeBitmap
)
1802 return GenericError
;
1804 bitmap
= (GpBitmap
*)image
;
1806 GdipGetImageWidth(image
, &width
);
1807 GdipGetImageHeight(image
, &height
);
1814 initresult
= CoInitialize(NULL
);
1816 hr
= CoCreateInstance(clsid
, NULL
, CLSCTX_INPROC_SERVER
,
1817 &IID_IWICBitmapEncoder
, (void**)&encoder
);
1820 if (SUCCEEDED(initresult
)) CoUninitialize();
1821 return hresult_to_status(hr
);
1824 hr
= IWICBitmapEncoder_Initialize(encoder
, stream
, WICBitmapEncoderNoCache
);
1828 hr
= IWICBitmapEncoder_CreateNewFrame(encoder
, &frameencode
, &encoderoptions
);
1831 if (SUCCEEDED(hr
)) /* created frame */
1833 hr
= IWICBitmapFrameEncode_Initialize(frameencode
, encoderoptions
);
1836 hr
= IWICBitmapFrameEncode_SetSize(frameencode
, width
, height
);
1839 /* FIXME: use the resolution from the image */
1840 hr
= IWICBitmapFrameEncode_SetResolution(frameencode
, 96.0, 96.0);
1844 for (i
=0; wic_pixel_formats
[i
]; i
++)
1846 if (wic_gdip_formats
[i
] == bitmap
->format
)
1849 if (wic_pixel_formats
[i
])
1850 memcpy(&wicformat
, wic_pixel_formats
[i
], sizeof(GUID
));
1852 memcpy(&wicformat
, &GUID_WICPixelFormat32bppBGRA
, sizeof(GUID
));
1854 hr
= IWICBitmapFrameEncode_SetPixelFormat(frameencode
, &wicformat
);
1856 for (i
=0; wic_pixel_formats
[i
]; i
++)
1858 if (IsEqualGUID(&wicformat
, wic_pixel_formats
[i
]))
1861 if (wic_pixel_formats
[i
])
1862 gdipformat
= wic_gdip_formats
[i
];
1865 ERR("cannot provide pixel format %s\n", debugstr_guid(&wicformat
));
1872 stat
= GdipBitmapLockBits(bitmap
, &rc
, ImageLockModeRead
, gdipformat
,
1877 UINT row_size
= (lockeddata
.Width
* PIXELFORMATBPP(gdipformat
) + 7)/8;
1880 /* write one row at a time in case stride is negative */
1881 row
= lockeddata
.Scan0
;
1882 for (i
=0; i
<lockeddata
.Height
; i
++)
1884 hr
= IWICBitmapFrameEncode_WritePixels(frameencode
, 1, row_size
, row_size
, row
);
1885 if (FAILED(hr
)) break;
1886 row
+= lockeddata
.Stride
;
1889 GdipBitmapUnlockBits(bitmap
, &lockeddata
);
1896 hr
= IWICBitmapFrameEncode_Commit(frameencode
);
1898 IWICBitmapFrameEncode_Release(frameencode
);
1899 IPropertyBag2_Release(encoderoptions
);
1903 hr
= IWICBitmapEncoder_Commit(encoder
);
1905 IWICBitmapEncoder_Release(encoder
);
1907 if (SUCCEEDED(initresult
)) CoUninitialize();
1909 return hresult_to_status(hr
);
1912 static GpStatus
encode_image_BMP(GpImage
*image
, IStream
* stream
,
1913 GDIPCONST CLSID
* clsid
, GDIPCONST EncoderParameters
* params
)
1915 return encode_image_WIC(image
, stream
, &CLSID_WICBmpEncoder
, params
);
1918 /*****************************************************************************
1919 * GdipSaveImageToStream [GDIPLUS.@]
1921 GpStatus WINGDIPAPI
GdipSaveImageToStream(GpImage
*image
, IStream
* stream
,
1922 GDIPCONST CLSID
* clsid
, GDIPCONST EncoderParameters
* params
)
1925 encode_image_func encode_image
;
1928 TRACE("%p %p %p %p\n", image
, stream
, clsid
, params
);
1930 if(!image
|| !stream
)
1931 return InvalidParameter
;
1933 /* select correct encoder */
1934 encode_image
= NULL
;
1935 for (i
= 0; i
< NUM_CODECS
; i
++) {
1936 if ((codecs
[i
].info
.Flags
& ImageCodecFlagsEncoder
) &&
1937 IsEqualCLSID(clsid
, &codecs
[i
].info
.Clsid
))
1938 encode_image
= codecs
[i
].encode_func
;
1940 if (encode_image
== NULL
)
1941 return UnknownImageFormat
;
1943 stat
= encode_image(image
, stream
, clsid
, params
);
1948 /*****************************************************************************
1949 * GdipGetImagePalette [GDIPLUS.@]
1951 GpStatus WINGDIPAPI
GdipGetImagePalette(GpImage
*image
, ColorPalette
*palette
, INT size
)
1953 static int calls
= 0;
1956 return InvalidParameter
;
1959 FIXME("not implemented\n");
1961 return NotImplemented
;
1964 /*****************************************************************************
1965 * GdipSetImagePalette [GDIPLUS.@]
1967 GpStatus WINGDIPAPI
GdipSetImagePalette(GpImage
*image
,
1968 GDIPCONST ColorPalette
*palette
)
1972 if(!image
|| !palette
)
1973 return InvalidParameter
;
1976 FIXME("not implemented\n");
1978 return NotImplemented
;
1981 /*************************************************************************
1983 * Structures that represent which formats we support for encoding.
1986 /* ImageCodecInfo creation routines taken from libgdiplus */
1987 static const WCHAR bmp_codecname
[] = {'B', 'u', 'i','l', 't', '-','i', 'n', ' ', 'B', 'M', 'P', 0}; /* Built-in BMP */
1988 static const WCHAR bmp_extension
[] = {'*','.','B', 'M', 'P',';', '*','.', 'D','I', 'B',';', '*','.', 'R', 'L', 'E',0}; /* *.BMP;*.DIB;*.RLE */
1989 static const WCHAR bmp_mimetype
[] = {'i', 'm', 'a','g', 'e', '/', 'b', 'm', 'p', 0}; /* image/bmp */
1990 static const WCHAR bmp_format
[] = {'B', 'M', 'P', 0}; /* BMP */
1991 static const BYTE bmp_sig_pattern
[] = { 0x42, 0x4D };
1992 static const BYTE bmp_sig_mask
[] = { 0xFF, 0xFF };
1994 static const WCHAR jpeg_codecname
[] = {'B', 'u', 'i','l', 't', '-','i', 'n', ' ', 'J','P','E','G', 0};
1995 static const WCHAR jpeg_extension
[] = {'*','.','J','P','G',';', '*','.','J','P','E','G',';', '*','.','J','P','E',';', '*','.','J','F','I','F',0};
1996 static const WCHAR jpeg_mimetype
[] = {'i','m','a','g','e','/','j','p','e','g', 0};
1997 static const WCHAR jpeg_format
[] = {'J','P','E','G',0};
1998 static const BYTE jpeg_sig_pattern
[] = { 0xFF, 0xD8 };
1999 static const BYTE jpeg_sig_mask
[] = { 0xFF, 0xFF };
2001 static const WCHAR gif_codecname
[] = {'B', 'u', 'i','l', 't', '-','i', 'n', ' ', 'G','I','F', 0};
2002 static const WCHAR gif_extension
[] = {'*','.','G','I','F',0};
2003 static const WCHAR gif_mimetype
[] = {'i','m','a','g','e','/','g','i','f', 0};
2004 static const WCHAR gif_format
[] = {'G','I','F',0};
2005 static const BYTE gif_sig_pattern
[4] = "GIF8";
2006 static const BYTE gif_sig_mask
[] = { 0xFF, 0xFF, 0xFF, 0xFF };
2008 static const WCHAR emf_codecname
[] = {'B', 'u', 'i','l', 't', '-','i', 'n', ' ', 'E','M','F', 0};
2009 static const WCHAR emf_extension
[] = {'*','.','E','M','F',0};
2010 static const WCHAR emf_mimetype
[] = {'i','m','a','g','e','/','x','-','e','m','f', 0};
2011 static const WCHAR emf_format
[] = {'E','M','F',0};
2012 static const BYTE emf_sig_pattern
[] = { 0x01, 0x00, 0x00, 0x00 };
2013 static const BYTE emf_sig_mask
[] = { 0xFF, 0xFF, 0xFF, 0xFF };
2015 static const WCHAR wmf_codecname
[] = {'B', 'u', 'i','l', 't', '-','i', 'n', ' ', 'W','M','F', 0};
2016 static const WCHAR wmf_extension
[] = {'*','.','W','M','F',0};
2017 static const WCHAR wmf_mimetype
[] = {'i','m','a','g','e','/','x','-','w','m','f', 0};
2018 static const WCHAR wmf_format
[] = {'W','M','F',0};
2019 static const BYTE wmf_sig_pattern
[] = { 0xd7, 0xcd };
2020 static const BYTE wmf_sig_mask
[] = { 0xFF, 0xFF };
2022 static const WCHAR png_codecname
[] = {'B', 'u', 'i','l', 't', '-','i', 'n', ' ', 'P','N','G', 0};
2023 static const WCHAR png_extension
[] = {'*','.','P','N','G',0};
2024 static const WCHAR png_mimetype
[] = {'i','m','a','g','e','/','p','n','g', 0};
2025 static const WCHAR png_format
[] = {'P','N','G',0};
2026 static const BYTE png_sig_pattern
[] = { 137, 80, 78, 71, 13, 10, 26, 10, };
2027 static const BYTE png_sig_mask
[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
2029 static const WCHAR ico_codecname
[] = {'B', 'u', 'i','l', 't', '-','i', 'n', ' ', 'I','C','O', 0};
2030 static const WCHAR ico_extension
[] = {'*','.','I','C','O',0};
2031 static const WCHAR ico_mimetype
[] = {'i','m','a','g','e','/','x','-','i','c','o','n', 0};
2032 static const WCHAR ico_format
[] = {'I','C','O',0};
2033 static const BYTE ico_sig_pattern
[] = { 0x00, 0x00, 0x01, 0x00 };
2034 static const BYTE ico_sig_mask
[] = { 0xFF, 0xFF, 0xFF, 0xFF };
2036 static const struct image_codec codecs
[NUM_CODECS
] = {
2039 /* Clsid */ { 0x557cf400, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } },
2040 /* FormatID */ { 0xb96b3cabU
, 0x0728U
, 0x11d3U
, {0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e} },
2041 /* CodecName */ bmp_codecname
,
2043 /* FormatDescription */ bmp_format
,
2044 /* FilenameExtension */ bmp_extension
,
2045 /* MimeType */ bmp_mimetype
,
2046 /* Flags */ ImageCodecFlagsEncoder
| ImageCodecFlagsDecoder
| ImageCodecFlagsSupportBitmap
| ImageCodecFlagsBuiltin
,
2050 /* SigPattern */ bmp_sig_pattern
,
2051 /* SigMask */ bmp_sig_mask
,
2054 decode_image_olepicture_bitmap
2058 /* Clsid */ { 0x557cf401, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } },
2059 /* FormatID */ { 0xb96b3caeU
, 0x0728U
, 0x11d3U
, {0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e} },
2060 /* CodecName */ jpeg_codecname
,
2062 /* FormatDescription */ jpeg_format
,
2063 /* FilenameExtension */ jpeg_extension
,
2064 /* MimeType */ jpeg_mimetype
,
2065 /* Flags */ ImageCodecFlagsDecoder
| ImageCodecFlagsSupportBitmap
| ImageCodecFlagsBuiltin
,
2069 /* SigPattern */ jpeg_sig_pattern
,
2070 /* SigMask */ jpeg_sig_mask
,
2077 /* Clsid */ { 0x557cf402, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } },
2078 /* FormatID */ { 0xb96b3cb0U
, 0x0728U
, 0x11d3U
, {0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e} },
2079 /* CodecName */ gif_codecname
,
2081 /* FormatDescription */ gif_format
,
2082 /* FilenameExtension */ gif_extension
,
2083 /* MimeType */ gif_mimetype
,
2084 /* Flags */ ImageCodecFlagsDecoder
| ImageCodecFlagsSupportBitmap
| ImageCodecFlagsBuiltin
,
2088 /* SigPattern */ gif_sig_pattern
,
2089 /* SigMask */ gif_sig_mask
,
2096 /* Clsid */ { 0x557cf403, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } },
2097 /* FormatID */ { 0xb96b3cacU
, 0x0728U
, 0x11d3U
, {0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e} },
2098 /* CodecName */ emf_codecname
,
2100 /* FormatDescription */ emf_format
,
2101 /* FilenameExtension */ emf_extension
,
2102 /* MimeType */ emf_mimetype
,
2103 /* Flags */ ImageCodecFlagsDecoder
| ImageCodecFlagsSupportVector
| ImageCodecFlagsBuiltin
,
2107 /* SigPattern */ emf_sig_pattern
,
2108 /* SigMask */ emf_sig_mask
,
2111 decode_image_olepicture_metafile
2115 /* Clsid */ { 0x557cf404, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } },
2116 /* FormatID */ { 0xb96b3cadU
, 0x0728U
, 0x11d3U
, {0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e} },
2117 /* CodecName */ wmf_codecname
,
2119 /* FormatDescription */ wmf_format
,
2120 /* FilenameExtension */ wmf_extension
,
2121 /* MimeType */ wmf_mimetype
,
2122 /* Flags */ ImageCodecFlagsDecoder
| ImageCodecFlagsSupportVector
| ImageCodecFlagsBuiltin
,
2126 /* SigPattern */ wmf_sig_pattern
,
2127 /* SigMask */ wmf_sig_mask
,
2130 decode_image_olepicture_metafile
2134 /* Clsid */ { 0x557cf406, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } },
2135 /* FormatID */ { 0xb96b3cafU
, 0x0728U
, 0x11d3U
, {0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e} },
2136 /* CodecName */ png_codecname
,
2138 /* FormatDescription */ png_format
,
2139 /* FilenameExtension */ png_extension
,
2140 /* MimeType */ png_mimetype
,
2141 /* Flags */ ImageCodecFlagsDecoder
| ImageCodecFlagsSupportBitmap
| ImageCodecFlagsBuiltin
,
2145 /* SigPattern */ png_sig_pattern
,
2146 /* SigMask */ png_sig_mask
,
2149 decode_image_olepicture_bitmap
2153 /* Clsid */ { 0x557cf407, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } },
2154 /* FormatID */ { 0xb96b3cabU
, 0x0728U
, 0x11d3U
, {0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e} },
2155 /* CodecName */ ico_codecname
,
2157 /* FormatDescription */ ico_format
,
2158 /* FilenameExtension */ ico_extension
,
2159 /* MimeType */ ico_mimetype
,
2160 /* Flags */ ImageCodecFlagsDecoder
| ImageCodecFlagsSupportBitmap
| ImageCodecFlagsBuiltin
,
2164 /* SigPattern */ ico_sig_pattern
,
2165 /* SigMask */ ico_sig_mask
,
2172 /*****************************************************************************
2173 * GdipGetImageDecodersSize [GDIPLUS.@]
2175 GpStatus WINGDIPAPI
GdipGetImageDecodersSize(UINT
*numDecoders
, UINT
*size
)
2177 int decoder_count
=0;
2179 TRACE("%p %p\n", numDecoders
, size
);
2181 if (!numDecoders
|| !size
)
2182 return InvalidParameter
;
2184 for (i
=0; i
<NUM_CODECS
; i
++)
2186 if (codecs
[i
].info
.Flags
& ImageCodecFlagsDecoder
)
2190 *numDecoders
= decoder_count
;
2191 *size
= decoder_count
* sizeof(ImageCodecInfo
);
2196 /*****************************************************************************
2197 * GdipGetImageDecoders [GDIPLUS.@]
2199 GpStatus WINGDIPAPI
GdipGetImageDecoders(UINT numDecoders
, UINT size
, ImageCodecInfo
*decoders
)
2201 int i
, decoder_count
=0;
2202 TRACE("%u %u %p\n", numDecoders
, size
, decoders
);
2205 size
!= numDecoders
* sizeof(ImageCodecInfo
))
2206 return GenericError
;
2208 for (i
=0; i
<NUM_CODECS
; i
++)
2210 if (codecs
[i
].info
.Flags
& ImageCodecFlagsDecoder
)
2212 if (decoder_count
== numDecoders
) return GenericError
;
2213 memcpy(&decoders
[decoder_count
], &codecs
[i
].info
, sizeof(ImageCodecInfo
));
2218 if (decoder_count
< numDecoders
) return GenericError
;
2223 /*****************************************************************************
2224 * GdipGetImageEncodersSize [GDIPLUS.@]
2226 GpStatus WINGDIPAPI
GdipGetImageEncodersSize(UINT
*numEncoders
, UINT
*size
)
2228 int encoder_count
=0;
2230 TRACE("%p %p\n", numEncoders
, size
);
2232 if (!numEncoders
|| !size
)
2233 return InvalidParameter
;
2235 for (i
=0; i
<NUM_CODECS
; i
++)
2237 if (codecs
[i
].info
.Flags
& ImageCodecFlagsEncoder
)
2241 *numEncoders
= encoder_count
;
2242 *size
= encoder_count
* sizeof(ImageCodecInfo
);
2247 /*****************************************************************************
2248 * GdipGetImageEncoders [GDIPLUS.@]
2250 GpStatus WINGDIPAPI
GdipGetImageEncoders(UINT numEncoders
, UINT size
, ImageCodecInfo
*encoders
)
2252 int i
, encoder_count
=0;
2253 TRACE("%u %u %p\n", numEncoders
, size
, encoders
);
2256 size
!= numEncoders
* sizeof(ImageCodecInfo
))
2257 return GenericError
;
2259 for (i
=0; i
<NUM_CODECS
; i
++)
2261 if (codecs
[i
].info
.Flags
& ImageCodecFlagsEncoder
)
2263 if (encoder_count
== numEncoders
) return GenericError
;
2264 memcpy(&encoders
[encoder_count
], &codecs
[i
].info
, sizeof(ImageCodecInfo
));
2269 if (encoder_count
< numEncoders
) return GenericError
;
2274 /*****************************************************************************
2275 * GdipCreateBitmapFromHBITMAP [GDIPLUS.@]
2277 GpStatus WINGDIPAPI
GdipCreateBitmapFromHBITMAP(HBITMAP hbm
, HPALETTE hpal
, GpBitmap
** bitmap
)
2284 TRACE("%p %p %p\n", hbm
, hpal
, bitmap
);
2287 return InvalidParameter
;
2289 /* TODO: Support for device-dependent bitmaps */
2291 FIXME("no support for device-dependent bitmaps\n");
2292 return NotImplemented
;
2295 if (GetObjectA(hbm
, sizeof(bm
), &bm
) != sizeof(bm
))
2296 return InvalidParameter
;
2298 /* TODO: Figure out the correct format for 16, 32, 64 bpp */
2299 switch(bm
.bmBitsPixel
) {
2301 format
= PixelFormat1bppIndexed
;
2304 format
= PixelFormat4bppIndexed
;
2307 format
= PixelFormat8bppIndexed
;
2310 format
= PixelFormat24bppRGB
;
2313 format
= PixelFormat32bppRGB
;
2316 format
= PixelFormat48bppRGB
;
2319 FIXME("don't know how to handle %d bpp\n", bm
.bmBitsPixel
);
2320 return InvalidParameter
;
2324 bits
= (BYTE
*)bm
.bmBits
+ (bm
.bmHeight
- 1) * bm
.bmWidthBytes
;
2327 FIXME("can only get image data from DIB sections\n");
2331 retval
= GdipCreateBitmapFromScan0(bm
.bmWidth
, bm
.bmHeight
, -bm
.bmWidthBytes
,
2332 format
, bits
, bitmap
);
2337 GpStatus WINGDIPAPI
GdipDeleteEffect(CGpEffect
*effect
)
2339 FIXME("(%p): stub\n", effect
);
2340 /* note: According to Jose Roca's GDI+ Docs, this is not implemented
2341 * in Windows's gdiplus */
2342 return NotImplemented
;
2345 /*****************************************************************************
2346 * GdipSetEffectParameters [GDIPLUS.@]
2348 GpStatus WINGDIPAPI
GdipSetEffectParameters(CGpEffect
*effect
,
2349 const VOID
*params
, const UINT size
)
2354 FIXME("not implemented\n");
2356 return NotImplemented
;
2359 /*****************************************************************************
2360 * GdipGetImageFlags [GDIPLUS.@]
2362 GpStatus WINGDIPAPI
GdipGetImageFlags(GpImage
*image
, UINT
*flags
)
2364 TRACE("%p %p\n", image
, flags
);
2366 if(!image
|| !flags
)
2367 return InvalidParameter
;
2369 *flags
= image
->flags
;
2374 GpStatus WINGDIPAPI
GdipTestControl(GpTestControlEnum control
, void *param
)
2376 TRACE("(%d, %p)\n", control
, param
);
2379 case TestControlForceBilinear
:
2381 FIXME("TestControlForceBilinear not handled\n");
2383 case TestControlNoICM
:
2385 FIXME("TestControlNoICM not handled\n");
2387 case TestControlGetBuildNumber
:
2388 *((DWORD
*)param
) = 3102;
2395 GpStatus WINGDIPAPI
GdipRecordMetafileFileName(GDIPCONST WCHAR
* fileName
,
2396 HDC hdc
, EmfType type
, GDIPCONST GpRectF
*pFrameRect
,
2397 MetafileFrameUnit frameUnit
, GDIPCONST WCHAR
*desc
,
2398 GpMetafile
**metafile
)
2400 FIXME("%s %p %d %p %d %s %p stub!\n", debugstr_w(fileName
), hdc
, type
, pFrameRect
,
2401 frameUnit
, debugstr_w(desc
), metafile
);
2403 return NotImplemented
;
2406 GpStatus WINGDIPAPI
GdipRecordMetafileFileNameI(GDIPCONST WCHAR
* fileName
, HDC hdc
, EmfType type
,
2407 GDIPCONST GpRect
*pFrameRect
, MetafileFrameUnit frameUnit
,
2408 GDIPCONST WCHAR
*desc
, GpMetafile
**metafile
)
2410 FIXME("%s %p %d %p %d %s %p stub!\n", debugstr_w(fileName
), hdc
, type
, pFrameRect
,
2411 frameUnit
, debugstr_w(desc
), metafile
);
2413 return NotImplemented
;
2416 GpStatus WINGDIPAPI
GdipImageForceValidation(GpImage
*image
)
2418 FIXME("%p\n", image
);
2423 /*****************************************************************************
2424 * GdipGetImageThumbnail [GDIPLUS.@]
2426 GpStatus WINGDIPAPI
GdipGetImageThumbnail(GpImage
*image
, UINT width
, UINT height
,
2427 GpImage
**ret_image
, GetThumbnailImageAbort cb
,
2430 FIXME("(%p %u %u %p %p %p) stub\n",
2431 image
, width
, height
, ret_image
, cb
, cb_data
);
2432 return NotImplemented
;
2435 /*****************************************************************************
2436 * GdipImageRotateFlip [GDIPLUS.@]
2438 GpStatus WINGDIPAPI
GdipImageRotateFlip(GpImage
*image
, RotateFlipType type
)
2440 FIXME("(%p %u) stub\n", image
, type
);
2441 return NotImplemented
;