ReactOS  0.4.14-dev-606-g14ebc0b
image.c File Reference
#include <stdarg.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "wingdi.h"
#include "objbase.h"
#include "olectl.h"
#include "ole2.h"
#include "initguid.h"
#include "wincodec.h"
#include "gdiplus.h"
#include "gdiplus_private.h"
#include "wine/debug.h"
Include dependency graph for image.c:

Go to the source code of this file.

Classes

struct  image_format_dimension
 
struct  image_codec
 

Macros

#define NONAMELESSUNION
 
#define COBJMACROS
 
#define PIXELFORMATBPP(x)   ((x) ? ((x) >> 8) & 255 : 24)
 
#define WMF_PLACEABLE_KEY   0x9ac6cdd7
 
#define convert_indexed_to_rgb(getpixel_function, setpixel_function)
 
#define convert_rgb_to_rgb(getpixel_function, setpixel_function)
 
#define convert_rgb_to_indexed(getpixel_function, setpixel_function)
 
#define PropertyTagTypeSByte   6
 
#define PropertyTagTypeSShort   8
 
#define PropertyTagTypeFloat   11
 
#define PropertyTagTypeDouble   12
 

Typedefs

typedef void(* metadata_reader_func) (GpBitmap *bitmap, IWICBitmapDecoder *decoder, UINT frame)
 
typedef GpStatus(* encode_image_func) (GpImage *image, IStream *stream, GDIPCONST EncoderParameters *params)
 
typedef GpStatus(* decode_image_func) (IStream *stream, GpImage **image)
 
typedef GpStatus(* select_image_func) (GpImage *image, UINT active_frame)
 
typedef struct image_codec image_codec
 

Enumerations

enum  ImageFormat {
  BMP, JPEG, GIF, TIFF,
  EMF, WMF, PNG, ICO,
  NUM_CODECS
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (gdiplus)
 
HRESULT WINAPI WICCreateImagingFactory_Proxy (UINT, IWICImagingFactory **)
 
static ColorPaletteget_palette (IWICBitmapFrameDecode *frame, WICBitmapPaletteType palette_type)
 
GpStatus WINGDIPAPI GdipBitmapApplyEffect (GpBitmap *bitmap, CGpEffect *effect, RECT *roi, BOOL useAuxData, VOID **auxData, INT *auxDataSize)
 
GpStatus WINGDIPAPI GdipBitmapCreateApplyEffect (GpBitmap **inputBitmaps, INT numInputs, CGpEffect *effect, RECT *roi, RECT *outputRect, GpBitmap **outputBitmap, BOOL useAuxData, VOID **auxData, INT *auxDataSize)
 
static void getpixel_1bppIndexed (BYTE *index, const BYTE *row, UINT x)
 
static void getpixel_4bppIndexed (BYTE *index, const BYTE *row, UINT x)
 
static void getpixel_8bppIndexed (BYTE *index, const BYTE *row, UINT x)
 
static void getpixel_16bppGrayScale (BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
 
static void getpixel_16bppRGB555 (BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
 
static void getpixel_16bppRGB565 (BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
 
static void getpixel_16bppARGB1555 (BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
 
static void getpixel_24bppRGB (BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
 
static void getpixel_32bppRGB (BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
 
static void getpixel_32bppARGB (BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
 
static void getpixel_32bppPARGB (BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
 
static void getpixel_48bppRGB (BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
 
static void getpixel_64bppARGB (BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
 
static void getpixel_64bppPARGB (BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
 
GpStatus WINGDIPAPI GdipBitmapGetPixel (GpBitmap *bitmap, INT x, INT y, ARGB *color)
 
static UINT get_palette_index (BYTE r, BYTE g, BYTE b, BYTE a, ColorPalette *palette)
 
static void setpixel_8bppIndexed (BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x, ColorPalette *palette)
 
static void setpixel_1bppIndexed (BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x, ColorPalette *palette)
 
static void setpixel_4bppIndexed (BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x, ColorPalette *palette)
 
static void setpixel_16bppGrayScale (BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
 
static void setpixel_16bppRGB555 (BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
 
static void setpixel_16bppRGB565 (BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
 
static void setpixel_16bppARGB1555 (BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
 
static void setpixel_24bppRGB (BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
 
static void setpixel_32bppRGB (BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
 
static void setpixel_32bppARGB (BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
 
static void setpixel_32bppPARGB (BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
 
static void setpixel_48bppRGB (BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
 
static void setpixel_64bppARGB (BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
 
static void setpixel_64bppPARGB (BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
 
GpStatus WINGDIPAPI GdipBitmapSetPixel (GpBitmap *bitmap, INT x, INT y, ARGB color)
 
GpStatus convert_pixels (INT width, INT height, INT dst_stride, BYTE *dst_bits, PixelFormat dst_format, INT src_stride, const BYTE *src_bits, PixelFormat src_format, ColorPalette *palette)
 
GpStatus WINGDIPAPI GdipBitmapLockBits (GpBitmap *bitmap, GDIPCONST GpRect *rect, UINT flags, PixelFormat format, BitmapData *lockeddata)
 
GpStatus WINGDIPAPI GdipBitmapSetResolution (GpBitmap *bitmap, REAL xdpi, REAL ydpi)
 
GpStatus WINGDIPAPI GdipBitmapUnlockBits (GpBitmap *bitmap, BitmapData *lockeddata)
 
GpStatus WINGDIPAPI GdipCloneBitmapArea (REAL x, REAL y, REAL width, REAL height, PixelFormat format, GpBitmap *srcBitmap, GpBitmap **dstBitmap)
 
GpStatus WINGDIPAPI GdipCloneBitmapAreaI (INT x, INT y, INT width, INT height, PixelFormat format, GpBitmap *srcBitmap, GpBitmap **dstBitmap)
 
GpStatus WINGDIPAPI GdipCloneImage (GpImage *image, GpImage **cloneImage)
 
GpStatus WINGDIPAPI GdipCreateBitmapFromFile (GDIPCONST WCHAR *filename, GpBitmap **bitmap)
 
GpStatus WINGDIPAPI GdipCreateBitmapFromGdiDib (GDIPCONST BITMAPINFO *info, VOID *bits, GpBitmap **bitmap)
 
GpStatus WINGDIPAPI GdipCreateBitmapFromFileICM (GDIPCONST WCHAR *filename, GpBitmap **bitmap)
 
GpStatus WINGDIPAPI GdipCreateBitmapFromResource (HINSTANCE hInstance, GDIPCONST WCHAR *lpBitmapName, GpBitmap **bitmap)
 
static DWORD blend_argb_no_bkgnd_alpha (DWORD src, DWORD bkgnd)
 
GpStatus WINGDIPAPI GdipCreateHBITMAPFromBitmap (GpBitmap *bitmap, HBITMAP *hbmReturn, ARGB background)
 
GpStatus WINGDIPAPI GdipCreateBitmapFromGraphics (INT width, INT height, GpGraphics *target, GpBitmap **bitmap)
 
GpStatus WINGDIPAPI GdipCreateBitmapFromHICON (HICON hicon, GpBitmap **bitmap)
 
static void generate_halftone_palette (ARGB *entries, UINT count)
 
static GpStatus get_screen_resolution (REAL *xres, REAL *yres)
 
GpStatus WINGDIPAPI GdipCreateBitmapFromScan0 (INT width, INT height, INT stride, PixelFormat format, BYTE *scan0, GpBitmap **bitmap)
 
GpStatus WINGDIPAPI GdipCreateBitmapFromStream (IStream *stream, GpBitmap **bitmap)
 
GpStatus WINGDIPAPI GdipCreateBitmapFromStreamICM (IStream *stream, GpBitmap **bitmap)
 
GpStatus WINGDIPAPI GdipCreateCachedBitmap (GpBitmap *bitmap, GpGraphics *graphics, GpCachedBitmap **cachedbmp)
 
GpStatus WINGDIPAPI GdipCreateHICONFromBitmap (GpBitmap *bitmap, HICON *hicon)
 
GpStatus WINGDIPAPI GdipDeleteCachedBitmap (GpCachedBitmap *cachedbmp)
 
GpStatus WINGDIPAPI GdipDrawCachedBitmap (GpGraphics *graphics, GpCachedBitmap *cachedbmp, INT x, INT y)
 
static void move_bitmap (GpBitmap *dst, GpBitmap *src, BOOL clobber_palette)
 
static GpStatus free_image_data (GpImage *image)
 
GpStatus WINGDIPAPI GdipDisposeImage (GpImage *image)
 
GpStatus WINGDIPAPI GdipFindFirstImageItem (GpImage *image, ImageItemData *item)
 
GpStatus WINGDIPAPI GdipGetImageItemData (GpImage *image, ImageItemData *item)
 
GpStatus WINGDIPAPI GdipGetImageBounds (GpImage *image, GpRectF *srcRect, GpUnit *srcUnit)
 
GpStatus WINGDIPAPI GdipGetImageDimension (GpImage *image, REAL *width, REAL *height)
 
GpStatus WINGDIPAPI GdipGetImageGraphicsContext (GpImage *image, GpGraphics **graphics)
 
GpStatus WINGDIPAPI GdipGetImageHeight (GpImage *image, UINT *height)
 
GpStatus WINGDIPAPI GdipGetImageHorizontalResolution (GpImage *image, REAL *res)
 
GpStatus WINGDIPAPI GdipGetImagePaletteSize (GpImage *image, INT *size)
 
GpStatus WINGDIPAPI GdipGetImagePixelFormat (GpImage *image, PixelFormat *format)
 
GpStatus WINGDIPAPI GdipGetImageRawFormat (GpImage *image, GUID *format)
 
GpStatus WINGDIPAPI GdipGetImageType (GpImage *image, ImageType *type)
 
GpStatus WINGDIPAPI GdipGetImageVerticalResolution (GpImage *image, REAL *res)
 
GpStatus WINGDIPAPI GdipGetImageWidth (GpImage *image, UINT *width)
 
GpStatus WINGDIPAPI GdipGetPropertyCount (GpImage *image, UINT *num)
 
GpStatus WINGDIPAPI GdipGetPropertyIdList (GpImage *image, UINT num, PROPID *list)
 
static UINT propvariant_size (PROPVARIANT *value)
 
GpStatus WINGDIPAPI GdipGetPropertyItemSize (GpImage *image, PROPID propid, UINT *size)
 
static UINT vt_to_itemtype (UINT vt)
 
static GpStatus propvariant_to_item (PROPVARIANT *value, PropertyItem *item, UINT size, PROPID id)
 
GpStatus WINGDIPAPI GdipGetPropertyItem (GpImage *image, PROPID propid, UINT size, PropertyItem *buffer)
 
GpStatus WINGDIPAPI GdipGetPropertySize (GpImage *image, UINT *size, UINT *count)
 
GpStatus WINGDIPAPI GdipGetAllPropertyItems (GpImage *image, UINT size, UINT count, PropertyItem *buf)
 
GpStatus WINGDIPAPI GdipImageGetFrameCount (GpImage *image, GDIPCONST GUID *dimensionID, UINT *count)
 
GpStatus WINGDIPAPI GdipImageGetFrameDimensionsCount (GpImage *image, UINT *count)
 
GpStatus WINGDIPAPI GdipImageGetFrameDimensionsList (GpImage *image, GUID *dimensionIDs, UINT count)
 
GpStatus WINGDIPAPI GdipLoadImageFromFile (GDIPCONST WCHAR *filename, GpImage **image)
 
GpStatus WINGDIPAPI GdipLoadImageFromFileICM (GDIPCONST WCHAR *filename, GpImage **image)
 
static void add_property (GpBitmap *bitmap, PropertyItem *item)
 
static BOOL get_bool_property (IWICMetadataReader *reader, const GUID *guid, const WCHAR *prop_name)
 
static PropertyItemget_property (IWICMetadataReader *reader, const GUID *guid, const WCHAR *prop_name)
 
static PropertyItemget_gif_comment (IWICMetadataReader *reader)
 
static PropertyItemget_gif_loopcount (IWICMetadataReader *reader)
 
static PropertyItemget_gif_background (IWICMetadataReader *reader)
 
static PropertyItemget_gif_palette (IWICBitmapDecoder *decoder, IWICMetadataReader *reader)
 
static PropertyItemget_gif_transparent_idx (IWICMetadataReader *reader)
 
static LONG get_gif_frame_property (IWICBitmapFrameDecode *frame, const GUID *format, const WCHAR *property)
 
static void gif_metadata_reader (GpBitmap *bitmap, IWICBitmapDecoder *decoder, UINT active_frame)
 
static PropertyItemcreate_prop (PROPID propid, PROPVARIANT *value)
 
static ULONG get_ulong_by_index (IWICMetadataReader *reader, ULONG index)
 
static void png_metadata_reader (GpBitmap *bitmap, IWICBitmapDecoder *decoder, UINT active_frame)
 
static GpStatus initialize_decoder_wic (IStream *stream, REFGUID container, IWICBitmapDecoder **decoder)
 
static GpStatus decode_frame_wic (IWICBitmapDecoder *decoder, BOOL force_conversion, UINT active_frame, metadata_reader_func metadata_reader, GpImage **image)
 
static GpStatus decode_image_wic (IStream *stream, REFGUID container, metadata_reader_func metadata_reader, GpImage **image)
 
static GpStatus select_frame_wic (GpImage *image, UINT active_frame)
 
static HRESULT get_gif_frame_rect (IWICBitmapFrameDecode *frame, UINT *left, UINT *top, UINT *width, UINT *height)
 
static HRESULT blit_gif_frame (GpBitmap *bitmap, IWICBitmapFrameDecode *frame, BOOL first_frame)
 
static DWORD get_gif_background_color (GpBitmap *bitmap)
 
static GpStatus select_frame_gif (GpImage *image, UINT active_frame)
 
static GpStatus decode_image_icon (IStream *stream, GpImage **image)
 
static GpStatus decode_image_bmp (IStream *stream, GpImage **image)
 
static GpStatus decode_image_jpeg (IStream *stream, GpImage **image)
 
static BOOL has_png_transparency_chunk (IStream *pIStream)
 
static GpStatus decode_image_png (IStream *stream, GpImage **image)
 
static GpStatus decode_image_gif (IStream *stream, GpImage **image)
 
static GpStatus decode_image_tiff (IStream *stream, GpImage **image)
 
static GpStatus load_wmf (IStream *stream, GpMetafile **metafile)
 
static GpStatus decode_image_wmf (IStream *stream, GpImage **image)
 
static GpStatus load_emf (IStream *stream, GpMetafile **metafile)
 
static GpStatus decode_image_emf (IStream *stream, GpImage **image)
 
static GpStatus get_decoder_info (IStream *stream, const struct image_codec **result)
 
static GpStatus get_decoder_info_from_image (GpImage *image, const struct image_codec **result)
 
GpStatus WINGDIPAPI GdipImageSelectActiveFrame (GpImage *image, GDIPCONST GUID *dimensionID, UINT frame)
 
GpStatus WINGDIPAPI GdipLoadImageFromStream (IStream *stream, GpImage **image)
 
GpStatus WINGDIPAPI GdipLoadImageFromStreamICM (IStream *stream, GpImage **image)
 
GpStatus WINGDIPAPI GdipRemovePropertyItem (GpImage *image, PROPID propId)
 
GpStatus WINGDIPAPI GdipSetPropertyItem (GpImage *image, GDIPCONST PropertyItem *item)
 
GpStatus WINGDIPAPI GdipSaveImageToFile (GpImage *image, GDIPCONST WCHAR *filename, GDIPCONST CLSID *clsidEncoder, GDIPCONST EncoderParameters *encoderParams)
 
static GpStatus encode_image_wic (GpImage *image, IStream *stream, REFGUID container, GDIPCONST EncoderParameters *params)
 
static GpStatus encode_image_BMP (GpImage *image, IStream *stream, GDIPCONST EncoderParameters *params)
 
static GpStatus encode_image_tiff (GpImage *image, IStream *stream, GDIPCONST EncoderParameters *params)
 
GpStatus encode_image_png (GpImage *image, IStream *stream, GDIPCONST EncoderParameters *params)
 
static GpStatus encode_image_jpeg (GpImage *image, IStream *stream, GDIPCONST EncoderParameters *params)
 
static GpStatus encode_image_gif (GpImage *image, IStream *stream, GDIPCONST EncoderParameters *params)
 
GpStatus WINGDIPAPI GdipSaveImageToStream (GpImage *image, IStream *stream, GDIPCONST CLSID *clsid, GDIPCONST EncoderParameters *params)
 
GpStatus WINGDIPAPI GdipSaveAdd (GpImage *image, GDIPCONST EncoderParameters *params)
 
GpStatus WINGDIPAPI GdipGetImagePalette (GpImage *image, ColorPalette *palette, INT size)
 
GpStatus WINGDIPAPI GdipSetImagePalette (GpImage *image, GDIPCONST ColorPalette *palette)
 
GpStatus WINGDIPAPI GdipGetImageDecodersSize (UINT *numDecoders, UINT *size)
 
GpStatus WINGDIPAPI GdipGetImageDecoders (UINT numDecoders, UINT size, ImageCodecInfo *decoders)
 
GpStatus WINGDIPAPI GdipGetImageEncodersSize (UINT *numEncoders, UINT *size)
 
GpStatus WINGDIPAPI GdipGetImageEncoders (UINT numEncoders, UINT size, ImageCodecInfo *encoders)
 
GpStatus WINGDIPAPI GdipGetEncoderParameterListSize (GpImage *image, GDIPCONST CLSID *clsidEncoder, UINT *size)
 
static PixelFormat get_16bpp_format (HBITMAP hbm)
 
GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP (HBITMAP hbm, HPALETTE hpal, GpBitmap **bitmap)
 
GpStatus WINGDIPAPI GdipCreateEffect (const GUID guid, CGpEffect **effect)
 
GpStatus WINGDIPAPI GdipDeleteEffect (CGpEffect *effect)
 
GpStatus WINGDIPAPI GdipSetEffectParameters (CGpEffect *effect, const VOID *params, const UINT size)
 
GpStatus WINGDIPAPI GdipGetImageFlags (GpImage *image, UINT *flags)
 
GpStatus WINGDIPAPI GdipTestControl (GpTestControlEnum control, void *param)
 
GpStatus WINGDIPAPI GdipImageForceValidation (GpImage *image)
 
GpStatus WINGDIPAPI GdipGetImageThumbnail (GpImage *image, UINT width, UINT height, GpImage **ret_image, GetThumbnailImageAbort cb, VOID *cb_data)
 
GpStatus WINGDIPAPI GdipImageRotateFlip (GpImage *image, RotateFlipType type)
 
GpStatus WINGDIPAPI GdipImageSetAbort (GpImage *image, GdiplusAbort *pabort)
 
GpStatus WINGDIPAPI GdipBitmapConvertFormat (GpBitmap *bitmap, PixelFormat format, DitherType dithertype, PaletteType palettetype, ColorPalette *palette, REAL alphathreshold)
 
static void set_histogram_point_argb (ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
 
static void set_histogram_point_pargb (ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
 
static void set_histogram_point_rgb (ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
 
static void set_histogram_point_gray (ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
 
static void set_histogram_point_b (ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
 
static void set_histogram_point_g (ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
 
static void set_histogram_point_r (ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
 
static void set_histogram_point_a (ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
 
GpStatus WINGDIPAPI GdipBitmapGetHistogram (GpBitmap *bitmap, HistogramFormat format, UINT num_of_entries, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
 
GpStatus WINGDIPAPI GdipBitmapGetHistogramSize (HistogramFormat format, UINT *num_of_entries)
 
static GpStatus create_optimal_palette (ColorPalette *palette, INT desired, BOOL transparent, GpBitmap *bitmap)
 
GpStatus WINGDIPAPI GdipInitializePalette (ColorPalette *palette, PaletteType type, INT desired, BOOL transparent, GpBitmap *bitmap)
 

Variables

struct {
   const WICPixelFormatGUID *   wic_format
 
   PixelFormat   gdip_format
 
   WICBitmapPaletteType   palette_type
 
pixel_formats []
 
static const struct image_format_dimension image_format_dimensions []
 
static const struct image_codec codecs [NUM_CODECS]
 
static const WCHAR bmp_codecname [] = {'B', 'u', 'i','l', 't', '-','i', 'n', ' ', 'B', 'M', 'P', 0}
 
static const WCHAR bmp_extension [] = {'*','.','B', 'M', 'P',';', '*','.', 'D','I', 'B',';', '*','.', 'R', 'L', 'E',0}
 
static const WCHAR bmp_mimetype [] = {'i', 'm', 'a','g', 'e', '/', 'b', 'm', 'p', 0}
 
static const WCHAR bmp_format [] = {'B', 'M', 'P', 0}
 
static const BYTE bmp_sig_pattern [] = { 0x42, 0x4D }
 
static const BYTE bmp_sig_mask [] = { 0xFF, 0xFF }
 
static const WCHAR jpeg_codecname [] = {'B', 'u', 'i','l', 't', '-','i', 'n', ' ', 'J','P','E','G', 0}
 
static const WCHAR jpeg_extension [] = {'*','.','J','P','G',';', '*','.','J','P','E','G',';', '*','.','J','P','E',';', '*','.','J','F','I','F',0}
 
static const WCHAR jpeg_mimetype [] = {'i','m','a','g','e','/','j','p','e','g', 0}
 
static const WCHAR jpeg_format [] = {'J','P','E','G',0}
 
static const BYTE jpeg_sig_pattern [] = { 0xFF, 0xD8 }
 
static const BYTE jpeg_sig_mask [] = { 0xFF, 0xFF }
 
static const WCHAR gif_codecname [] = {'B', 'u', 'i','l', 't', '-','i', 'n', ' ', 'G','I','F', 0}
 
static const WCHAR gif_extension [] = {'*','.','G','I','F',0}
 
static const WCHAR gif_mimetype [] = {'i','m','a','g','e','/','g','i','f', 0}
 
static const WCHAR gif_format [] = {'G','I','F',0}
 
static const BYTE gif_sig_pattern [12] = "GIF87aGIF89a"
 
static const BYTE gif_sig_mask [] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
 
static const WCHAR tiff_codecname [] = {'B', 'u', 'i','l', 't', '-','i', 'n', ' ', 'T','I','F','F', 0}
 
static const WCHAR tiff_extension [] = {'*','.','T','I','F','F',';','*','.','T','I','F',0}
 
static const WCHAR tiff_mimetype [] = {'i','m','a','g','e','/','t','i','f','f', 0}
 
static const WCHAR tiff_format [] = {'T','I','F','F',0}
 
static const BYTE tiff_sig_pattern [] = {0x49,0x49,42,0,0x4d,0x4d,0,42}
 
static const BYTE tiff_sig_mask [] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
 
static const WCHAR emf_codecname [] = {'B', 'u', 'i','l', 't', '-','i', 'n', ' ', 'E','M','F', 0}
 
static const WCHAR emf_extension [] = {'*','.','E','M','F',0}
 
static const WCHAR emf_mimetype [] = {'i','m','a','g','e','/','x','-','e','m','f', 0}
 
static const WCHAR emf_format [] = {'E','M','F',0}
 
static const BYTE emf_sig_pattern [] = { 0x01, 0x00, 0x00, 0x00 }
 
static const BYTE emf_sig_mask [] = { 0xFF, 0xFF, 0xFF, 0xFF }
 
static const WCHAR wmf_codecname [] = {'B', 'u', 'i','l', 't', '-','i', 'n', ' ', 'W','M','F', 0}
 
static const WCHAR wmf_extension [] = {'*','.','W','M','F',0}
 
static const WCHAR wmf_mimetype [] = {'i','m','a','g','e','/','x','-','w','m','f', 0}
 
static const WCHAR wmf_format [] = {'W','M','F',0}
 
static const BYTE wmf_sig_pattern [] = { 0xd7, 0xcd }
 
static const BYTE wmf_sig_mask [] = { 0xFF, 0xFF }
 
static const WCHAR png_codecname [] = {'B', 'u', 'i','l', 't', '-','i', 'n', ' ', 'P','N','G', 0}
 
static const WCHAR png_extension [] = {'*','.','P','N','G',0}
 
static const WCHAR png_mimetype [] = {'i','m','a','g','e','/','p','n','g', 0}
 
static const WCHAR png_format [] = {'P','N','G',0}
 
static const BYTE png_sig_pattern [] = { 137, 80, 78, 71, 13, 10, 26, 10, }
 
static const BYTE png_sig_mask [] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
 
static const WCHAR ico_codecname [] = {'B', 'u', 'i','l', 't', '-','i', 'n', ' ', 'I','C','O', 0}
 
static const WCHAR ico_extension [] = {'*','.','I','C','O',0}
 
static const WCHAR ico_mimetype [] = {'i','m','a','g','e','/','x','-','i','c','o','n', 0}
 
static const WCHAR ico_format [] = {'I','C','O',0}
 
static const BYTE ico_sig_pattern [] = { 0x00, 0x00, 0x01, 0x00 }
 
static const BYTE ico_sig_mask [] = { 0xFF, 0xFF, 0xFF, 0xFF }
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 30 of file image.c.

◆ convert_indexed_to_rgb

#define convert_indexed_to_rgb (   getpixel_function,
  setpixel_function 
)
Value:
do { \
for (y=0; y<height; y++) \
for (x=0; x<width; x++) { \
BYTE index; \
ARGB argb; \
BYTE *color = (BYTE *)&argb; \
getpixel_function(&index, src_bits+src_stride*y, x); \
argb = (palette && index < palette->Count) ? palette->Entries[index] : 0; \
setpixel_function(color[2], color[1], color[0], color[3], dst_bits+dst_stride*y, x); \
} \
return Ok; \
} while (0);
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint color
Definition: glext.h:6243
GLuint index
Definition: glext.h:6031
#define index(s, c)
Definition: various.h:29
unsigned char BYTE
Definition: mem.h:68
static HPALETTE palette
Definition: clipboard.c:1345
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

◆ convert_rgb_to_indexed

#define convert_rgb_to_indexed (   getpixel_function,
  setpixel_function 
)
Value:
do { \
for (y=0; y<height; y++) \
for (x=0; x<width; x++) { \
BYTE r, g, b, a; \
getpixel_function(&r, &g, &b, &a, src_bits+src_stride*y, x); \
setpixel_function(r, g, b, a, dst_bits+dst_stride*y, x, palette); \
} \
return Ok; \
} while (0);
GLint GLint GLsizei width
Definition: gl.h:1546
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
static HPALETTE palette
Definition: clipboard.c:1345
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ convert_rgb_to_rgb

#define convert_rgb_to_rgb (   getpixel_function,
  setpixel_function 
)
Value:
do { \
for (y=0; y<height; y++) \
for (x=0; x<width; x++) { \
BYTE r, g, b, a; \
getpixel_function(&r, &g, &b, &a, src_bits+src_stride*y, x); \
setpixel_function(r, g, b, a, dst_bits+dst_stride*y, x); \
} \
return Ok; \
} while (0);
GLint GLint GLsizei width
Definition: gl.h:1546
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 23 of file image.c.

◆ PIXELFORMATBPP

#define PIXELFORMATBPP (   x)    ((x) ? ((x) >> 8) & 255 : 24)

Definition at line 45 of file image.c.

◆ PropertyTagTypeDouble

#define PropertyTagTypeDouble   12

Definition at line 2539 of file image.c.

◆ PropertyTagTypeFloat

#define PropertyTagTypeFloat   11

Definition at line 2538 of file image.c.

◆ PropertyTagTypeSByte

#define PropertyTagTypeSByte   6

Definition at line 2536 of file image.c.

◆ PropertyTagTypeSShort

#define PropertyTagTypeSShort   8

Definition at line 2537 of file image.c.

◆ WMF_PLACEABLE_KEY

#define WMF_PLACEABLE_KEY   0x9ac6cdd7

Definition at line 46 of file image.c.

Typedef Documentation

◆ decode_image_func

typedef GpStatus(* decode_image_func) (IStream *stream, GpImage **image)

Definition at line 4212 of file image.c.

◆ encode_image_func

typedef GpStatus(* encode_image_func) (GpImage *image, IStream *stream, GDIPCONST EncoderParameters *params)

Definition at line 4209 of file image.c.

◆ image_codec

◆ metadata_reader_func

typedef void(* metadata_reader_func) (GpBitmap *bitmap, IWICBitmapDecoder *decoder, UINT frame)

Definition at line 3582 of file image.c.

◆ select_image_func

typedef GpStatus(* select_image_func) (GpImage *image, UINT active_frame)

Definition at line 4214 of file image.c.

Enumeration Type Documentation

◆ ImageFormat

Enumerator
BMP 
JPEG 
GIF 
TIFF 
EMF 
WMF 
PNG 
ICO 
NUM_CODECS 

Definition at line 4223 of file image.c.

4223  {
4224  BMP,
4225  JPEG,
4226  GIF,
4227  TIFF,
4228  EMF,
4229  WMF,
4230  PNG,
4231  ICO,
4232  NUM_CODECS
4233 } ImageFormat;
Definition: image.c:4227
Definition: image.c:4228
Definition: image.c:4224
Definition: image.c:4225
Definition: image.c:4229
ImageFormat
Definition: image.c:4223
Definition: image.c:4226
Definition: image.c:4231
Definition: image.c:4230

Function Documentation

◆ add_property()

static void add_property ( GpBitmap bitmap,
PropertyItem item 
)
static

Definition at line 2961 of file image.c.

2962 {
2963  UINT prop_size, prop_count;
2964  PropertyItem *prop_item;
2965 
2966  if (bitmap->prop_item == NULL)
2967  {
2968  prop_size = prop_count = 0;
2969  prop_item = heap_alloc_zero(item->length + sizeof(PropertyItem));
2970  if (!prop_item) return;
2971  }
2972  else
2973  {
2974  UINT i;
2975  char *item_value;
2976 
2977  GdipGetPropertySize(&bitmap->image, &prop_size, &prop_count);
2978 
2979  prop_item = heap_alloc_zero(prop_size + item->length + sizeof(PropertyItem));
2980  if (!prop_item) return;
2981  memcpy(prop_item, bitmap->prop_item, sizeof(PropertyItem) * bitmap->prop_count);
2982  prop_size -= sizeof(PropertyItem) * bitmap->prop_count;
2983  memcpy(prop_item + prop_count + 1, bitmap->prop_item + prop_count, prop_size);
2984 
2985  item_value = (char *)(prop_item + prop_count + 1);
2986 
2987  for (i = 0; i < prop_count; i++)
2988  {
2989  prop_item[i].value = item_value;
2990  item_value += prop_item[i].length;
2991  }
2992  }
2993 
2994  prop_item[prop_count].id = item->id;
2995  prop_item[prop_count].type = item->type;
2996  prop_item[prop_count].length = item->length;
2997  prop_item[prop_count].value = (char *)(prop_item + prop_count + 1) + prop_size;
2998  memcpy(prop_item[prop_count].value, item->value, item->length);
2999 
3000  heap_free(bitmap->prop_item);
3001  bitmap->prop_item = prop_item;
3002  bitmap->prop_count++;
3003 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
Definition: uimain.c:88
struct PropertyItem PropertyItem
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static ATOM item
Definition: dde.c:856
unsigned int UINT
Definition: ndis.h:50
GpStatus WINGDIPAPI GdipGetPropertySize(GpImage *image, UINT *size, UINT *count)
Definition: image.c:2687
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by gif_metadata_reader(), and png_metadata_reader().

◆ blend_argb_no_bkgnd_alpha()

static DWORD blend_argb_no_bkgnd_alpha ( DWORD  src,
DWORD  bkgnd 
)
inlinestatic

Definition at line 1467 of file image.c.

1468 {
1469  BYTE b = (BYTE)src;
1470  BYTE g = (BYTE)(src >> 8);
1471  BYTE r = (BYTE)(src >> 16);
1472  DWORD alpha = (BYTE)(src >> 24);
1473  return ((b + ((BYTE)bkgnd * (255 - alpha) + 127) / 255) |
1474  (g + ((BYTE)(bkgnd >> 8) * (255 - alpha) + 127) / 255) << 8 |
1475  (r + ((BYTE)(bkgnd >> 16) * (255 - alpha) + 127) / 255) << 16 |
1476  (alpha << 24));
1477 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740

Referenced by GdipCreateHBITMAPFromBitmap().

◆ blit_gif_frame()

static HRESULT blit_gif_frame ( GpBitmap bitmap,
IWICBitmapFrameDecode frame,
BOOL  first_frame 
)
static

Definition at line 3786 of file image.c.

3787 {
3788  UINT i, j, left, top, width, height;
3790  BYTE *new_bits;
3791  HRESULT hr;
3792 
3793  hr = get_gif_frame_rect(frame, &left, &top, &width, &height);
3794  if(FAILED(hr))
3795  return hr;
3796 
3797  hr = WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGRA, (IWICBitmapSource*)frame, &source);
3798  if(FAILED(hr))
3799  return hr;
3800 
3801  new_bits = heap_alloc_zero(width*height*4);
3802  if(!new_bits)
3803  return E_OUTOFMEMORY;
3804 
3805  hr = IWICBitmapSource_CopyPixels(source, NULL, width*4, width*height*4, new_bits);
3806  IWICBitmapSource_Release(source);
3807  if(FAILED(hr)) {
3808  heap_free(new_bits);
3809  return hr;
3810  }
3811 
3812  for(i=0; i<height && i+top<bitmap->height; i++) {
3813  for(j=0; j<width && j+left<bitmap->width; j++) {
3814  DWORD *src = (DWORD*)(new_bits+i*width*4+j*4);
3815  DWORD *dst = (DWORD*)(bitmap->bits+(i+top)*bitmap->stride+(j+left)*4);
3816 
3817  if(first_frame || *src>>24 != 0)
3818  *dst = *src;
3819  }
3820  }
3821  heap_free(new_bits);
3822  return hr;
3823 }
GLint GLint GLsizei width
Definition: gl.h:1546
static HRESULT get_gif_frame_rect(IWICBitmapFrameDecode *frame, UINT *left, UINT *top, UINT *width, UINT *height)
Definition: image.c:3774
uint32 width
Definition: uimain.c:91
HRESULT hr
Definition: shlfolder.c:183
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
Definition: uimain.c:88
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint left
Definition: glext.h:7726
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
uint32 height
Definition: uimain.c:92
GLsizei GLsizei GLchar * source
Definition: glext.h:6048
GLenum GLenum dst
Definition: glext.h:6340
unsigned int UINT
Definition: ndis.h:50
HRESULT WINAPI WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat, IWICBitmapSource *pISrc, IWICBitmapSource **ppIDst)
Definition: info.c:2474
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by select_frame_gif().

◆ convert_pixels()

GpStatus convert_pixels ( INT  width,
INT  height,
INT  dst_stride,
BYTE dst_bits,
PixelFormat  dst_format,
INT  src_stride,
const BYTE src_bits,
PixelFormat  src_format,
ColorPalette palette 
)

Definition at line 562 of file image.c.

566 {
567  INT x, y;
568 
569  if (src_format == dst_format ||
570  (dst_format == PixelFormat32bppRGB && PIXELFORMATBPP(src_format) == 32))
571  {
572  UINT widthbytes = PIXELFORMATBPP(src_format) * width / 8;
573  for (y=0; y<height; y++)
574  memcpy(dst_bits+dst_stride*y, src_bits+src_stride*y, widthbytes);
575  return Ok;
576  }
577 
578 #define convert_indexed_to_rgb(getpixel_function, setpixel_function) do { \
579  for (y=0; y<height; y++) \
580  for (x=0; x<width; x++) { \
581  BYTE index; \
582  ARGB argb; \
583  BYTE *color = (BYTE *)&argb; \
584  getpixel_function(&index, src_bits+src_stride*y, x); \
585  argb = (palette && index < palette->Count) ? palette->Entries[index] : 0; \
586  setpixel_function(color[2], color[1], color[0], color[3], dst_bits+dst_stride*y, x); \
587  } \
588  return Ok; \
589 } while (0);
590 
591 #define convert_rgb_to_rgb(getpixel_function, setpixel_function) do { \
592  for (y=0; y<height; y++) \
593  for (x=0; x<width; x++) { \
594  BYTE r, g, b, a; \
595  getpixel_function(&r, &g, &b, &a, src_bits+src_stride*y, x); \
596  setpixel_function(r, g, b, a, dst_bits+dst_stride*y, x); \
597  } \
598  return Ok; \
599 } while (0);
600 
601 #define convert_rgb_to_indexed(getpixel_function, setpixel_function) do { \
602  for (y=0; y<height; y++) \
603  for (x=0; x<width; x++) { \
604  BYTE r, g, b, a; \
605  getpixel_function(&r, &g, &b, &a, src_bits+src_stride*y, x); \
606  setpixel_function(r, g, b, a, dst_bits+dst_stride*y, x, palette); \
607  } \
608  return Ok; \
609 } while (0);
610 
611  switch (src_format)
612  {
614  switch (dst_format)
615  {
624  case PixelFormat24bppRGB:
626  case PixelFormat32bppRGB:
632  case PixelFormat48bppRGB:
636  default:
637  break;
638  }
639  break;
641  switch (dst_format)
642  {
651  case PixelFormat24bppRGB:
653  case PixelFormat32bppRGB:
659  case PixelFormat48bppRGB:
663  default:
664  break;
665  }
666  break;
668  switch (dst_format)
669  {
678  case PixelFormat24bppRGB:
680  case PixelFormat32bppRGB:
686  case PixelFormat48bppRGB:
690  default:
691  break;
692  }
693  break;
695  switch (dst_format)
696  {
707  case PixelFormat24bppRGB:
709  case PixelFormat32bppRGB:
715  case PixelFormat48bppRGB:
719  default:
720  break;
721  }
722  break;
724  switch (dst_format)
725  {
736  case PixelFormat24bppRGB:
738  case PixelFormat32bppRGB:
744  case PixelFormat48bppRGB:
748  default:
749  break;
750  }
751  break;
753  switch (dst_format)
754  {
765  case PixelFormat24bppRGB:
767  case PixelFormat32bppRGB:
773  case PixelFormat48bppRGB:
777  default:
778  break;
779  }
780  break;
782  switch (dst_format)
783  {
794  case PixelFormat24bppRGB:
796  case PixelFormat32bppRGB:
802  case PixelFormat48bppRGB:
806  default:
807  break;
808  }
809  break;
810  case PixelFormat24bppRGB:
811  switch (dst_format)
812  {
825  case PixelFormat32bppRGB:
831  case PixelFormat48bppRGB:
835  default:
836  break;
837  }
838  break;
839  case PixelFormat32bppRGB:
840  switch (dst_format)
841  {
854  case PixelFormat24bppRGB:
860  case PixelFormat48bppRGB:
864  default:
865  break;
866  }
867  break;
869  switch (dst_format)
870  {
883  case PixelFormat24bppRGB:
886  convert_32bppARGB_to_32bppPARGB(width, height, dst_bits, dst_stride, src_bits, src_stride);
887  return Ok;
888  case PixelFormat48bppRGB:
892  default:
893  break;
894  }
895  break;
897  switch (dst_format)
898  {
911  case PixelFormat24bppRGB:
913  case PixelFormat32bppRGB:
917  case PixelFormat48bppRGB:
921  default:
922  break;
923  }
924  break;
925  case PixelFormat48bppRGB:
926  switch (dst_format)
927  {
940  case PixelFormat24bppRGB:
942  case PixelFormat32bppRGB:
950  default:
951  break;
952  }
953  break;
955  switch (dst_format)
956  {
969  case PixelFormat24bppRGB:
971  case PixelFormat32bppRGB:
977  case PixelFormat48bppRGB:
979  default:
980  break;
981  }
982  break;
984  switch (dst_format)
985  {
998  case PixelFormat24bppRGB:
1000  case PixelFormat32bppRGB:
1002  case PixelFormat32bppARGB:
1004  case PixelFormat32bppPARGB:
1006  case PixelFormat48bppRGB:
1008  case PixelFormat64bppARGB:
1010  default:
1011  break;
1012  }
1013  break;
1014  default:
1015  break;
1016  }
1017 
1018 #undef convert_indexed_to_rgb
1019 #undef convert_rgb_to_rgb
1020 
1021  return NotImplemented;
1022 }
static void setpixel_32bppARGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:453
GLint GLint GLsizei width
Definition: gl.h:1546
#define PIXELFORMATBPP(x)
Definition: image.c:45
static const char * dst_format
Definition: dib.c:1133
static void setpixel_32bppPARGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:459
static void getpixel_64bppPARGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:274
#define convert_rgb_to_rgb(getpixel_function, setpixel_function)
#define PixelFormat1bppIndexed
static void setpixel_1bppIndexed(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x, ColorPalette *palette)
Definition: image.c:393
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define PixelFormat32bppRGB
#define PixelFormat16bppARGB1555
int32_t INT
Definition: typedefs.h:56
static void getpixel_16bppRGB565(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:192
static void getpixel_32bppRGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:224
void convert_32bppARGB_to_32bppPARGB(UINT width, UINT height, BYTE *dst_bits, INT dst_stride, const BYTE *src_bits, INT src_stride)
Definition: gdiplus.c:435
static void setpixel_16bppARGB1555(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:430
static void getpixel_16bppRGB555(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:182
static void getpixel_24bppRGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:215
#define PixelFormat8bppIndexed
#define PixelFormat4bppIndexed
#define convert_rgb_to_indexed(getpixel_function, setpixel_function)
static void getpixel_16bppARGB1555(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:202
#define PixelFormat16bppRGB555
static void getpixel_32bppARGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:233
static void setpixel_16bppRGB565(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:422
static void getpixel_64bppARGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:265
#define PixelFormat64bppARGB
static void setpixel_32bppRGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:447
static void getpixel_1bppIndexed(BYTE *index, const BYTE *row, UINT x)
Definition: image.c:157
#define convert_indexed_to_rgb(getpixel_function, setpixel_function)
static void getpixel_48bppRGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:256
#define PixelFormat64bppPARGB
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define PixelFormat24bppRGB
static void setpixel_16bppGrayScale(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:408
unsigned int UINT
Definition: ndis.h:50
static void setpixel_16bppRGB555(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:414
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static void setpixel_64bppARGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:476
static void getpixel_32bppPARGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:242
static void getpixel_4bppIndexed(BYTE *index, const BYTE *row, UINT x)
Definition: image.c:162
static void setpixel_8bppIndexed(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x, ColorPalette *palette)
Definition: image.c:386
static void setpixel_48bppRGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:468
#define PixelFormat32bppPARGB
#define PixelFormat16bppRGB565
static void setpixel_24bppRGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:439
#define PixelFormat16bppGrayScale
static void getpixel_8bppIndexed(BYTE *index, const BYTE *row, UINT x)
Definition: image.c:170
#define PixelFormat48bppRGB
#define PixelFormat32bppARGB
static void getpixel_16bppGrayScale(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:175

Referenced by GdipBitmapLockBits(), GdipBitmapUnlockBits(), GdipCloneBitmapArea(), GdipCreateHBITMAPFromBitmap(), and GdipDrawImagePointsRect().

◆ create_optimal_palette()

static GpStatus create_optimal_palette ( ColorPalette palette,
INT  desired,
BOOL  transparent,
GpBitmap bitmap 
)
static

Definition at line 5645 of file image.c.

5647 {
5648  GpStatus status;
5649  BitmapData data;
5650  HRESULT hr;
5652  IWICPalette *wic_palette;
5653 
5654  if (!bitmap) return InvalidParameter;
5655  if (palette->Count < desired) return GenericError;
5656 
5658  if (status != Ok) return status;
5659 
5660  hr = WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory);
5661  if (hr != S_OK)
5662  {
5664  return hresult_to_status(hr);
5665  }
5666 
5667  hr = IWICImagingFactory_CreatePalette(factory, &wic_palette);
5668  if (hr == S_OK)
5669  {
5670  IWICBitmap *bitmap;
5671 
5672  /* PixelFormat24bppRGB actually stores the bitmap bits as BGR. */
5673  hr = IWICImagingFactory_CreateBitmapFromMemory(factory, data.Width, data.Height,
5674  &GUID_WICPixelFormat24bppBGR, data.Stride, data.Stride * data.Width, data.Scan0, &bitmap);
5675  if (hr == S_OK)
5676  {
5677  hr = IWICPalette_InitializeFromBitmap(wic_palette, (IWICBitmapSource *)bitmap, desired, transparent);
5678  if (hr == S_OK)
5679  {
5680  palette->Flags = 0;
5681  IWICPalette_GetColorCount(wic_palette, &palette->Count);
5682  IWICPalette_GetColors(wic_palette, palette->Count, palette->Entries, &palette->Count);
5683  }
5684 
5685  IWICBitmap_Release(bitmap);
5686  }
5687 
5688  IWICPalette_Release(wic_palette);
5689  }
5690 
5691  IWICImagingFactory_Release(factory);
5693 
5694  return hresult_to_status(hr);
5695 }
GpStatus hresult_to_status(HRESULT res)
Definition: gdiplus.c:312
HRESULT hr
Definition: shlfolder.c:183
int desired
Definition: jpeglib.h:1116
HRESULT WINAPI WICCreateImagingFactory_Proxy(UINT, IWICImagingFactory **)
Definition: proxy.c:651
Definition: main.c:438
GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap *bitmap, GDIPCONST GpRect *rect, UINT flags, PixelFormat format, BitmapData *lockeddata)
Definition: image.c:1030
smooth NULL
Definition: ftsmooth.c:416
Definition: uimain.c:88
GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap *bitmap, BitmapData *lockeddata)
Definition: image.c:1176
LONG HRESULT
Definition: typedefs.h:77
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static HPALETTE palette
Definition: clipboard.c:1345
Status
Definition: gdiplustypes.h:24
#define S_OK
Definition: intsafe.h:59
#define PixelFormat24bppRGB
static ClassFactoryImpl factory
Definition: ole_server.c:234
static HBITMAP bitmap
Definition: clipboard.c:1344
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by GdipInitializePalette().

◆ create_prop()

static PropertyItem* create_prop ( PROPID  propid,
PROPVARIANT *  value 
)
static

Definition at line 3371 of file image.c.

3372 {
3373  PropertyItem *item = NULL;
3374  UINT item_size = propvariant_size(value);
3375 
3376  if (item_size)
3377  {
3378  item_size += sizeof(*item);
3379  item = heap_alloc_zero(item_size);
3380  if (propvariant_to_item(value, item, item_size, propid) != Ok)
3381  {
3382  heap_free(item);
3383  item = NULL;
3384  }
3385  }
3386 
3387  return item;
3388 }
static GpStatus propvariant_to_item(PROPVARIANT *value, PropertyItem *item, UINT size, PROPID id)
Definition: image.c:2571
smooth NULL
Definition: ftsmooth.c:416
static ATOM item
Definition: dde.c:856
unsigned int UINT
Definition: ndis.h:50
static UINT propvariant_size(PROPVARIANT *value)
Definition: image.c:2454
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by png_metadata_reader().

◆ decode_frame_wic()

static GpStatus decode_frame_wic ( IWICBitmapDecoder decoder,
BOOL  force_conversion,
UINT  active_frame,
metadata_reader_func  metadata_reader,
GpImage **  image 
)
static

Definition at line 3584 of file image.c.

3586 {
3587  GpStatus status=Ok;
3588  GpBitmap *bitmap;
3589  HRESULT hr;
3590  IWICBitmapFrameDecode *frame;
3592  IWICMetadataBlockReader *block_reader;
3597  int i;
3598  UINT width, height, frame_count;
3599  BitmapData lockeddata;
3600  WICRect wrc;
3601 
3602  TRACE("%p,%u,%p\n", decoder, active_frame, image);
3603 
3604  IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
3605  hr = IWICBitmapDecoder_GetFrame(decoder, active_frame, &frame);
3606  if (SUCCEEDED(hr)) /* got frame */
3607  {
3608  hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &wic_format);
3609 
3610  if (SUCCEEDED(hr))
3611  {
3612  if (!force_conversion)
3613  {
3614  for (i=0; pixel_formats[i].wic_format; i++)
3615  {
3617  {
3618  source = (IWICBitmapSource*)frame;
3619  IWICBitmapSource_AddRef(source);
3620  gdip_format = pixel_formats[i].gdip_format;
3621  palette_type = pixel_formats[i].palette_type;
3622  break;
3623  }
3624  }
3625  }
3626  if (!source)
3627  {
3628  /* unknown format; fall back on 32bppARGB */
3629  hr = WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGRA, (IWICBitmapSource*)frame, &source);
3631  }
3632  TRACE("%s => %#x\n", wine_dbgstr_guid(&wic_format), gdip_format);
3633  }
3634 
3635  if (SUCCEEDED(hr)) /* got source */
3636  {
3637  hr = IWICBitmapSource_GetSize(source, &width, &height);
3638 
3639  if (SUCCEEDED(hr))
3641  NULL, &bitmap);
3642 
3643  if (SUCCEEDED(hr) && status == Ok) /* created bitmap */
3644  {
3646  gdip_format, &lockeddata);
3647  if (status == Ok) /* locked bitmap */
3648  {
3649  wrc.X = 0;
3650  wrc.Width = width;
3651  wrc.Height = 1;
3652  for (i=0; i<height; i++)
3653  {
3654  wrc.Y = i;
3655  hr = IWICBitmapSource_CopyPixels(source, &wrc, abs(lockeddata.Stride),
3656  abs(lockeddata.Stride), (BYTE*)lockeddata.Scan0+lockeddata.Stride*i);
3657  if (FAILED(hr)) break;
3658  }
3659 
3660  GdipBitmapUnlockBits(bitmap, &lockeddata);
3661  }
3662 
3663  if (SUCCEEDED(hr) && status == Ok)
3664  *image = &bitmap->image;
3665  else
3666  {
3667  *image = NULL;
3668  GdipDisposeImage(&bitmap->image);
3669  }
3670 
3671  if (SUCCEEDED(hr) && status == Ok)
3672  {
3673  double dpix, dpiy;
3674  hr = IWICBitmapSource_GetResolution(source, &dpix, &dpiy);
3675  if (SUCCEEDED(hr))
3676  {
3677  bitmap->image.xres = dpix;
3678  bitmap->image.yres = dpiy;
3679  }
3680  hr = S_OK;
3681  }
3682  }
3683 
3684  IWICBitmapSource_Release(source);
3685  }
3686 
3687  if (SUCCEEDED(hr)) {
3688  bitmap->metadata_reader = NULL;
3689 
3690  if (metadata_reader)
3691  metadata_reader(bitmap, decoder, active_frame);
3692  else if (IWICBitmapFrameDecode_QueryInterface(frame, &IID_IWICMetadataBlockReader, (void **)&block_reader) == S_OK)
3693  {
3694  UINT block_count = 0;
3695  if (IWICMetadataBlockReader_GetCount(block_reader, &block_count) == S_OK && block_count)
3696  IWICMetadataBlockReader_GetReaderByIndex(block_reader, 0, &bitmap->metadata_reader);
3697  IWICMetadataBlockReader_Release(block_reader);
3698  }
3699 
3700  palette = get_palette(frame, palette_type);
3701  IWICBitmapFrameDecode_Release(frame);
3702  }
3703  }
3704 
3705  if (FAILED(hr) && status == Ok) status = hresult_to_status(hr);
3706 
3707  if (status == Ok)
3708  {
3709  /* Native GDI+ used to be smarter, but since Win7 it just sets these flags. */
3711  if (IsEqualGUID(&wic_format, &GUID_WICPixelFormat2bppGray) ||
3712  IsEqualGUID(&wic_format, &GUID_WICPixelFormat4bppGray) ||
3713  IsEqualGUID(&wic_format, &GUID_WICPixelFormat8bppGray) ||
3714  IsEqualGUID(&wic_format, &GUID_WICPixelFormat16bppGray))
3715  bitmap->image.flags |= ImageFlagsColorSpaceGRAY;
3716  else
3717  bitmap->image.flags |= ImageFlagsColorSpaceRGB;
3718  bitmap->image.frame_count = frame_count;
3719  bitmap->image.current_frame = active_frame;
3720  bitmap->image.decoder = decoder;
3721  IWICBitmapDecoder_AddRef(decoder);
3722  if (palette)
3723  {
3724  heap_free(bitmap->image.palette);
3725  bitmap->image.palette = palette;
3726  }
3727  else
3728  {
3729  if (IsEqualGUID(&wic_format, &GUID_WICPixelFormatBlackWhite))
3730  bitmap->image.palette->Flags = 0;
3731  }
3732  TRACE("=> %p\n", *image);
3733  }
3734 
3735  return status;
3736 }
#define abs(i)
Definition: fconv.c:206
GLint GLint GLsizei width
Definition: gl.h:1546
GpStatus hresult_to_status(HRESULT res)
Definition: gdiplus.c:312
static const struct @399 pixel_formats[]
HRESULT hr
Definition: shlfolder.c:183
const char * wine_dbgstr_guid(const GUID *guid)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap *bitmap, GDIPCONST GpRect *rect, UINT flags, PixelFormat format, BitmapData *lockeddata)
Definition: image.c:1030
smooth NULL
Definition: ftsmooth.c:416
GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE *scan0, GpBitmap **bitmap)
Definition: image.c:1760
INT Height
Definition: wincodec.idl:239
Definition: uimain.c:88
GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap *bitmap, BitmapData *lockeddata)
Definition: image.c:1176
#define TRACE(s)
Definition: solgame.cpp:4
const WICPixelFormatGUID * wic_format
Definition: image.c:50
WICBitmapPaletteType
Definition: wincodec.idl:90
LONG HRESULT
Definition: typedefs.h:77
INT PixelFormat
unsigned char BYTE
Definition: mem.h:68
static HPALETTE palette
Definition: clipboard.c:1345
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2107
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
Status
Definition: gdiplustypes.h:24
#define S_OK
Definition: intsafe.h:59
WICBitmapPaletteType palette_type
Definition: image.c:53
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
INT Width
Definition: wincodec.idl:238
static ColorPalette * get_palette(IWICBitmapFrameDecode *frame, WICBitmapPaletteType palette_type)
Definition: image.c:74
HRESULT WINAPI WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat, IWICBitmapSource *pISrc, IWICBitmapSource **ppIDst)
Definition: info.c:2474
static HBITMAP bitmap
Definition: clipboard.c:1344
static SERVICE_STATUS status
Definition: service.c:31
#define PixelFormat32bppARGB
#define SUCCEEDED(hr)
Definition: intsafe.h:57
PixelFormat gdip_format
Definition: image.c:51
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
Definition: ps.c:97

Referenced by decode_image_gif(), decode_image_png(), decode_image_wic(), and select_frame_wic().

◆ decode_image_bmp()

static GpStatus decode_image_bmp ( IStream stream,
GpImage **  image 
)
static

Definition at line 3935 of file image.c.

3936 {
3937  GpStatus status;
3938  GpBitmap* bitmap;
3939 
3940  status = decode_image_wic(stream, &GUID_ContainerFormatBmp, NULL, image);
3941 
3942  bitmap = (GpBitmap*)*image;
3943 
3944  if (status == Ok && bitmap->format == PixelFormat32bppARGB)
3945  {
3946  /* WIC supports bmp files with alpha, but gdiplus does not */
3947  bitmap->format = PixelFormat32bppRGB;
3948  }
3949 
3950  return status;
3951 }
static GpStatus decode_image_wic(IStream *stream, REFGUID container, metadata_reader_func metadata_reader, GpImage **image)
Definition: image.c:3738
#define PixelFormat32bppRGB
smooth NULL
Definition: ftsmooth.c:416
Definition: uimain.c:88
Definition: parse.h:22
Status
Definition: gdiplustypes.h:24
static HBITMAP bitmap
Definition: clipboard.c:1344
static SERVICE_STATUS status
Definition: service.c:31
#define PixelFormat32bppARGB
Definition: ps.c:97

◆ decode_image_emf()

static GpStatus decode_image_emf ( IStream stream,
GpImage **  image 
)
static

Definition at line 4186 of file image.c.

4187 {
4189  GpStatus status;
4190 
4191  TRACE("%p %p\n", stream, image);
4192 
4193  if (!stream || !image)
4194  return InvalidParameter;
4195 
4197  if (status != Ok)
4198  {
4199  TRACE("Could not load metafile\n");
4200  return status;
4201  }
4202 
4203  *image = (GpImage *)metafile;
4204  TRACE("<-- %p\n", *image);
4205 
4206  return Ok;
4207 }
static const unsigned char metafile[]
Definition: olepicture.c:138
#define TRACE(s)
Definition: solgame.cpp:4
static GpStatus load_emf(IStream *stream, GpMetafile **metafile)
Definition: image.c:4147
Definition: parse.h:22
Status
Definition: gdiplustypes.h:24
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ decode_image_gif()

static GpStatus decode_image_gif ( IStream stream,
GpImage **  image 
)
static

Definition at line 4034 of file image.c.

4035 {
4036  IWICBitmapDecoder *decoder;
4037  UINT frame_count;
4038  GpStatus status;
4039  HRESULT hr;
4040 
4041  status = initialize_decoder_wic(stream, &GUID_ContainerFormatGif, &decoder);
4042  if(status != Ok)
4043  return status;
4044 
4045  hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
4046  if(FAILED(hr))
4047  return hresult_to_status(hr);
4048 
4049  status = decode_frame_wic(decoder, frame_count > 1, 0, gif_metadata_reader, image);
4050  IWICBitmapDecoder_Release(decoder);
4051  if(status != Ok)
4052  return status;
4053 
4054  if(frame_count > 1) {
4055  heap_free((*image)->palette);
4056  (*image)->palette = NULL;
4057  }
4058  return Ok;
4059 }
GpStatus hresult_to_status(HRESULT res)
Definition: gdiplus.c:312
HRESULT hr
Definition: shlfolder.c:183
static void gif_metadata_reader(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UINT active_frame)
Definition: image.c:3246
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
Definition: parse.h:22
Status
Definition: gdiplustypes.h:24
static GpStatus decode_frame_wic(IWICBitmapDecoder *decoder, BOOL force_conversion, UINT active_frame, metadata_reader_func metadata_reader, GpImage **image)
Definition: image.c:3584
unsigned int UINT
Definition: ndis.h:50
static GpStatus initialize_decoder_wic(IStream *stream, REFGUID container, IWICBitmapDecoder **decoder)
Definition: image.c:3564
static SERVICE_STATUS status
Definition: service.c:31
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
Definition: ps.c:97

◆ decode_image_icon()

static GpStatus decode_image_icon ( IStream stream,
GpImage **  image 
)
static

Definition at line 3930 of file image.c.

3931 {
3932  return decode_image_wic(stream, &GUID_ContainerFormatIco, NULL, image);
3933 }
static GpStatus decode_image_wic(IStream *stream, REFGUID container, metadata_reader_func metadata_reader, GpImage **image)
Definition: image.c:3738
smooth NULL
Definition: ftsmooth.c:416
Definition: parse.h:22

◆ decode_image_jpeg()

static GpStatus decode_image_jpeg ( IStream stream,
GpImage **  image 
)
static

Definition at line 3953 of file image.c.

3954 {
3955  return decode_image_wic(stream, &GUID_ContainerFormatJpeg, NULL, image);
3956 }
static GpStatus decode_image_wic(IStream *stream, REFGUID container, metadata_reader_func metadata_reader, GpImage **image)
Definition: image.c:3738
smooth NULL
Definition: ftsmooth.c:416
Definition: parse.h:22

◆ decode_image_png()

static GpStatus decode_image_png ( IStream stream,
GpImage **  image 
)
static

Definition at line 3991 of file image.c.

3992 {
3993  IWICBitmapDecoder *decoder;
3994  IWICBitmapFrameDecode *frame;
3995  GpStatus status;
3996  HRESULT hr;
3997  GUID format;
3998  BOOL force_conversion = FALSE;
3999 
4000  status = initialize_decoder_wic(stream, &GUID_ContainerFormatPng, &decoder);
4001  if (status != Ok)
4002  return status;
4003 
4004  hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
4005  if (hr == S_OK)
4006  {
4007  hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format);
4008  if (hr == S_OK)
4009  {
4010  if (IsEqualGUID(&format, &GUID_WICPixelFormat8bppGray))
4011  force_conversion = TRUE;
4012  else if ((IsEqualGUID(&format, &GUID_WICPixelFormat8bppIndexed) ||
4013  IsEqualGUID(&format, &GUID_WICPixelFormat4bppIndexed) ||
4014  IsEqualGUID(&format, &GUID_WICPixelFormat2bppIndexed) ||
4015  IsEqualGUID(&format, &GUID_WICPixelFormat1bppIndexed) ||
4016  IsEqualGUID(&format, &GUID_WICPixelFormat24bppBGR)) &&
4018  force_conversion = TRUE;
4019 
4020  status = decode_frame_wic(decoder, force_conversion, 0, png_metadata_reader, image);
4021  }
4022  else
4024 
4025  IWICBitmapFrameDecode_Release(frame);
4026  }
4027  else
4029 
4030  IWICBitmapDecoder_Release(decoder);
4031  return status;
4032 }
GpStatus hresult_to_status(HRESULT res)
Definition: gdiplus.c:312
#define TRUE
Definition: types.h:120
static void png_metadata_reader(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UINT active_frame)
Definition: image.c:3413
HRESULT hr
Definition: shlfolder.c:183
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL has_png_transparency_chunk(IStream *pIStream)
Definition: image.c:3958
LONG HRESULT
Definition: typedefs.h:77
Definition: parse.h:22
Status
Definition: gdiplustypes.h:24
#define S_OK
Definition: intsafe.h:59
static GpStatus decode_frame_wic(IWICBitmapDecoder *decoder, BOOL force_conversion, UINT active_frame, metadata_reader_func metadata_reader, GpImage **image)
Definition: image.c:3584
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
static GpStatus initialize_decoder_wic(IStream *stream, REFGUID container, IWICBitmapDecoder **decoder)
Definition: image.c:3564
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ decode_image_tiff()

static GpStatus decode_image_tiff ( IStream stream,
GpImage **  image 
)
static

Definition at line 4061 of file image.c.

4062 {
4063  return decode_image_wic(stream, &GUID_ContainerFormatTiff, NULL, image);
4064 }
static GpStatus decode_image_wic(IStream *stream, REFGUID container, metadata_reader_func metadata_reader, GpImage **image)
Definition: image.c:3738
smooth NULL
Definition: ftsmooth.c:416
Definition: parse.h:22

◆ decode_image_wic()

static GpStatus decode_image_wic ( IStream stream,
REFGUID  container,
metadata_reader_func  metadata_reader,
GpImage **  image 
)
static

Definition at line 3738 of file image.c.

3740 {
3741  IWICBitmapDecoder *decoder;
3742  GpStatus status;
3743 
3745  if(status != Ok)
3746  return status;
3747 
3748  status = decode_frame_wic(decoder, FALSE, 0, metadata_reader, image);
3749  IWICBitmapDecoder_Release(decoder);
3750  return status;
3751 }
Definition: parse.h:22
Status
Definition: gdiplustypes.h:24
static GpStatus decode_frame_wic(IWICBitmapDecoder *decoder, BOOL force_conversion, UINT active_frame, metadata_reader_func metadata_reader, GpImage **image)
Definition: image.c:3584
static GpStatus initialize_decoder_wic(IStream *stream, REFGUID container, IWICBitmapDecoder **decoder)
Definition: image.c:3564
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by decode_image_bmp(), decode_image_icon(), decode_image_jpeg(), and decode_image_tiff().

◆ decode_image_wmf()

static GpStatus decode_image_wmf ( IStream stream,
GpImage **  image 
)
static

Definition at line 4124 of file image.c.

4125 {
4127  GpStatus status;
4128 
4129  TRACE("%p %p\n", stream, image);
4130 
4131  if (!stream || !image)
4132  return InvalidParameter;
4133 
4135  if (status != Ok)
4136  {
4137  TRACE("Could not load metafile\n");
4138  return status;
4139  }
4140 
4141  *image = (GpImage *)metafile;
4142  TRACE("<-- %p\n", *image);
4143 
4144  return Ok;
4145 }
static const unsigned char metafile[]
Definition: olepicture.c:138
#define TRACE(s)
Definition: solgame.cpp:4
static GpStatus load_wmf(IStream *stream, GpMetafile **metafile)
Definition: image.c:4066
Definition: parse.h:22
Status
Definition: gdiplustypes.h:24
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ encode_image_BMP()

static GpStatus encode_image_BMP ( GpImage image,
IStream stream,
GDIPCONST EncoderParameters params 
)
static

Definition at line 4590 of file image.c.

4592 {
4593  return encode_image_wic(image, stream, &GUID_ContainerFormatBmp, params);
4594 }
GLenum const GLfloat * params
Definition: glext.h:5645
Definition: parse.h:22
static GpStatus encode_image_wic(GpImage *image, IStream *stream, REFGUID container, GDIPCONST EncoderParameters *params)
Definition: image.c:4455

◆ encode_image_gif()

static GpStatus encode_image_gif ( GpImage image,
IStream stream,
GDIPCONST EncoderParameters params 
)
static

Definition at line 4614 of file image.c.

4616 {
4617  return encode_image_wic(image, stream, &GUID_ContainerFormatGif, params);
4618 }
GLenum const GLfloat * params
Definition: glext.h:5645
Definition: parse.h:22
static GpStatus encode_image_wic(GpImage *image, IStream *stream, REFGUID container, GDIPCONST EncoderParameters *params)
Definition: image.c:4455

◆ encode_image_jpeg()

static GpStatus encode_image_jpeg ( GpImage image,
IStream stream,
GDIPCONST EncoderParameters params 
)
static

Definition at line 4608 of file image.c.

4610 {
4611  return encode_image_wic(image, stream, &GUID_ContainerFormatJpeg, params);
4612 }
GLenum const GLfloat * params
Definition: glext.h:5645
Definition: parse.h:22
static GpStatus encode_image_wic(GpImage *image, IStream *stream, REFGUID container, GDIPCONST EncoderParameters *params)
Definition: image.c:4455

◆ encode_image_png()

GpStatus encode_image_png ( GpImage image,
IStream stream,
GDIPCONST EncoderParameters params 
)

Definition at line 4602 of file image.c.

4604 {
4605  return encode_image_wic(image, stream, &GUID_ContainerFormatPng, params);
4606 }
GLenum const GLfloat * params
Definition: glext.h:5645
Definition: parse.h:22
static GpStatus encode_image_wic(GpImage *image, IStream *stream, REFGUID container, GDIPCONST EncoderParameters *params)
Definition: image.c:4455

Referenced by METAFILE_CreateCompressedImageStream().

◆ encode_image_tiff()

static GpStatus encode_image_tiff ( GpImage image,
IStream stream,
GDIPCONST EncoderParameters params 
)
static

Definition at line 4596 of file image.c.

4598 {
4599  return encode_image_wic(image, stream, &GUID_ContainerFormatTiff, params);
4600 }
GLenum const GLfloat * params
Definition: glext.h:5645
Definition: parse.h:22
static GpStatus encode_image_wic(GpImage *image, IStream *stream, REFGUID container, GDIPCONST EncoderParameters *params)
Definition: image.c:4455

◆ encode_image_wic()

static GpStatus encode_image_wic ( GpImage image,
IStream stream,
REFGUID  container,
GDIPCONST EncoderParameters params 
)
static

Definition at line 4455 of file image.c.

4457 {
4458  GpStatus stat;
4459  GpBitmap *bitmap;
4461  IWICBitmapEncoder *encoder;
4462  IWICBitmapFrameEncode *frameencode;
4463  IPropertyBag2 *encoderoptions;
4464  HRESULT hr;
4465  UINT width, height;
4466  PixelFormat gdipformat=0;
4467  const WICPixelFormatGUID *desired_wicformat;
4468  WICPixelFormatGUID wicformat;
4469  GpRect rc;
4470  BitmapData lockeddata;
4471  UINT i;
4472 
4473  if (image->type != ImageTypeBitmap)
4474  return GenericError;
4475 
4476  bitmap = (GpBitmap*)image;
4477 
4480 
4481  rc.X = 0;
4482  rc.Y = 0;
4483  rc.Width = width;
4484  rc.Height = height;
4485 
4486  hr = WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory);
4487  if (FAILED(hr))
4488  return hresult_to_status(hr);
4489  hr = IWICImagingFactory_CreateEncoder(factory, container, NULL, &encoder);
4490  IWICImagingFactory_Release(factory);
4491  if (FAILED(hr))
4492  return hresult_to_status(hr);
4493 
4494  hr = IWICBitmapEncoder_Initialize(encoder, stream, WICBitmapEncoderNoCache);
4495 
4496  if (SUCCEEDED(hr))
4497  {
4498  hr = IWICBitmapEncoder_CreateNewFrame(encoder, &frameencode, &encoderoptions);
4499  }
4500 
4501  if (SUCCEEDED(hr)) /* created frame */
4502  {
4503  hr = IWICBitmapFrameEncode_Initialize(frameencode, encoderoptions);
4504 
4505  if (SUCCEEDED(hr))
4506  hr = IWICBitmapFrameEncode_SetSize(frameencode, width, height);
4507 
4508  if (SUCCEEDED(hr))
4509  hr = IWICBitmapFrameEncode_SetResolution(frameencode, image->xres, image->yres);
4510 
4511  if (SUCCEEDED(hr))
4512  {
4513  for (i=0; pixel_formats[i].wic_format; i++)
4514  {
4515  if (pixel_formats[i].gdip_format == bitmap->format)
4516  {
4517  desired_wicformat = pixel_formats[i].wic_format;
4518  gdipformat = bitmap->format;
4519  break;
4520  }
4521  }
4522  if (!gdipformat)
4523  {
4524  desired_wicformat = &GUID_WICPixelFormat32bppBGRA;
4525  gdipformat = PixelFormat32bppARGB;
4526  }
4527 
4528  memcpy(&wicformat, desired_wicformat, sizeof(GUID));
4529  hr = IWICBitmapFrameEncode_SetPixelFormat(frameencode, &wicformat);
4530  }
4531 
4532  if (SUCCEEDED(hr) && !IsEqualGUID(desired_wicformat, &wicformat))
4533  {
4534  /* Encoder doesn't support this bitmap's format. */
4535  gdipformat = 0;
4536  for (i=0; pixel_formats[i].wic_format; i++)
4537  {
4538  if (IsEqualGUID(&wicformat, pixel_formats[i].wic_format))
4539  {
4540  gdipformat = pixel_formats[i].gdip_format;
4541  break;
4542  }
4543  }
4544  if (!gdipformat)
4545  {
4546  ERR("Cannot support encoder format %s\n", debugstr_guid(&wicformat));
4547  hr = E_FAIL;
4548  }
4549  }
4550 
4551  if (SUCCEEDED(hr))
4552  {
4553  stat = GdipBitmapLockBits(bitmap, &rc, ImageLockModeRead, gdipformat,
4554  &lockeddata);
4555 
4556  if (stat == Ok)
4557  {
4558  UINT row_size = (lockeddata.Width * PIXELFORMATBPP(gdipformat) + 7)/8;
4559  BYTE *row;
4560 
4561  /* write one row at a time in case stride is negative */
4562  row = lockeddata.Scan0;
4563  for (i=0; i<lockeddata.Height; i++)
4564  {
4565  hr = IWICBitmapFrameEncode_WritePixels(frameencode, 1, row_size, row_size, row);
4566  if (FAILED(hr)) break;
4567  row += lockeddata.Stride;
4568  }
4569 
4570  GdipBitmapUnlockBits(bitmap, &lockeddata);
4571  }
4572  else
4573  hr = E_FAIL;
4574  }
4575 
4576  if (SUCCEEDED(hr))
4577  hr = IWICBitmapFrameEncode_Commit(frameencode);
4578 
4579  IWICBitmapFrameEncode_Release(frameencode);
4580  IPropertyBag2_Release(encoderoptions);
4581  }
4582 
4583  if (SUCCEEDED(hr))
4584  hr = IWICBitmapEncoder_Commit(encoder);
4585 
4586  IWICBitmapEncoder_Release(encoder);
4587  return hresult_to_status(hr);
4588 }
GLint GLint GLsizei width
Definition: gl.h:1546
GpStatus hresult_to_status(HRESULT res)
Definition: gdiplus.c:312
static const struct @399 pixel_formats[]
#define PIXELFORMATBPP(x)
Definition: image.c:45
HRESULT hr
Definition: shlfolder.c:183
GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width)
Definition: image.c:2342
INT Width
Definition: gdiplustypes.h:271
HRESULT WINAPI WICCreateImagingFactory_Proxy(UINT, IWICImagingFactory **)
Definition: proxy.c:651
#define E_FAIL
Definition: ddrawi.h:102
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height)
Definition: image.c:2239
Definition: main.c:438
GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap *bitmap, GDIPCONST GpRect *rect, UINT flags, PixelFormat format, BitmapData *lockeddata)
Definition: image.c:1030
INT X
Definition: gdiplustypes.h:269
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
Definition: uimain.c:88
GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap *bitmap, BitmapData *lockeddata)
Definition: image.c:1176
const WICPixelFormatGUID * wic_format
Definition: image.c:50
LONG HRESULT
Definition: typedefs.h:77
INT PixelFormat
Definition: parse.h:22
Definition: stat.h:55
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
INT Height
Definition: gdiplustypes.h:272
static ClassFactoryImpl factory
Definition: ole_server.c:234
static HBITMAP bitmap
Definition: clipboard.c:1344
INT Y
Definition: gdiplustypes.h:270
#define PixelFormat32bppARGB
#define SUCCEEDED(hr)
Definition: intsafe.h:57
PixelFormat gdip_format
Definition: image.c:51
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78

Referenced by encode_image_BMP(), encode_image_gif(), encode_image_jpeg(), encode_image_png(), and encode_image_tiff().

◆ free_image_data()

static GpStatus free_image_data ( GpImage image)
static

Definition at line 2078 of file image.c.

2079 {
2080  if(!image)
2081  return InvalidParameter;
2082 
2083  if (image->type == ImageTypeBitmap)
2084  {
2085  heap_free(((GpBitmap*)image)->bitmapbits);
2086  heap_free(((GpBitmap*)image)->own_bits);
2087  DeleteDC(((GpBitmap*)image)->hdc);
2089  if (((GpBitmap*)image)->metadata_reader)
2090  IWICMetadataReader_Release(((GpBitmap*)image)->metadata_reader);
2091  heap_free(((GpBitmap*)image)->prop_item);
2092  }
2093  else if (image->type == ImageTypeMetafile)
2095  else
2096  {
2097  WARN("invalid image: %p\n", image);
2098  return ObjectBusy;
2099  }
2100  if (image->decoder)
2101  IWICBitmapDecoder_Release(image->decoder);
2102  heap_free(image->palette);
2103 
2104  return Ok;
2105 }
#define WARN(fmt,...)
Definition: debug.h:111
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC hdc
Definition: main.c:9
BOOL WINAPI DeleteDC(_In_ HDC)
static HBITMAP hbitmap
void METAFILE_Free(GpMetafile *metafile) DECLSPEC_HIDDEN
Definition: metafile.c:590
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by GdipDisposeImage(), and select_frame_wic().

◆ GdipBitmapApplyEffect()

GpStatus WINGDIPAPI GdipBitmapApplyEffect ( GpBitmap bitmap,
CGpEffect effect,
RECT roi,
BOOL  useAuxData,
VOID **  auxData,
INT auxDataSize 
)

Definition at line 134 of file image.c.

136 {
137  FIXME("(%p %p %p %d %p %p): stub\n", bitmap, effect, roi, useAuxData, auxData, auxDataSize);
138  /*
139  * Note: According to Jose Roca's GDI+ docs, this function is not
140  * implemented in Windows's GDI+.
141  */
142  return NotImplemented;
143 }
#define FIXME(fmt,...)
Definition: debug.h:110
Definition: uimain.c:88

◆ GdipBitmapConvertFormat()

GpStatus WINGDIPAPI GdipBitmapConvertFormat ( GpBitmap bitmap,
PixelFormat  format,
DitherType  dithertype,
PaletteType  palettetype,
ColorPalette palette,
REAL  alphathreshold 
)

Definition at line 5501 of file image.c.

5503 {
5504  FIXME("(%p, 0x%08x, %d, %d, %p, %f): stub\n", bitmap, format, dithertype, palettetype, palette, alphathreshold);
5505  return NotImplemented;
5506 }
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define FIXME(fmt,...)
Definition: debug.h:110
Definition: uimain.c:88
static HPALETTE palette
Definition: clipboard.c:1345

◆ GdipBitmapCreateApplyEffect()

GpStatus WINGDIPAPI GdipBitmapCreateApplyEffect ( GpBitmap **  inputBitmaps,
INT  numInputs,
CGpEffect effect,
RECT roi,
RECT outputRect,
GpBitmap **  outputBitmap,
BOOL  useAuxData,
VOID **  auxData,
INT auxDataSize 
)

Definition at line 145 of file image.c.

148 {
149  FIXME("(%p %d %p %p %p %p %d %p %p): stub\n", inputBitmaps, numInputs, effect, roi, outputRect, outputBitmap, useAuxData, auxData, auxDataSize);
150  /*
151  * Note: According to Jose Roca's GDI+ docs, this function is not
152  * implemented in Windows's GDI+.
153  */
154  return NotImplemented;
155 }
#define FIXME(fmt,...)
Definition: debug.h:110

◆ GdipBitmapGetHistogram()

GpStatus WINGDIPAPI GdipBitmapGetHistogram ( GpBitmap bitmap,
HistogramFormat  format,
UINT  num_of_entries,
UINT ch0,
UINT ch1,
UINT ch2,
UINT ch3 
)

Definition at line 5561 of file image.c.

5563 {
5564  static void (* const set_histogram_point[])(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3) =
5565  {
5574  };
5575  UINT width, height, x, y;
5576 
5577  TRACE("(%p, %d, %u, %p, %p, %p, %p)\n", bitmap, format, num_of_entries,
5578  ch0, ch1, ch2, ch3);
5579 
5580  if (!bitmap || num_of_entries != 256)
5581  return InvalidParameter;
5582 
5583  /* Make sure passed channel pointers match requested format */
5584  switch (format)
5585  {
5586  case HistogramFormatARGB:
5587  case HistogramFormatPARGB:
5588  if (!ch0 || !ch1 || !ch2 || !ch3)
5589  return InvalidParameter;
5590  memset(ch0, 0, num_of_entries * sizeof(UINT));
5591  memset(ch1, 0, num_of_entries * sizeof(UINT));
5592  memset(ch2, 0, num_of_entries * sizeof(UINT));
5593  memset(ch3, 0, num_of_entries * sizeof(UINT));
5594  break;
5595  case HistogramFormatRGB:
5596  if (!ch0 || !ch1 || !ch2 || ch3)
5597  return InvalidParameter;
5598  memset(ch0, 0, num_of_entries * sizeof(UINT));
5599  memset(ch1, 0, num_of_entries * sizeof(UINT));
5600  memset(ch2, 0, num_of_entries * sizeof(UINT));
5601  break;
5602  case HistogramFormatGray:
5603  case HistogramFormatB:
5604  case HistogramFormatG:
5605  case HistogramFormatR:
5606  case HistogramFormatA:
5607  if (!ch0 || ch1 || ch2 || ch3)
5608  return InvalidParameter;
5609  memset(ch0, 0, num_of_entries * sizeof(UINT));
5610  break;
5611  default:
5612  WARN("Invalid histogram format requested, %d\n", format);
5613  return InvalidParameter;
5614  }
5615 
5616  GdipGetImageWidth(&bitmap->image, &width);
5617  GdipGetImageHeight(&bitmap->image, &height);
5618 
5619  for (y = 0; y < height; y++)
5620  for (x = 0; x < width; x++)
5621  {
5622  ARGB color;
5623 
5625  set_histogram_point[format](color, ch0, ch1, ch2, ch3);
5626  }
5627 
5628  return Ok;
5629 }
static void set_histogram_point_rgb(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
Definition: image.c:5526
GLint GLint GLsizei width
Definition: gl.h:1546
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width)
Definition: image.c:2342
#define WARN(fmt,...)
Definition: debug.h:111
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static void set_histogram_point_a(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
Definition: image.c:5553
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap *bitmap, INT x, INT y, ARGB *color)
Definition: image.c:288
GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height)
Definition: image.c:2239
GLuint color
Definition: glext.h:6243
Definition: uimain.c:88
#define TRACE(s)
Definition: solgame.cpp:4
static void set_histogram_point_b(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
Definition: image.c:5538
static void set_histogram_point_gray(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
Definition: image.c:5533
static void set_histogram_point_r(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
Definition: image.c:5548
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
unsigned int UINT
Definition: ndis.h:50
static void set_histogram_point_g(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
Definition: image.c:5543
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define memset(x, y, z)
Definition: compat.h:39
static void set_histogram_point_pargb(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
Definition: image.c:5516
static void set_histogram_point_argb(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
Definition: image.c:5508
DWORD ARGB

◆ GdipBitmapGetHistogramSize()

GpStatus WINGDIPAPI GdipBitmapGetHistogramSize ( HistogramFormat  format,
UINT num_of_entries 
)

Definition at line 5634 of file image.c.

5635 {
5636  TRACE("(%d, %p)\n", format, num_of_entries);
5637 
5638  if (!num_of_entries)
5639  return InvalidParameter;
5640 
5641  *num_of_entries = 256;
5642  return Ok;
5643 }
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define TRACE(s)
Definition: solgame.cpp:4

◆ GdipBitmapGetPixel()

GpStatus WINGDIPAPI GdipBitmapGetPixel ( GpBitmap bitmap,
INT  x,
INT  y,
ARGB color 
)

Definition at line 288 of file image.c.

290 {
291  BYTE r, g, b, a;
292  BYTE index;
293  BYTE *row;
294 
295  if(!bitmap || !color ||
296  x < 0 || y < 0 || x >= bitmap->width || y >= bitmap->height)
297  return InvalidParameter;
298 
299  row = bitmap->bits+bitmap->stride*y;
300 
301  switch (bitmap->format)
302  {
305  break;
308  break;
311  break;
314  break;
316  getpixel_16bppRGB555(&r,&g,&b,&a,row,x);
317  break;
319  getpixel_16bppRGB565(&r,&g,&b,&a,row,x);
320  break;
323  break;
324  case PixelFormat24bppRGB:
325  getpixel_24bppRGB(&r,&g,&b,&a,row,x);
326  break;
327  case PixelFormat32bppRGB:
328  getpixel_32bppRGB(&r,&g,&b,&a,row,x);
329  break;
331  getpixel_32bppARGB(&r,&g,&b,&a,row,x);
332  break;
334  getpixel_32bppPARGB(&r,&g,&b,&a,row,x);
335  break;
336  case PixelFormat48bppRGB:
337  getpixel_48bppRGB(&r,&g,&b,&a,row,x);
338  break;
340  getpixel_64bppARGB(&r,&g,&b,&a,row,x);
341  break;
343  getpixel_64bppPARGB(&r,&g,&b,&a,row,x);
344  break;
345  default:
346  FIXME("not implemented for format 0x%x\n", bitmap->format);
347  return NotImplemented;
348  }
349 
350  if (bitmap->format & PixelFormatIndexed)
351  *color = bitmap->image.palette->Entries[index];
352  else
353  *color = a<<24|r<<16|g<<8|b;
354 
355  return Ok;
356 }
uint32 width
Definition: uimain.c:91
static void getpixel_64bppPARGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:274
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define PixelFormat1bppIndexed
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define PixelFormat32bppRGB
#define PixelFormat16bppARGB1555
static void getpixel_16bppRGB565(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:192
static void getpixel_32bppRGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:224
GLuint color
Definition: glext.h:6243
#define a
Definition: ke_i.h:78
#define FIXME(fmt,...)
Definition: debug.h:110
static void getpixel_16bppRGB555(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:182
static void getpixel_24bppRGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:215
GLuint index
Definition: glext.h:6031
#define PixelFormat8bppIndexed
#define PixelFormat4bppIndexed
#define b
Definition: ke_i.h:79
Definition: uimain.c:88
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
static void getpixel_16bppARGB1555(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:202
#define PixelFormat16bppRGB555
static void getpixel_32bppARGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:233
static void getpixel_64bppARGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:265
#define PixelFormat64bppARGB
static void getpixel_1bppIndexed(BYTE *index, const BYTE *row, UINT x)
Definition: image.c:157
static void getpixel_48bppRGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:256
#define PixelFormat64bppPARGB
#define index(s, c)
Definition: various.h:29
unsigned char BYTE
Definition: mem.h:68
uint32 height
Definition: uimain.c:92
#define PixelFormatIndexed
#define PixelFormat24bppRGB
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static void getpixel_32bppPARGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:242
static void getpixel_4bppIndexed(BYTE *index, const BYTE *row, UINT x)
Definition: image.c:162
#define PixelFormat32bppPARGB
#define PixelFormat16bppRGB565
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define PixelFormat16bppGrayScale
static void getpixel_8bppIndexed(BYTE *index, const BYTE *row, UINT x)
Definition: image.c:170
#define PixelFormat48bppRGB
#define PixelFormat32bppARGB
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
static void getpixel_16bppGrayScale(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:175

Referenced by alpha_blend_bmp_pixels(), GdipBitmapGetHistogram(), Bitmap::GetPixel(), test_clear(), test_clipping(), test_colorkey(), test_colormatrix(), test_containers(), test_emfonly(), test_fillrect(), test_gamma(), test_GdipFillRectanglesOnBitmapTextureBrush(), test_GdipImageGetFrameDimensionsCount(), test_gditransform(), test_getdc(), test_getdc_scaled(), test_getsetpixel(), test_LockBits(), test_LockBits_UserBuf(), test_multiframegif(), test_pagetransform(), test_palette(), test_remaptable(), test_rotateflip(), and test_worldtransform().

◆ GdipBitmapLockBits()

GpStatus WINGDIPAPI GdipBitmapLockBits ( GpBitmap bitmap,
GDIPCONST GpRect rect,
UINT  flags,
PixelFormat  format,
BitmapData lockeddata 
)

Definition at line 1030 of file image.c.

1032 {
1033  INT bitspp = PIXELFORMATBPP(format);
1034  GpRect act_rect; /* actual rect to be used */
1035  GpStatus stat;
1036  BOOL unlock;
1037 
1038  TRACE("%p %p %d 0x%x %p\n", bitmap, rect, flags, format, lockeddata);
1039 
1040  if(!lockeddata || !bitmap)
1041  return InvalidParameter;
1042  if(!image_lock(&bitmap->image, &unlock))
1043  return ObjectBusy;
1044 
1045  if(rect){
1046  if(rect->X < 0 || rect->Y < 0 || (rect->X + rect->Width > bitmap->width) ||
1047  (rect->Y + rect->Height > bitmap->height) || !flags)
1048  {
1049  image_unlock(&bitmap->image, unlock);
1050  return InvalidParameter;
1051  }
1052 
1053  act_rect = *rect;
1054  }
1055  else{
1056  act_rect.X = act_rect.Y = 0;
1057  act_rect.Width = bitmap->width;
1058  act_rect.Height = bitmap->height;
1059  }
1060 
1061  if(bitmap->lockmode)
1062  {
1063  WARN("bitmap is already locked and cannot be locked again\n");
1064  image_unlock(&bitmap->image, unlock);
1065  return WrongState;
1066  }
1067 
1068  if (bitmap->bits && bitmap->format == format && !(flags & ImageLockModeUserInputBuf))
1069  {
1070  /* no conversion is necessary; just use the bits directly */
1071  lockeddata->Width = act_rect.Width;
1072  lockeddata->Height = act_rect.Height;
1073  lockeddata->PixelFormat = format;
1074  lockeddata->Reserved = flags;
1075  lockeddata->Stride = bitmap->stride;
1076  lockeddata->Scan0 = bitmap->bits + (bitspp / 8) * act_rect.X +
1077  bitmap->stride * act_rect.Y;
1078 
1079  bitmap->lockmode = flags | ImageLockModeRead;
1080 
1081  image_unlock(&bitmap->image, unlock);
1082  return Ok;
1083  }
1084 
1085  /* Make sure we can convert to the requested format. */
1086  if (flags & ImageLockModeRead)
1087  {
1088  stat = convert_pixels(0, 0, 0, NULL, format, 0, NULL, bitmap->format, NULL);
1089  if (stat == NotImplemented)
1090  {
1091  FIXME("cannot read bitmap from %x to %x\n", bitmap->format, format);
1092  image_unlock(&bitmap->image, unlock);
1093  return NotImplemented;
1094  }
1095  }
1096 
1097  /* If we're opening for writing, make sure we'll be able to write back in
1098  * the original format. */
1099  if (flags & ImageLockModeWrite)
1100  {
1101  stat = convert_pixels(0, 0, 0, NULL, bitmap->format, 0, NULL, format, NULL);
1102  if (stat == NotImplemented)
1103  {
1104  FIXME("cannot write bitmap from %x to %x\n", format, bitmap->format);
1105  image_unlock(&bitmap->image, unlock);
1106  return NotImplemented;
1107  }
1108  }
1109 
1110  lockeddata->Width = act_rect.Width;
1111  lockeddata->Height = act_rect.Height;
1112  lockeddata->PixelFormat = format;
1113  lockeddata->Reserved = flags;
1114 
1116  {
1117  lockeddata->Stride = (((act_rect.Width * bitspp + 7) / 8) + 3) & ~3;
1118 
1119  bitmap->bitmapbits = heap_alloc_zero(lockeddata->Stride * act_rect.Height);
1120 
1121  if (!bitmap->bitmapbits)
1122  {
1123  image_unlock(&bitmap->image, unlock);
1124  return OutOfMemory;
1125  }
1126 
1127  lockeddata->Scan0 = bitmap->bitmapbits;
1128  }
1129 
1130  if (flags & ImageLockModeRead)
1131  {
1132  static BOOL fixme = FALSE;
1133 
1134  if (!fixme && (PIXELFORMATBPP(bitmap->format) * act_rect.X) % 8 != 0)
1135  {
1136  FIXME("Cannot copy rows that don't start at a whole byte.\n");
1137  fixme = TRUE;
1138  }
1139 
1140  stat = convert_pixels(act_rect.Width, act_rect.Height,
1141  lockeddata->Stride, lockeddata->Scan0, format,
1142  bitmap->stride,
1143  bitmap->bits + bitmap->stride * act_rect.Y + PIXELFORMATBPP(bitmap->format) * act_rect.X / 8,
1144  bitmap->format, bitmap->image.palette);
1145 
1146  if (stat != Ok)
1147  {
1148  heap_free(bitmap->bitmapbits);
1149  bitmap->bitmapbits = NULL;
1150  image_unlock(&bitmap->image, unlock);
1151  return stat;
1152  }
1153  }
1154 
1155  bitmap->lockmode = flags | ImageLockModeRead;
1156  bitmap->lockx = act_rect.X;
1157  bitmap->locky = act_rect.Y;
1158 
1159  image_unlock(&bitmap->image, unlock);
1160  return Ok;
1161 }
#define TRUE
Definition: types.h:120
#define PIXELFORMATBPP(x)
Definition: image.c:45
uint32 width
Definition: uimain.c:91
INT Width
Definition: gdiplustypes.h:271
#define WARN(fmt,...)
Definition: debug.h:111
GpStatus convert_pixels(INT width, INT height, INT dst_stride, BYTE *dst_bits, PixelFormat dst_format, INT src_stride, const BYTE *src_bits, PixelFormat src_format, ColorPalette *palette)
Definition: image.c:562
static void image_unlock(GpImage *image, BOOL unlock)
int32_t INT
Definition: typedefs.h:56
& rect
Definition: startmenu.cpp:1413
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
unsigned int BOOL
Definition: ntddk_ex.h:94
INT X
Definition: gdiplustypes.h:269
#define FIXME(fmt,...)
Definition: debug.h:110
static BOOL image_lock(GpImage *image, BOOL *unlock)
smooth NULL
Definition: ftsmooth.c:416
Definition: uimain.c:88
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
Definition: stat.h:55
Status
Definition: gdiplustypes.h:24
PixelFormat PixelFormat
uint32 height
Definition: uimain.c:92
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
UINT_PTR Reserved
INT Height
Definition: gdiplustypes.h:272
INT Y
Definition: gdiplustypes.h:270
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by brush_fill_pixels(), create_optimal_palette(), decode_frame_wic(), DibLoadImage(), encode_image_wic(), GdipCreateBitmapFromHBITMAP(), GdipCreateBitmapFromHICON(), GdipCreateHICONFromBitmap(), GdipDrawImagePointsRect(), GdipImageRotateFlip(), Bitmap::LockBits(), test_ARGB_conversion(), test_bitmapbits(), test_CloneBitmapArea(), test_createhbitmap(), test_image_format(), test_LockBits(), test_LockBits_UserBuf(), and test_pen_thickness().

◆ GdipBitmapSetPixel()

GpStatus WINGDIPAPI GdipBitmapSetPixel ( GpBitmap bitmap,
INT  x,
INT  y,
ARGB  color 
)

Definition at line 494 of file image.c.

496 {
497  BYTE a, r, g, b;
498  BYTE *row;
499 
500  if(!bitmap || x < 0 || y < 0 || x >= bitmap->width || y >= bitmap->height)
501  return InvalidParameter;
502 
503  a = color>>24;
504  r = color>>16;
505  g = color>>8;
506  b = color;
507 
508  row = bitmap->bits + bitmap->stride * y;
509 
510  switch (bitmap->format)
511  {
514  break;
517  break;
520  break;
523  break;
524  case PixelFormat24bppRGB:
526  break;
527  case PixelFormat32bppRGB:
529  break;
532  break;
535  break;
536  case PixelFormat48bppRGB:
538  break;
541  break;
544  break;
546  setpixel_8bppIndexed(r,g,b,a,row,x,bitmap->image.palette);
547  break;
549  setpixel_4bppIndexed(r,g,b,a,row,x,bitmap->image.palette);
550  break;
552  setpixel_1bppIndexed(r,g,b,a,row,x,bitmap->image.palette);
553  break;
554  default:
555  FIXME("not implemented for format 0x%x\n", bitmap->format);
556  return NotImplemented;
557  }
558 
559  return Ok;
560 }
static void setpixel_32bppARGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:453
uint32 width
Definition: uimain.c:91
static void setpixel_32bppPARGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:459
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static void setpixel_4bppIndexed(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x, ColorPalette *palette)
Definition: image.c:399
static void setpixel_64bppPARGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:483
#define PixelFormat1bppIndexed
static void setpixel_1bppIndexed(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x, ColorPalette *palette)
Definition: image.c:393
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define PixelFormat32bppRGB
#define PixelFormat16bppARGB1555
GLuint color
Definition: glext.h:6243
#define a
Definition: ke_i.h:78
#define FIXME(fmt,...)
Definition: debug.h:110
static void setpixel_16bppARGB1555(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:430
#define PixelFormat8bppIndexed
#define PixelFormat4bppIndexed
#define b
Definition: ke_i.h:79
Definition: uimain.c:88
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define PixelFormat16bppRGB555
static void setpixel_16bppRGB565(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:422
#define PixelFormat64bppARGB
static void setpixel_32bppRGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:447
#define PixelFormat64bppPARGB
unsigned char BYTE
Definition: mem.h:68
uint32 height
Definition: uimain.c:92
#define PixelFormat24bppRGB
static void setpixel_16bppGrayScale(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:408
static void setpixel_16bppRGB555(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:414
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static void setpixel_64bppARGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:476
static void setpixel_8bppIndexed(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x, ColorPalette *palette)
Definition: image.c:386
static void setpixel_48bppRGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:468
#define PixelFormat32bppPARGB
#define PixelFormat16bppRGB565
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
static void setpixel_24bppRGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:439
#define PixelFormat16bppGrayScale
#define PixelFormat48bppRGB
#define PixelFormat32bppARGB
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78

Referenced by alpha_blend_bmp_pixels(), Bitmap::SetPixel(), test_colorkey(), test_colormatrix(), test_emfonly(), test_fillrect(), test_gamma(), test_GdipCreateBitmapFromHBITMAP(), test_GdipImageGetFrameDimensionsCount(), test_getdc(), test_getsetpixel(), test_histogram(), test_LockBits(), test_multiframegif(), test_palette(), and test_remaptable().

◆ GdipBitmapSetResolution()

GpStatus WINGDIPAPI GdipBitmapSetResolution ( GpBitmap bitmap,
REAL  xdpi,
REAL  ydpi 
)

Definition at line 1163 of file image.c.

1164 {
1165  TRACE("(%p, %.2f, %.2f)\n", bitmap, xdpi, ydpi);
1166 
1167  if (!bitmap || xdpi == 0.0 || ydpi == 0.0)
1168  return InvalidParameter;
1169 
1170  bitmap->image.xres = xdpi;
1171  bitmap->image.yres = ydpi;
1172 
1173  return Ok;
1174 }
Definition: uimain.c:88
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by create_graphics(), Bitmap::SetResolution(), test_DrawImage(), test_DrawImage_scale(), test_GdipDrawImagePointRect(), test_pen_thickness(), and test_resolution().

◆ GdipBitmapUnlockBits()

GpStatus WINGDIPAPI GdipBitmapUnlockBits ( GpBitmap bitmap,
BitmapData lockeddata 
)

Definition at line 1176 of file image.c.

1178 {
1179  GpStatus stat;
1180  static BOOL fixme = FALSE;
1181  BOOL unlock;
1182 
1183  TRACE("(%p,%p)\n", bitmap, lockeddata);
1184 
1185  if(!bitmap || !lockeddata)
1186  return InvalidParameter;
1187  if(!image_lock(&bitmap->image, &unlock))
1188  return ObjectBusy;
1189 
1190  if(!bitmap->lockmode)
1191  {
1192  image_unlock(&bitmap->image, unlock);
1193  return WrongState;
1194  }
1195 
1196  if(!(lockeddata->Reserved & ImageLockModeWrite)){
1197  bitmap->lockmode = 0;
1198  heap_free(bitmap->bitmapbits);
1199  bitmap->bitmapbits = NULL;
1200  image_unlock(&bitmap->image, unlock);
1201  return Ok;
1202  }
1203 
1204  if (!bitmap->bitmapbits && !(lockeddata->Reserved & ImageLockModeUserInputBuf))
1205  {
1206  /* we passed a direct reference; no need to do anything */
1207  bitmap->lockmode = 0;
1208  image_unlock(&bitmap->image, unlock);
1209  return Ok;
1210  }
1211 
1212  if (!fixme && (PIXELFORMATBPP(bitmap->format) * bitmap->lockx) % 8 != 0)
1213  {
1214  FIXME("Cannot copy rows that don't start at a whole byte.\n");
1215  fixme = TRUE;
1216  }
1217 
1218  stat = convert_pixels(lockeddata->Width, lockeddata->Height,
1219  bitmap->stride,
1220  bitmap->bits + bitmap->stride * bitmap->locky + PIXELFORMATBPP(bitmap->format) * bitmap->lockx / 8,
1221  bitmap->format,
1222  lockeddata->Stride, lockeddata->Scan0, lockeddata->PixelFormat, NULL);
1223 
1224  if (stat != Ok)
1225  {
1226  ERR("failed to convert pixels; this should never happen\n");
1227  }
1228 
1229  heap_free(bitmap->bitmapbits);
1230  bitmap->bitmapbits = NULL;
1231  bitmap->lockmode = 0;
1232 
1233  image_unlock(&bitmap->image, unlock);
1234  return stat;
1235 }
#define TRUE
Definition: types.h:120
#define PIXELFORMATBPP(x)
Definition: image.c:45
GpStatus convert_pixels(INT width, INT height, INT dst_stride, BYTE *dst_bits, PixelFormat dst_format, INT src_stride, const BYTE *src_bits, PixelFormat src_format, ColorPalette *palette)
Definition: image.c:562
static void image_unlock(GpImage *image, BOOL unlock)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
static BOOL image_lock(GpImage *image, BOOL *unlock)
smooth NULL
Definition: ftsmooth.c:416
Definition: uimain.c:88
#define TRACE(s)
Definition: solgame.cpp:4
Definition: stat.h:55
Status
Definition: gdiplustypes.h:24
PixelFormat PixelFormat
#define ERR(fmt,...)
Definition: debug.h:109
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
UINT_PTR Reserved
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by brush_fill_pixels(), create_optimal_palette(), decode_frame_wic(), DibLoadImage(), encode_image_wic(), GdipCreateBitmapFromHBITMAP(), GdipCreateBitmapFromHICON(), GdipCreateHICONFromBitmap(), GdipDrawImagePointsRect(), GdipImageRotateFlip(), test_ARGB_conversion(), test_bitmapbits(), test_CloneBitmapArea(), test_createhbitmap(), test_image_format(), test_LockBits(), test_LockBits_UserBuf(), test_pen_thickness(), and Bitmap::UnlockBits().

◆ GdipCloneBitmapArea()

GpStatus WINGDIPAPI GdipCloneBitmapArea ( REAL  x,
REAL  y,
REAL  width,
REAL  height,
PixelFormat  format,
GpBitmap srcBitmap,
GpBitmap **  dstBitmap 
)

Definition at line 1237 of file image.c.

1239 {
1240  Rect area;
1241  GpStatus stat;
1242 
1243  TRACE("(%f,%f,%f,%f,0x%x,%p,%p)\n", x, y, width, height, format, srcBitmap, dstBitmap);
1244 
1245  if (!srcBitmap || !dstBitmap || srcBitmap->image.type != ImageTypeBitmap ||
1246  x < 0 || y < 0 ||
1247  x + width > srcBitmap->width || y + height > srcBitmap->height)
1248  {
1249  TRACE("<-- InvalidParameter\n");
1250  return InvalidParameter;
1251  }
1252 
1253  if (format == PixelFormatDontCare)
1254  format = srcBitmap->format;
1255 
1256  area.X = gdip_round(x);
1257  area.Y = gdip_round(y);
1258  area.Width = gdip_round(width);
1259  area.Height = gdip_round(height);
1260 
1261  stat = GdipCreateBitmapFromScan0(area.Width, area.Height, 0, format, NULL, dstBitmap);
1262  if (stat == Ok)
1263  {
1264  stat = convert_pixels(area.Width, area.Height, (*dstBitmap)->stride, (*dstBitmap)->bits, (*dstBitmap)->format,
1265  srcBitmap->stride,
1266  srcBitmap->bits + srcBitmap->stride * area.Y + PIXELFORMATBPP(srcBitmap->format) * area.X / 8,
1267  srcBitmap->format, srcBitmap->image.palette);
1268 
1269  if (stat == Ok && srcBitmap->image.palette)
1270  {
1271  ColorPalette *src_palette, *dst_palette;
1272 
1273  src_palette = srcBitmap->image.palette;
1274 
1275  dst_palette = heap_alloc_zero(sizeof(UINT) * 2 + sizeof(ARGB) * src_palette->Count);
1276 
1277  if (dst_palette)
1278  {
1279  dst_palette->