ReactOS  0.4.15-dev-5499-g1341c38
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: xxhash.c:193
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 2587 of file image.c.

◆ PropertyTagTypeFloat

#define PropertyTagTypeFloat   11

Definition at line 2586 of file image.c.

◆ PropertyTagTypeSByte

#define PropertyTagTypeSByte   6

Definition at line 2584 of file image.c.

◆ PropertyTagTypeSShort

#define PropertyTagTypeSShort   8

Definition at line 2585 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 4260 of file image.c.

◆ encode_image_func

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

Definition at line 4257 of file image.c.

◆ image_codec

◆ metadata_reader_func

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

Definition at line 3630 of file image.c.

◆ select_image_func

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

Definition at line 4262 of file image.c.

Enumeration Type Documentation

◆ ImageFormat

Enumerator
BMP 
JPEG 
GIF 
TIFF 
EMF 
WMF 
PNG 
ICO 
NUM_CODECS 

Definition at line 4271 of file image.c.

4271  {
4272  BMP,
4273  JPEG,
4274  GIF,
4275  TIFF,
4276  EMF,
4277  WMF,
4278  PNG,
4279  ICO,
4280  NUM_CODECS
4281 } ImageFormat;
Definition: image.c:4275
Definition: image.c:4276
Definition: image.c:4272
Definition: image.c:4273
Definition: image.c:4277
ImageFormat
Definition: image.c:4271
Definition: image.c:4274
Definition: image.c:4279
Definition: image.c:4278

Function Documentation

◆ add_property()

static void add_property ( GpBitmap bitmap,
PropertyItem item 
)
static

Definition at line 3009 of file image.c.

3010 {
3011  UINT prop_size, prop_count;
3012  PropertyItem *prop_item;
3013 
3014  if (bitmap->prop_item == NULL)
3015  {
3016  prop_size = prop_count = 0;
3017  prop_item = heap_alloc_zero(item->length + sizeof(PropertyItem));
3018  if (!prop_item) return;
3019  }
3020  else
3021  {
3022  UINT i;
3023  char *item_value;
3024 
3025  GdipGetPropertySize(&bitmap->image, &prop_size, &prop_count);
3026 
3027  prop_item = heap_alloc_zero(prop_size + item->length + sizeof(PropertyItem));
3028  if (!prop_item) return;
3029  memcpy(prop_item, bitmap->prop_item, sizeof(PropertyItem) * bitmap->prop_count);
3030  prop_size -= sizeof(PropertyItem) * bitmap->prop_count;
3031  memcpy(prop_item + prop_count + 1, bitmap->prop_item + prop_count, prop_size);
3032 
3033  item_value = (char *)(prop_item + prop_count + 1);
3034 
3035  for (i = 0; i < prop_count; i++)
3036  {
3037  prop_item[i].value = item_value;
3038  item_value += prop_item[i].length;
3039  }
3040  }
3041 
3042  prop_item[prop_count].id = item->id;
3043  prop_item[prop_count].type = item->type;
3044  prop_item[prop_count].length = item->length;
3045  prop_item[prop_count].value = (char *)(prop_item + prop_count + 1) + prop_size;
3046  memcpy(prop_item[prop_count].value, item->value, item->length);
3047 
3048  heap_free(bitmap->prop_item);
3049  bitmap->prop_item = prop_item;
3050  bitmap->prop_count++;
3051 }
Definition: pdh_main.c:93
Definition: uimain.c:88
struct PropertyItem PropertyItem
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static ATOM item
Definition: dde.c:856
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
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
GpStatus WINGDIPAPI GdipGetPropertySize(GpImage *image, UINT *size, UINT *count)
Definition: image.c:2735
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
GLenum src
Definition: glext.h:6340
unsigned char BYTE
Definition: xxhash.c:193
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 3834 of file image.c.

3835 {
3836  UINT i, j, left, top, width, height;
3838  BYTE *new_bits;
3839  HRESULT hr;
3840 
3841  hr = get_gif_frame_rect(frame, &left, &top, &width, &height);
3842  if(FAILED(hr))
3843  return hr;
3844 
3845  hr = WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGRA, (IWICBitmapSource*)frame, &source);
3846  if(FAILED(hr))
3847  return hr;
3848 
3849  new_bits = heap_alloc_zero(width*height*4);
3850  if(!new_bits)
3851  return E_OUTOFMEMORY;
3852 
3853  hr = IWICBitmapSource_CopyPixels(source, NULL, width*4, width*height*4, new_bits);
3854  IWICBitmapSource_Release(source);
3855  if(FAILED(hr)) {
3856  heap_free(new_bits);
3857  return hr;
3858  }
3859 
3860  for(i=0; i<height && i+top<bitmap->height; i++) {
3861  for(j=0; j<width && j+left<bitmap->width; j++) {
3862  DWORD *src = (DWORD*)(new_bits+i*width*4+j*4);
3863  DWORD *dst = (DWORD*)(bitmap->bits+(i+top)*bitmap->stride+(j+left)*4);
3864 
3865  if(first_frame || *src>>24 != 0)
3866  *dst = *src;
3867  }
3868  }
3869  heap_free(new_bits);
3870  return hr;
3871 }
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:3822
uint32 width
Definition: uimain.c:91
HRESULT hr
Definition: shlfolder.c:183
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
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:79
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint left
Definition: glext.h:7726
GLenum src
Definition: glext.h:6340
unsigned char BYTE
Definition: xxhash.c:193
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
uint32 height
Definition: uimain.c:92
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
GLsizei GLsizei GLchar * source
Definition: glext.h:6048
GLenum GLenum dst
Definition: glext.h:6340
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
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:58
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 5693 of file image.c.

5695 {
5696  GpStatus status;
5697  BitmapData data;
5698  HRESULT hr;
5700  IWICPalette *wic_palette;
5701 
5702  if (!bitmap) return InvalidParameter;
5703  if (palette->Count < desired) return GenericError;
5704 
5706  if (status != Ok) return status;
5707 
5708  hr = WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory);
5709  if (hr != S_OK)
5710  {
5712  return hresult_to_status(hr);
5713  }
5714 
5715  hr = IWICImagingFactory_CreatePalette(factory, &wic_palette);
5716  if (hr == S_OK)
5717  {
5718  IWICBitmap *bitmap;
5719 
5720  /* PixelFormat24bppRGB actually stores the bitmap bits as BGR. */
5721  hr = IWICImagingFactory_CreateBitmapFromMemory(factory, data.Width, data.Height,
5722  &GUID_WICPixelFormat24bppBGR, data.Stride, data.Stride * data.Width, data.Scan0, &bitmap);
5723  if (hr == S_OK)
5724  {
5725  hr = IWICPalette_InitializeFromBitmap(wic_palette, (IWICBitmapSource *)bitmap, desired, transparent);
5726  if (hr == S_OK)
5727  {
5728  palette->Flags = 0;
5729  IWICPalette_GetColorCount(wic_palette, &palette->Count);
5730  IWICPalette_GetColors(wic_palette, palette->Count, palette->Entries, &palette->Count);
5731  }
5732 
5733  IWICBitmap_Release(bitmap);
5734  }
5735 
5736  IWICPalette_Release(wic_palette);
5737  }
5738 
5739  IWICImagingFactory_Release(factory);
5741 
5742  return hresult_to_status(hr);
5743 }
GpStatus hresult_to_status(HRESULT res)
Definition: gdiplus.c:312
HRESULT hr
Definition: shlfolder.c:183
int desired
Definition: jpeglib.h:1119
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
Status
Definition: gdiplustypes.h:24
Definition: uimain.c:88
GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap *bitmap, BitmapData *lockeddata)
Definition: image.c:1176
LONG HRESULT
Definition: typedefs.h:79
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static HPALETTE palette
Definition: clipboard.c:1345
#define S_OK
Definition: intsafe.h:52
#define PixelFormat24bppRGB
#define NULL
Definition: types.h:112
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 3419 of file image.c.

3420 {
3421  PropertyItem *item = NULL;
3422  UINT item_size = propvariant_size(value);
3423 
3424  if (item_size)
3425  {
3426  item_size += sizeof(*item);
3427  item = heap_alloc_zero(item_size);
3428  if (propvariant_to_item(value, item, item_size, propid) != Ok)
3429  {
3430  heap_free(item);
3431  item = NULL;
3432  }
3433  }
3434 
3435  return item;
3436 }
Definition: pdh_main.c:93
static GpStatus propvariant_to_item(PROPVARIANT *value, PropertyItem *item, UINT size, PROPID id)
Definition: image.c:2619
static ATOM item
Definition: dde.c:856
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
static UINT propvariant_size(PROPVARIANT *value)
Definition: image.c:2502
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 3632 of file image.c.

3634 {
3635  GpStatus status=Ok;
3636  GpBitmap *bitmap;
3637  HRESULT hr;
3638  IWICBitmapFrameDecode *frame;
3640  IWICMetadataBlockReader *block_reader;
3645  int i;
3646  UINT width, height, frame_count;
3647  BitmapData lockeddata;
3648  WICRect wrc;
3649 
3650  TRACE("%p,%u,%p\n", decoder, active_frame, image);
3651 
3652  IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
3653  hr = IWICBitmapDecoder_GetFrame(decoder, active_frame, &frame);
3654  if (SUCCEEDED(hr)) /* got frame */
3655  {
3656  hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &wic_format);
3657 
3658  if (SUCCEEDED(hr))
3659  {
3660  if (!force_conversion)
3661  {
3662  for (i=0; pixel_formats[i].wic_format; i++)
3663  {
3665  {
3666  source = (IWICBitmapSource*)frame;
3667  IWICBitmapSource_AddRef(source);
3668  gdip_format = pixel_formats[i].gdip_format;
3669  palette_type = pixel_formats[i].palette_type;
3670  break;
3671  }
3672  }
3673  }
3674  if (!source)
3675  {
3676  /* unknown format; fall back on 32bppARGB */
3677  hr = WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGRA, (IWICBitmapSource*)frame, &source);
3679  }
3680  TRACE("%s => %#x\n", wine_dbgstr_guid(&wic_format), gdip_format);
3681  }
3682 
3683  if (SUCCEEDED(hr)) /* got source */
3684  {
3685  hr = IWICBitmapSource_GetSize(source, &width, &height);
3686 
3687  if (SUCCEEDED(hr))
3689  NULL, &bitmap);
3690 
3691  if (SUCCEEDED(hr) && status == Ok) /* created bitmap */
3692  {
3694  gdip_format, &lockeddata);
3695  if (status == Ok) /* locked bitmap */
3696  {
3697  wrc.X = 0;
3698  wrc.Width = width;
3699  wrc.Height = 1;
3700  for (i=0; i<height; i++)
3701  {
3702  wrc.Y = i;
3703  hr = IWICBitmapSource_CopyPixels(source, &wrc, abs(lockeddata.Stride),
3704  abs(lockeddata.Stride), (BYTE*)lockeddata.Scan0+lockeddata.Stride*i);
3705  if (FAILED(hr)) break;
3706  }
3707 
3708  GdipBitmapUnlockBits(bitmap, &lockeddata);
3709  }
3710 
3711  if (SUCCEEDED(hr) && status == Ok)
3712  *image = &bitmap->image;
3713  else
3714  {
3715  *image = NULL;
3716  GdipDisposeImage(&bitmap->image);
3717  }
3718 
3719  if (SUCCEEDED(hr) && status == Ok)
3720  {
3721  double dpix, dpiy;
3722  hr = IWICBitmapSource_GetResolution(source, &dpix, &dpiy);
3723  if (SUCCEEDED(hr))
3724  {
3725  bitmap->image.xres = dpix;
3726  bitmap->image.yres = dpiy;
3727  }
3728  hr = S_OK;
3729  }
3730  }
3731 
3732  IWICBitmapSource_Release(source);
3733  }
3734 
3735  if (SUCCEEDED(hr)) {
3736  bitmap->metadata_reader = NULL;
3737 
3738  if (metadata_reader)
3739  metadata_reader(bitmap, decoder, active_frame);
3740  else if (IWICBitmapFrameDecode_QueryInterface(frame, &IID_IWICMetadataBlockReader, (void **)&block_reader) == S_OK)
3741  {
3742  UINT block_count = 0;
3743  if (IWICMetadataBlockReader_GetCount(block_reader, &block_count) == S_OK && block_count)
3744  IWICMetadataBlockReader_GetReaderByIndex(block_reader, 0, &bitmap->metadata_reader);
3745  IWICMetadataBlockReader_Release(block_reader);
3746  }
3747 
3748  palette = get_palette(frame, palette_type);
3749  IWICBitmapFrameDecode_Release(frame);
3750  }
3751  }
3752 
3753  if (FAILED(hr) && status == Ok) status = hresult_to_status(hr);
3754 
3755  if (status == Ok)
3756  {
3757  /* Native GDI+ used to be smarter, but since Win7 it just sets these flags. */
3759  if (IsEqualGUID(&wic_format, &GUID_WICPixelFormat2bppGray) ||
3760  IsEqualGUID(&wic_format, &GUID_WICPixelFormat4bppGray) ||
3761  IsEqualGUID(&wic_format, &GUID_WICPixelFormat8bppGray) ||
3762  IsEqualGUID(&wic_format, &GUID_WICPixelFormat16bppGray))
3763  bitmap->image.flags |= ImageFlagsColorSpaceGRAY;
3764  else
3765  bitmap->image.flags |= ImageFlagsColorSpaceRGB;
3766  bitmap->image.frame_count = frame_count;
3767  bitmap->image.current_frame = active_frame;
3768  bitmap->image.decoder = decoder;
3769  IWICBitmapDecoder_AddRef(decoder);
3770  if (palette)
3771  {
3772  heap_free(bitmap->image.palette);
3773  bitmap->image.palette = palette;
3774  }
3775  else
3776  {
3777  if (IsEqualGUID(&wic_format, &GUID_WICPixelFormatBlackWhite))
3778  bitmap->image.palette->Flags = 0;
3779  }
3780  TRACE("=> %p\n", *image);
3781  }
3782 
3783  return status;
3784 }
#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
HRESULT hr
Definition: shlfolder.c:183
static const struct @404 pixel_formats[]
const char * wine_dbgstr_guid(const GUID *guid)
GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap *bitmap, GDIPCONST GpRect *rect, UINT flags, PixelFormat format, BitmapData *lockeddata)
Definition: image.c:1030
if SUCCEEDED(hr)
GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE *scan0, GpBitmap **bitmap)
Definition: image.c:1760
INT Height
Definition: wincodec.idl:301
Status
Definition: gdiplustypes.h:24
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:79
INT PixelFormat
unsigned char BYTE
Definition: xxhash.c:193
static HPALETTE palette
Definition: clipboard.c:1345
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2155
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define S_OK
Definition: intsafe.h:52
WICBitmapPaletteType palette_type
Definition: image.c:53
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
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
INT Width
Definition: wincodec.idl:300
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
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 3983 of file image.c.

3984 {
3985  GpStatus status;
3986  GpBitmap* bitmap;
3987 
3988  status = decode_image_wic(stream, &GUID_ContainerFormatBmp, NULL, image);
3989 
3990  bitmap = (GpBitmap*)*image;
3991 
3992  if (status == Ok && bitmap->format == PixelFormat32bppARGB)
3993  {
3994  /* WIC supports bmp files with alpha, but gdiplus does not */
3995  bitmap->format = PixelFormat32bppRGB;
3996  }
3997 
3998  return status;
3999 }
static GpStatus decode_image_wic(IStream *stream, REFGUID container, metadata_reader_func metadata_reader, GpImage **image)
Definition: image.c:3786
#define PixelFormat32bppRGB
Status
Definition: gdiplustypes.h:24
Definition: uimain.c:88
Definition: parse.h:22
#define NULL
Definition: types.h:112
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 4234 of file image.c.

4235 {
4237  GpStatus status;
4238 
4239  TRACE("%p %p\n", stream, image);
4240 
4241  if (!stream || !image)
4242  return InvalidParameter;
4243 
4245  if (status != Ok)
4246  {
4247  TRACE("Could not load metafile\n");
4248  return status;
4249  }
4250 
4251  *image = (GpImage *)metafile;
4252  TRACE("<-- %p\n", *image);
4253 
4254  return Ok;
4255 }
static const unsigned char metafile[]
Definition: olepicture.c:138
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
static GpStatus load_emf(IStream *stream, GpMetafile **metafile)
Definition: image.c:4195
Definition: parse.h:22
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 4082 of file image.c.

4083 {
4084  IWICBitmapDecoder *decoder;
4085  UINT frame_count;
4086  GpStatus status;
4087  HRESULT hr;
4088 
4089  status = initialize_decoder_wic(stream, &GUID_ContainerFormatGif, &decoder);
4090  if(status != Ok)
4091  return status;
4092 
4093  hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
4094  if(FAILED(hr))
4095  return hresult_to_status(hr);
4096 
4097  status = decode_frame_wic(decoder, frame_count > 1, 0, gif_metadata_reader, image);
4098  IWICBitmapDecoder_Release(decoder);
4099  if(status != Ok)
4100  return status;
4101 
4102  if(frame_count > 1) {
4103  heap_free((*image)->palette);
4104  (*image)->palette = NULL;
4105  }
4106  return Ok;
4107 }
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:3294
Status
Definition: gdiplustypes.h:24
LONG HRESULT
Definition: typedefs.h:79
Definition: parse.h:22
static GpStatus decode_frame_wic(IWICBitmapDecoder *decoder, BOOL force_conversion, UINT active_frame, metadata_reader_func metadata_reader, GpImage **image)
Definition: image.c:3632
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
static GpStatus initialize_decoder_wic(IStream *stream, REFGUID container, IWICBitmapDecoder **decoder)
Definition: image.c:3612
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 3978 of file image.c.

3979 {
3980  return decode_image_wic(stream, &GUID_ContainerFormatIco, NULL, image);
3981 }
static GpStatus decode_image_wic(IStream *stream, REFGUID container, metadata_reader_func metadata_reader, GpImage **image)
Definition: image.c:3786
Definition: parse.h:22
#define NULL
Definition: types.h:112

◆ decode_image_jpeg()

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

Definition at line 4001 of file image.c.

4002 {
4003  return decode_image_wic(stream, &GUID_ContainerFormatJpeg, NULL, image);
4004 }
static GpStatus decode_image_wic(IStream *stream, REFGUID container, metadata_reader_func metadata_reader, GpImage **image)
Definition: image.c:3786
Definition: parse.h:22
#define NULL
Definition: types.h:112

◆ decode_image_png()

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

Definition at line 4039 of file image.c.

4040 {
4041  IWICBitmapDecoder *decoder;
4042  IWICBitmapFrameDecode *frame;
4043  GpStatus status;
4044  HRESULT hr;
4045  GUID format;
4046  BOOL force_conversion = FALSE;
4047 
4048  status = initialize_decoder_wic(stream, &GUID_ContainerFormatPng, &decoder);
4049  if (status != Ok)
4050  return status;
4051 
4052  hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
4053  if (hr == S_OK)
4054  {
4055  hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format);
4056  if (hr == S_OK)
4057  {
4058  if (IsEqualGUID(&format, &GUID_WICPixelFormat8bppGray))
4059  force_conversion = TRUE;
4060  else if ((IsEqualGUID(&format, &GUID_WICPixelFormat8bppIndexed) ||
4061  IsEqualGUID(&format, &GUID_WICPixelFormat4bppIndexed) ||
4062  IsEqualGUID(&format, &GUID_WICPixelFormat2bppIndexed) ||
4063  IsEqualGUID(&format, &GUID_WICPixelFormat1bppIndexed) ||
4064  IsEqualGUID(&format, &GUID_WICPixelFormat24bppBGR)) &&
4066  force_conversion = TRUE;
4067 
4068  status = decode_frame_wic(decoder, force_conversion, 0, png_metadata_reader, image);
4069  }
4070  else
4072 
4073  IWICBitmapFrameDecode_Release(frame);
4074  }
4075  else
4077 
4078  IWICBitmapDecoder_Release(decoder);
4079  return status;
4080 }
GpStatus hresult_to_status(HRESULT res)
Definition: gdiplus.c:312
static void png_metadata_reader(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UINT active_frame)
Definition: image.c:3461
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
Status
Definition: gdiplustypes.h:24
static BOOL has_png_transparency_chunk(IStream *pIStream)
Definition: image.c:4006
LONG HRESULT
Definition: typedefs.h:79
Definition: parse.h:22
#define S_OK
Definition: intsafe.h:52
static GpStatus decode_frame_wic(IWICBitmapDecoder *decoder, BOOL force_conversion, UINT active_frame, metadata_reader_func metadata_reader, GpImage **image)
Definition: image.c:3632
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:3612
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 4109 of file image.c.

4110 {
4111  return decode_image_wic(stream, &GUID_ContainerFormatTiff, NULL, image);
4112 }
static GpStatus decode_image_wic(IStream *stream, REFGUID container, metadata_reader_func metadata_reader, GpImage **image)
Definition: image.c:3786
Definition: parse.h:22
#define NULL
Definition: types.h:112

◆ decode_image_wic()

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

Definition at line 3786 of file image.c.

3788 {
3789  IWICBitmapDecoder *decoder;
3790  GpStatus status;
3791 
3793  if(status != Ok)
3794  return status;
3795 
3796  status = decode_frame_wic(decoder, FALSE, 0, metadata_reader, image);
3797  IWICBitmapDecoder_Release(decoder);
3798  return status;
3799 }
#define FALSE
Definition: types.h:117
Status
Definition: gdiplustypes.h:24
Definition: parse.h:22
static GpStatus decode_frame_wic(IWICBitmapDecoder *decoder, BOOL force_conversion, UINT active_frame, metadata_reader_func metadata_reader, GpImage **image)
Definition: image.c:3632
static GpStatus initialize_decoder_wic(IStream *stream, REFGUID container, IWICBitmapDecoder **decoder)
Definition: image.c:3612
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 4172 of file image.c.

4173 {
4175  GpStatus status;
4176 
4177  TRACE("%p %p\n", stream, image);
4178 
4179  if (!stream || !image)
4180  return InvalidParameter;
4181 
4183  if (status != Ok)
4184  {
4185  TRACE("Could not load metafile\n");
4186  return status;
4187  }
4188 
4189  *image = (GpImage *)metafile;
4190  TRACE("<-- %p\n", *image);
4191 
4192  return Ok;
4193 }
static const unsigned char metafile[]
Definition: olepicture.c:138
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
static GpStatus load_wmf(IStream *stream, GpMetafile **metafile)
Definition: image.c:4114
Definition: parse.h:22
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 4638 of file image.c.

4640 {
4641  return encode_image_wic(image, stream, &GUID_ContainerFormatBmp, params);
4642 }
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:4503

◆ encode_image_gif()

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

Definition at line 4662 of file image.c.

4664 {
4665  return encode_image_wic(image, stream, &GUID_ContainerFormatGif, params);
4666 }
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:4503

◆ encode_image_jpeg()

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

Definition at line 4656 of file image.c.

4658 {
4659  return encode_image_wic(image, stream, &GUID_ContainerFormatJpeg, params);
4660 }
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:4503

◆ encode_image_png()

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

Definition at line 4650 of file image.c.

4652 {
4653  return encode_image_wic(image, stream, &GUID_ContainerFormatPng, params);
4654 }
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:4503

Referenced by METAFILE_CreateCompressedImageStream().

◆ encode_image_tiff()

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

Definition at line 4644 of file image.c.

4646 {
4647  return encode_image_wic(image, stream, &GUID_ContainerFormatTiff, params);
4648 }
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:4503

◆ encode_image_wic()

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

Definition at line 4503 of file image.c.

4505 {
4506  GpStatus stat;
4507  GpBitmap *bitmap;
4509  IWICBitmapEncoder *encoder;
4510  IWICBitmapFrameEncode *frameencode;
4511  IPropertyBag2 *encoderoptions;
4512  HRESULT hr;
4513  UINT width, height;
4514  PixelFormat gdipformat=0;
4515  const WICPixelFormatGUID *desired_wicformat;
4516  WICPixelFormatGUID wicformat;
4517  GpRect rc;
4518  BitmapData lockeddata;
4519  UINT i;
4520 
4521  if (image->type != ImageTypeBitmap)
4522  return GenericError;
4523 
4524  bitmap = (GpBitmap*)image;
4525 
4528 
4529  rc.X = 0;
4530  rc.Y = 0;
4531  rc.Width = width;
4532  rc.Height = height;
4533 
4534  hr = WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory);
4535  if (FAILED(hr))
4536  return hresult_to_status(hr);
4537  hr = IWICImagingFactory_CreateEncoder(factory, container, NULL, &encoder);
4538  IWICImagingFactory_Release(factory);
4539  if (FAILED(hr))
4540  return hresult_to_status(hr);
4541 
4542  hr = IWICBitmapEncoder_Initialize(encoder, stream, WICBitmapEncoderNoCache);
4543 
4544  if (SUCCEEDED(hr))
4545  {
4546  hr = IWICBitmapEncoder_CreateNewFrame(encoder, &frameencode, &encoderoptions);
4547  }
4548 
4549  if (SUCCEEDED(hr)) /* created frame */
4550  {
4551  hr = IWICBitmapFrameEncode_Initialize(frameencode, encoderoptions);
4552 
4553  if (SUCCEEDED(hr))
4554  hr = IWICBitmapFrameEncode_SetSize(frameencode, width, height);
4555 
4556  if (SUCCEEDED(hr))
4557  hr = IWICBitmapFrameEncode_SetResolution(frameencode, image->xres, image->yres);
4558 
4559  if (SUCCEEDED(hr))
4560  {
4561  for (i=0; pixel_formats[i].wic_format; i++)
4562  {
4563  if (pixel_formats[i].gdip_format == bitmap->format)
4564  {
4565  desired_wicformat = pixel_formats[i].wic_format;
4566  gdipformat = bitmap->format;
4567  break;
4568  }
4569  }
4570  if (!gdipformat)
4571  {
4572  desired_wicformat = &GUID_WICPixelFormat32bppBGRA;
4573  gdipformat = PixelFormat32bppARGB;
4574  }
4575 
4576  memcpy(&wicformat, desired_wicformat, sizeof(GUID));
4577  hr = IWICBitmapFrameEncode_SetPixelFormat(frameencode, &wicformat);
4578  }
4579 
4580  if (SUCCEEDED(hr) && !IsEqualGUID(desired_wicformat, &wicformat))
4581  {
4582  /* Encoder doesn't support this bitmap's format. */
4583  gdipformat = 0;
4584  for (i=0; pixel_formats[i].wic_format; i++)
4585  {
4586  if (IsEqualGUID(&wicformat, pixel_formats[i].wic_format))
4587  {
4588  gdipformat = pixel_formats[i].gdip_format;
4589  break;
4590  }
4591  }
4592  if (!gdipformat)
4593  {
4594  ERR("Cannot support encoder format %s\n", debugstr_guid(&wicformat));
4595  hr = E_FAIL;
4596  }
4597  }
4598 
4599  if (SUCCEEDED(hr))
4600  {
4601  stat = GdipBitmapLockBits(bitmap, &rc, ImageLockModeRead, gdipformat,
4602  &lockeddata);
4603 
4604  if (stat == Ok)
4605  {
4606  UINT row_size = (lockeddata.Width * PIXELFORMATBPP(gdipformat) + 7)/8;
4607  BYTE *row;
4608 
4609  /* write one row at a time in case stride is negative */
4610  row = lockeddata.Scan0;
4611  for (i=0; i<lockeddata.Height; i++)
4612  {
4613  hr = IWICBitmapFrameEncode_WritePixels(frameencode, 1, row_size, row_size, row);
4614  if (FAILED(hr)) break;
4615  row += lockeddata.Stride;
4616  }
4617 
4618  GdipBitmapUnlockBits(bitmap, &lockeddata);
4619  }
4620  else
4621  hr = E_FAIL;
4622  }
4623 
4624  if (SUCCEEDED(hr))
4625  hr = IWICBitmapFrameEncode_Commit(frameencode);
4626 
4627  IWICBitmapFrameEncode_Release(frameencode);
4628  IPropertyBag2_Release(encoderoptions);
4629  }
4630 
4631  if (SUCCEEDED(hr))
4632  hr = IWICBitmapEncoder_Commit(encoder);
4633 
4634  IWICBitmapEncoder_Release(encoder);
4635  return hresult_to_status(hr);
4636 }
GLint GLint GLsizei width
Definition: gl.h:1546
GpStatus hresult_to_status(HRESULT res)
Definition: gdiplus.c:312
#define PIXELFORMATBPP(x)
Definition: image.c:45
HRESULT hr
Definition: shlfolder.c:183
GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width)
Definition: image.c:2390
INT Width
Definition: gdiplustypes.h:671
static const struct @404 pixel_formats[]
HRESULT WINAPI WICCreateImagingFactory_Proxy(UINT, IWICImagingFactory **)
Definition: proxy.c:651
#define E_FAIL
Definition: ddrawi.h:102
GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height)
Definition: image.c:2287
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:669
if SUCCEEDED(hr)
#define debugstr_guid
Definition: kernel32.h:35
Status
Definition: gdiplustypes.h:24
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:79
INT PixelFormat
Definition: parse.h:22
Definition: stat.h:55
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: xxhash.c:193
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define ERR(fmt,...)
Definition: debug.h:110
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
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
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
INT Height
Definition: gdiplustypes.h:672
static ClassFactoryImpl factory
Definition: ole_server.c:234
static HBITMAP bitmap
Definition: clipboard.c:1344
INT Y
Definition: gdiplustypes.h:670
#define PixelFormat32bppARGB
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 2126 of file image.c.

2127 {
2128  if(!image)
2129  return InvalidParameter;
2130 
2131  if (image->type == ImageTypeBitmap)
2132  {
2133  heap_free(((GpBitmap*)image)->bitmapbits);
2134  heap_free(((GpBitmap*)image)->own_bits);
2135  DeleteDC(((GpBitmap*)image)->hdc);
2137  if (((GpBitmap*)image)->metadata_reader)
2138  IWICMetadataReader_Release(((GpBitmap*)image)->metadata_reader);
2139  heap_free(((GpBitmap*)image)->prop_item);
2140  }
2141  else if (image->type == ImageTypeMetafile)
2143  else
2144  {
2145  WARN("invalid image: %p\n", image);
2146  return ObjectBusy;
2147  }
2148  if (image->decoder)
2149  IWICBitmapDecoder_Release(image->decoder);
2150  heap_free(image->palette);
2151 
2152  return Ok;
2153 }
#define WARN(fmt,...)
Definition: debug.h:112
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:111
Definition: uimain.c:88

◆ GdipBitmapConvertFormat()

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

Definition at line 5549 of file image.c.

5551 {
5552  FIXME("(%p, 0x%08x, %d, %d, %p, %f): stub\n", bitmap, format, dithertype, palettetype, palette, alphathreshold);
5553  return NotImplemented;
5554 }
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define FIXME(fmt,...)
Definition: debug.h:111
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:111

◆ GdipBitmapGetHistogram()

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

Definition at line 5609 of file image.c.

5611 {
5612  static void (* const set_histogram_point[])(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3) =
5613  {
5622  };
5623  UINT width, height, x, y;
5624 
5625  TRACE("(%p, %d, %u, %p, %p, %p, %p)\n", bitmap, format, num_of_entries,
5626  ch0, ch1, ch2, ch3);
5627 
5628  if (!bitmap || num_of_entries != 256)
5629  return InvalidParameter;
5630 
5631  /* Make sure passed channel pointers match requested format */
5632  switch (format)
5633  {
5634  case HistogramFormatARGB:
5635  case HistogramFormatPARGB:
5636  if (!ch0 || !ch1 || !ch2 || !ch3)
5637  return InvalidParameter;
5638  memset(ch0, 0, num_of_entries * sizeof(UINT));
5639  memset(ch1, 0, num_of_entries * sizeof(UINT));
5640  memset(ch2, 0, num_of_entries * sizeof(UINT));
5641  memset(ch3, 0, num_of_entries * sizeof(UINT));
5642  break;
5643  case HistogramFormatRGB:
5644  if (!ch0 || !ch1 || !ch2 || ch3)
5645  return InvalidParameter;
5646  memset(ch0, 0, num_of_entries * sizeof(UINT));
5647  memset(ch1, 0, num_of_entries * sizeof(UINT));
5648  memset(ch2, 0, num_of_entries * sizeof(UINT));
5649  break;
5650  case HistogramFormatGray:
5651  case HistogramFormatB:
5652  case HistogramFormatG:
5653  case HistogramFormatR:
5654  case HistogramFormatA:
5655  if (!ch0 || ch1 || ch2 || ch3)
5656  return InvalidParameter;
5657  memset(ch0, 0, num_of_entries * sizeof(UINT));
5658  break;
5659  default:
5660  WARN("Invalid histogram format requested, %d\n", format);
5661  return InvalidParameter;
5662  }
5663 
5664  GdipGetImageWidth(&bitmap->image, &width);
5665  GdipGetImageHeight(&bitmap->image, &height);
5666 
5667  for (y = 0; y < height; y++)
5668  for (x = 0; x < width; x++)
5669  {
5670  ARGB color;
5671 
5673  set_histogram_point[format](color, ch0, ch1, ch2, ch3);
5674  }
5675 
5676  return Ok;
5677 }
static void set_histogram_point_rgb(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
Definition: image.c:5574
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:2390
#define WARN(fmt,...)
Definition: debug.h:112
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:5601
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:2287
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:5586
static void set_histogram_point_gray(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
Definition: image.c:5581
static void set_histogram_point_r(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
Definition: image.c:5596
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:5591
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:5564
static void set_histogram_point_argb(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
Definition: image.c:5556
DWORD ARGB

◆ GdipBitmapGetHistogramSize()

GpStatus WINGDIPAPI GdipBitmapGetHistogramSize ( HistogramFormat  format,
UINT num_of_entries 
)

Definition at line 5682 of file image.c.

5683 {
5684  TRACE("(%d, %p)\n", format, num_of_entries);
5685 
5686  if (!num_of_entries)
5687  return InvalidParameter;
5688 
5689  *num_of_entries = 256;
5690  return Ok;
5691 }
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:111
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: xxhash.c:193
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 PIXELFORMATBPP(x)
Definition: image.c:45
uint32 width
Definition: uimain.c:91
#define TRUE
Definition: types.h:120
INT Width
Definition: gdiplustypes.h:671
#define WARN(fmt,...)
Definition: debug.h:112
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:58
& rect
Definition: startmenu.cpp:1413
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
INT X
Definition: gdiplustypes.h:669
#define FIXME(fmt,...)
Definition: debug.h:111
static BOOL image_lock(GpImage *image, BOOL *unlock)
Status
Definition: gdiplustypes.h:24
Definition: uimain.c:88
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
Definition: stat.h:55
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
#define NULL
Definition: types.h:112
INT Height
Definition: gdiplustypes.h:672
INT Y
Definition: gdiplustypes.h:670
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:111
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: xxhash.c:193
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 PIXELFORMATBPP(x)
Definition: image.c:45
#define TRUE
Definition: types.h:120
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)
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:111
static BOOL image_lock(GpImage *image, BOOL *unlock)
Status
Definition: gdiplustypes.h:24
Definition: uimain.c:88
#define TRACE(s)
Definition: solgame.cpp:4
Definition: stat.h:55
PixelFormat PixelFormat
#define ERR(fmt,...)
Definition: debug.h:110
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
UINT_PTR Reserved
#define NULL
Definition: types.h:112
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->Flags = src_palette->Flags;
1280  dst_palette->Count = src_palette->Count;
1281  memcpy(dst_palette->Entries, src_palette->Entries, sizeof(ARGB) * src_palette->Count);
1282 
1283  heap_free((*dstBitmap)->image.palette);
1284  (*dstBitmap)->image.palette = dst_palette;
1285  }
1286  else
1287  stat = OutOfMemory;
1288  }
1289 
1290  if (stat != Ok)
1291  GdipDisposeImage(&(*dstBitmap)->image);
1292  }
1293 
1294  if (stat != Ok)
1295  *dstBitmap = <