ReactOS 0.4.15-dev-8116-gf69e256
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++) { \
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);
#define index(s, c)
Definition: various.h:29
DWORD ARGB
@ Ok
Definition: gdiplustypes.h:26
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLuint color
Definition: glext.h:6243
GLuint index
Definition: glext.h:6031
static HPALETTE palette
Definition: clipboard.c:1345
unsigned char BYTE
Definition: xxhash.c:193

◆ 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);
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79

◆ 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);

◆ 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,
4281} ImageFormat;
ImageFormat
Definition: image.c:4271
@ EMF
Definition: image.c:4276
@ WMF
Definition: image.c:4277
@ NUM_CODECS
Definition: image.c:4280
@ BMP
Definition: image.c:4272
@ TIFF
Definition: image.c:4275
@ ICO
Definition: image.c:4279
@ PNG
Definition: image.c:4278
@ GIF
Definition: image.c:4274
@ JPEG
Definition: image.c:4273

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}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define NULL
Definition: types.h:112
GpStatus WINGDIPAPI GdipGetPropertySize(GpImage *image, UINT *size, UINT *count)
Definition: image.c:2735
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static ATOM item
Definition: dde.c:856
unsigned int UINT
Definition: ndis.h:50
Definition: uimain.c:89
Definition: pdh_main.c:94

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}
unsigned long DWORD
Definition: ntddk_ex.h:95
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
GLenum src
Definition: glext.h:6340

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}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static HRESULT get_gif_frame_rect(IWICBitmapFrameDecode *frame, UINT *left, UINT *top, UINT *width, UINT *height)
Definition: image.c:3822
HRESULT WINAPI WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat, IWICBitmapSource *pISrc, IWICBitmapSource **ppIDst)
Definition: info.c:2474
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
GLenum GLenum dst
Definition: glext.h:6340
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
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hr
Definition: shlfolder.c:183
uint32 width
Definition: uimain.c:91
uint32 height
Definition: uimain.c:92

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 {
636 default:
637 break;
638 }
639 break;
641 switch (dst_format)
642 {
663 default:
664 break;
665 }
666 break;
668 switch (dst_format)
669 {
690 default:
691 break;
692 }
693 break;
695 switch (dst_format)
696 {
719 default:
720 break;
721 }
722 break;
724 switch (dst_format)
725 {
748 default:
749 break;
750 }
751 break;
753 switch (dst_format)
754 {
777 default:
778 break;
779 }
780 break;
782 switch (dst_format)
783 {
806 default:
807 break;
808 }
809 break;
811 switch (dst_format)
812 {
835 default:
836 break;
837 }
838 break;
840 switch (dst_format)
841 {
864 default:
865 break;
866 }
867 break;
869 switch (dst_format)
870 {
886 convert_32bppARGB_to_32bppPARGB(width, height, dst_bits, dst_stride, src_bits, src_stride);
887 return Ok;
892 default:
893 break;
894 }
895 break;
897 switch (dst_format)
898 {
921 default:
922 break;
923 }
924 break;
926 switch (dst_format)
927 {
950 default:
951 break;
952 }
953 break;
955 switch (dst_format)
956 {
979 default:
980 break;
981 }
982 break;
984 switch (dst_format)
985 {
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_16bppARGB1555(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:430
static void setpixel_48bppRGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:468
static void setpixel_32bppPARGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:459
#define PIXELFORMATBPP(x)
Definition: image.c:45
static void getpixel_16bppARGB1555(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:202
static void getpixel_64bppPARGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:274
static void getpixel_16bppRGB565(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:192
static void getpixel_4bppIndexed(BYTE *index, const BYTE *row, UINT x)
Definition: image.c:162
static void setpixel_16bppRGB555(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:414
#define convert_rgb_to_indexed(getpixel_function, setpixel_function)
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
static void getpixel_32bppRGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:224
static void getpixel_8bppIndexed(BYTE *index, const BYTE *row, UINT x)
Definition: image.c:170
#define convert_indexed_to_rgb(getpixel_function, setpixel_function)
static void getpixel_64bppARGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:265
static void getpixel_48bppRGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:256
static void setpixel_16bppGrayScale(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:408
static void getpixel_16bppGrayScale(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:175
static void setpixel_64bppARGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:476
static void getpixel_24bppRGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:215
#define convert_rgb_to_rgb(getpixel_function, setpixel_function)
static void setpixel_32bppARGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:453
static void setpixel_16bppRGB565(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:422
static void getpixel_16bppRGB555(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:182
static void setpixel_1bppIndexed(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x, ColorPalette *palette)
Definition: image.c:393
static void getpixel_32bppARGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:233
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_24bppRGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:439
static void getpixel_32bppPARGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a, const BYTE *row, UINT x)
Definition: image.c:242
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
#define PixelFormat32bppPARGB
#define PixelFormat64bppARGB
#define PixelFormat32bppRGB
#define PixelFormat4bppIndexed
#define PixelFormat64bppPARGB
#define PixelFormat16bppRGB555
#define PixelFormat16bppARGB1555
#define PixelFormat16bppGrayScale
#define PixelFormat8bppIndexed
#define PixelFormat24bppRGB
#define PixelFormat16bppRGB565
#define PixelFormat1bppIndexed
#define PixelFormat32bppARGB
#define PixelFormat48bppRGB
@ NotImplemented
Definition: gdiplustypes.h:32
static const char * dst_format
Definition: dib.c:1133
int32_t INT
Definition: typedefs.h:58

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{
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 {
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 WINGDIPAPI GdipBitmapLockBits(GpBitmap *bitmap, GDIPCONST GpRect *rect, UINT flags, PixelFormat format, BitmapData *lockeddata)
Definition: image.c:1030
HRESULT WINAPI WICCreateImagingFactory_Proxy(UINT, IWICImagingFactory **)
Definition: proxy.c:651
GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap *bitmap, BitmapData *lockeddata)
Definition: image.c:1176
GpStatus hresult_to_status(HRESULT res)
Definition: gdiplus.c:312
@ ImageLockModeRead
Status
Definition: gdiplustypes.h:25
@ InvalidParameter
Definition: gdiplustypes.h:28
@ GenericError
Definition: gdiplustypes.h:27
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define S_OK
Definition: intsafe.h:52
int desired
Definition: jpeglib.h:1119
Definition: main.c:439
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{
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}
static UINT propvariant_size(PROPVARIANT *value)
Definition: image.c:2502
static GpStatus propvariant_to_item(PROPVARIANT *value, PropertyItem *item, UINT size, PROPID id)
Definition: image.c:2619

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{
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
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}
GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride, PixelFormat format, BYTE *scan0, GpBitmap **bitmap)
Definition: image.c:1760
static const struct @419 pixel_formats[]
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
Definition: image.c:2155
const WICPixelFormatGUID * wic_format
Definition: image.c:50
WICBitmapPaletteType palette_type
Definition: image.c:53
PixelFormat gdip_format
Definition: image.c:51
static ColorPalette * get_palette(IWICBitmapFrameDecode *frame, WICBitmapPaletteType palette_type)
Definition: image.c:74
#define abs(i)
Definition: fconv.c:206
@ ImageFlagsHasRealDPI
Definition: gdiplusenums.h:343
@ ImageFlagsHasRealPixelSize
Definition: gdiplusenums.h:344
@ ImageFlagsReadOnly
Definition: gdiplusenums.h:345
@ ImageFlagsColorSpaceRGB
Definition: gdiplusenums.h:338
@ ImageFlagsColorSpaceGRAY
Definition: gdiplusenums.h:340
@ ImageLockModeWrite
INT PixelFormat
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197
#define TRACE(s)
Definition: solgame.cpp:4
INT Height
Definition: wincodec.idl:301
INT Width
Definition: wincodec.idl:300
WICBitmapPaletteType
Definition: wincodec.idl:90
@ WICBitmapPaletteTypeFixedHalftone256
Definition: wincodec.idl:101

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{
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
Definition: parse.h:23

◆ decode_image_emf()

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

Definition at line 4234 of file image.c.

4235{
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 GpStatus load_emf(IStream *stream, GpMetafile **metafile)
Definition: image.c:4195
static const unsigned char metafile[]
Definition: olepicture.c:138

◆ 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;
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}
static GpStatus initialize_decoder_wic(IStream *stream, REFGUID container, IWICBitmapDecoder **decoder)
Definition: image.c:3612
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 void gif_metadata_reader(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UINT active_frame)
Definition: image.c:3294

◆ 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}

◆ 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}

◆ 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;
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}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static void png_metadata_reader(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UINT active_frame)
Definition: image.c:3461
static BOOL has_png_transparency_chunk(IStream *pIStream)
Definition: image.c:4006
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546

◆ 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}

◆ 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;
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}

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{
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 GpStatus load_wmf(IStream *stream, GpMetafile **metafile)
Definition: image.c:4114

◆ 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}
static GpStatus encode_image_wic(GpImage *image, IStream *stream, REFGUID container, GDIPCONST EncoderParameters *params)
Definition: image.c:4503
GLenum const GLfloat * params
Definition: glext.h:5645

◆ 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}

◆ 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}

◆ 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}

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}

◆ 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;
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}
#define stat
Definition: acwin.h:99
#define ERR(fmt,...)
Definition: debug.h:113
#define E_FAIL
Definition: ddrawi.h:102
GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width)
Definition: image.c:2390
GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height)
Definition: image.c:2287
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
@ ImageTypeBitmap
Definition: gdiplusenums.h:195
#define debugstr_guid
Definition: kernel32.h:35
INT Width
Definition: gdiplustypes.h:671
INT Height
Definition: gdiplustypes.h:672
INT X
Definition: gdiplustypes.h:669
INT Y
Definition: gdiplustypes.h:670
Definition: stat.h:55
@ WICBitmapEncoderNoCache
Definition: wincodec.idl:72

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}
static HBITMAP hbitmap
#define WARN(fmt,...)
Definition: debug.h:115
pKey DeleteObject()
void METAFILE_Free(GpMetafile *metafile) DECLSPEC_HIDDEN
Definition: metafile.c:590
@ ImageTypeMetafile
Definition: gdiplusenums.h:196
@ ObjectBusy
Definition: gdiplustypes.h:30
HDC hdc
Definition: main.c:9
BOOL WINAPI DeleteDC(_In_ HDC)

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:114

◆ 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}

◆ 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}

◆ 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 {
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;
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_g(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
Definition: image.c:5591
static void set_histogram_point_rgb(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
Definition: image.c:5574
static void set_histogram_point_argb(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
Definition: image.c:5556
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_a(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
Definition: image.c:5601
GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap *bitmap, INT x, INT y, ARGB *color)
Definition: image.c:288
static void set_histogram_point_r(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
Definition: image.c:5596
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_b(ARGB color, UINT *ch0, UINT *ch1, UINT *ch2, UINT *ch3)
Definition: image.c:5586
@ HistogramFormatRGB
@ HistogramFormatPARGB
@ HistogramFormatB
@ HistogramFormatA
@ HistogramFormatARGB
@ HistogramFormatR
@ HistogramFormatGray
@ HistogramFormatG
#define memset(x, y, z)
Definition: compat.h:39

◆ 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}

◆ 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;
317 break;
320 break;
323 break;
325 getpixel_24bppRGB(&r,&g,&b,&a,row,x);
326 break;
328 getpixel_32bppRGB(&r,&g,&b,&a,row,x);
329 break;
332 break;
335 break;
337 getpixel_48bppRGB(&r,&g,&b,&a,row,x);
338 break;
341 break;
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}
#define PixelFormatIndexed

Referenced by alpha_blend_bmp_pixels(), GdipBitmapGetHistogram(), 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. */
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. */
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
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}
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)
static BOOL image_lock(GpImage *image, BOOL *unlock)
@ ImageLockModeUserInputBuf
@ WrongState
Definition: gdiplustypes.h:34
@ OutOfMemory
Definition: gdiplustypes.h:29
GLbitfield flags
Definition: glext.h:7161
& rect
Definition: startmenu.cpp:1413
UINT_PTR Reserved
PixelFormat PixelFormat

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(), 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;
526 break;
529 break;
532 break;
535 break;
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_64bppPARGB(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x)
Definition: image.c:483
static void setpixel_4bppIndexed(BYTE r, BYTE g, BYTE b, BYTE a, BYTE *row, UINT x, ColorPalette *palette)
Definition: image.c:399

Referenced by alpha_blend_bmp_pixels(), 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}

Referenced by create_graphics(), 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}

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(), and test_pen_thickness().

◆ 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
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 = NULL;
1296
1297 return stat;
1298}
static INT gdip_round(REAL x)
#define PixelFormatDontCare
static Real area(Real A[2], Real B[2], Real C[2])
Definition: polyDBG.cc:50
GpImage image
PixelFormat format
ColorPalette * palette
ImageType type

Referenced by GdipCloneBitmapAreaI(), and GdipCreateTextureIA().

◆ GdipCloneBitmapAreaI()

GpStatus WINGDIPAPI GdipCloneBitmapAreaI ( INT  x,
INT  y,
INT  width,
INT  height,
PixelFormat  format,
GpBitmap srcBitmap,
GpBitmap **  dstBitmap 
)

Definition at line 1300 of file image.c.

1302{
1303 TRACE("(%i,%i,%i,%i,0x%x,%p,%p)\n", x, y, width, height, format, srcBitmap, dstBitmap);
1304
1305 return GdipCloneBitmapArea(x, y, width, height, format, srcBitmap, dstBitmap);
1306}
GpStatus WINGDIPAPI GdipCloneBitmapArea(REAL x, REAL y, REAL width, REAL height, PixelFormat format, GpBitmap *srcBitmap, GpBitmap **dstBitmap)
Definition: image.c:1237

Referenced by GdipCloneImage(), and test_CloneBitmapArea().

◆ GdipCloneImage()

GpStatus WINGDIPAPI GdipCloneImage ( GpImage image,
GpImage **  cloneImage 
)

Definition at line 1308 of file image.c.

1309{
1310 TRACE("%p, %p\n", image, cloneImage);
1311
1312 if (!image || !cloneImage)
1313 return InvalidParameter;
1314
1315 if (image->type == ImageTypeBitmap)
1316 {
1318
1320 bitmap->format, bitmap, (GpBitmap **)cloneImage);
1321 }
1322 else if (image->type == ImageTypeMetafile && ((GpMetafile*)image)->hemf)
1323 {
1325
1327
1328 result = heap_alloc_zero(sizeof(*result));
1329 if (!result)
1330 return OutOfMemory;
1331
1332 result->image.type = ImageTypeMetafile;
1333 result->image.format = image->format;
1334 result->image.flags = image->flags;
1335 result->image.frame_count = 1;
1336 result->image.xres = image->xres;
1337 result->image.yres = image->yres;
1338 result->bounds = metafile->bounds;
1339 result->unit = metafile->unit;
1340 result->metafile_type = metafile->metafile_type;
1341 result->hemf = CopyEnhMetaFileW(metafile->hemf, NULL);
1342 list_init(&result->containers);
1343
1344 if (!result->hemf)
1345 {
1347 return OutOfMemory;
1348 }
1349
1350 *cloneImage = &result->image;
1351 return Ok;
1352 }
1353 else
1354 {
1355 WARN("GpImage with no image data (metafile in wrong state?)\n");
1356 return InvalidParameter;
1357 }
1358}
static void list_init(struct list_entry *head)
Definition: list.h:51
GpStatus WINGDIPAPI GdipCloneBitmapAreaI(INT x, INT y, INT width, INT height, PixelFormat format, GpBitmap *srcBitmap, GpBitmap **dstBitmap)
Definition: image.c:1300
GLuint64EXT * result
Definition: glext.h:11304
HENHMETAFILE WINAPI CopyEnhMetaFileW(_In_ HENHMETAFILE hemfSrc, _In_opt_ LPCWSTR pszFile)

Referenced by GdipCreateCachedBitmap(), GdipGetTextureImage(), load_image(), sync_metafile(), test_emfonly(), and test_GdipCloneImage().

◆ GdipCreateBitmapFromFile()

GpStatus WINGDIPAPI GdipCreateBitmapFromFile ( GDIPCONST WCHAR filename,
GpBitmap **  bitmap 
)

Definition at line 1360 of file image.c.

1362{
1363 GpStatus stat;
1364 IStream *stream;
1365
1366 TRACE("(%s) %p\n", debugstr_w(filename), bitmap);
1367
1368 if(!filename || !bitmap)
1369 return InvalidParameter;
1370
1371 *bitmap = NULL;
1372
1374
1375 if(stat != Ok)
1376 return stat;
1377
1379
1380 IStream_Release(stream);
1381
1382 return stat;
1383}
#define GENERIC_READ
Definition: compat.h:135
GpStatus WINGDIPAPI GdipCreateStreamOnFile(GDIPCONST WCHAR *filename, UINT access, IStream **stream)
Definition: graphics.c:2558
GpStatus WINGDIPAPI GdipCreateBitmapFromStream(IStream *stream, GpBitmap **bitmap)
Definition: image.c:1935
const char * filename
Definition: ioapi.h:137
#define debugstr_w
Definition: kernel32.h:32

Referenced by DibLoadImage(), GdipCreateBitmapFromFileICM(), and test_LoadingImages().

◆ GdipCreateBitmapFromFileICM()

GpStatus WINGDIPAPI GdipCreateBitmapFromFileICM ( GDIPCONST WCHAR filename,
GpBitmap **  bitmap 
)

Definition at line 1436 of file image.c.

1438{
1439 TRACE("(%s) %p\n", debugstr_w(filename), bitmap);
1440
1442}
GpStatus WINGDIPAPI GdipCreateBitmapFromFile(GDIPCONST WCHAR *filename, GpBitmap **bitmap)
Definition: image.c:1360

◆ GdipCreateBitmapFromGdiDib()

GpStatus WINGDIPAPI GdipCreateBitmapFromGdiDib ( GDIPCONST BITMAPINFO info,
VOID bits,
GpBitmap **  bitmap 
)

Definition at line 1385 of file image.c.

1387{
1390
1391 FIXME("(%p, %p, %p) - partially implemented\n", info, bits, bitmap);
1392
1393 if (!info || !bits || !bitmap)
1394 return InvalidParameter;
1395
1396 height = abs(info->bmiHeader.biHeight);
1397 stride = ((info->bmiHeader.biWidth * info->bmiHeader.biBitCount + 31) >> 3) & ~3;
1398
1399 if(info->bmiHeader.biHeight > 0) /* bottom-up */
1400 {
1401 bits = (BYTE*)bits + (height - 1) * stride;
1402 stride = -stride;
1403 }
1404
1405 switch(info->bmiHeader.biBitCount) {
1406 case 1:
1408 break;
1409 case 4:
1411 break;
1412 case 8:
1414 break;
1415 case 16:
1417 break;
1418 case 24:
1420 break;
1421 case 32:
1423 break;
1424 default:
1425 FIXME("don't know how to handle %d bpp\n", info->bmiHeader.biBitCount);
1426 *bitmap = NULL;
1427 return InvalidParameter;
1428 }
1429
1430 return GdipCreateBitmapFromScan0(info->bmiHeader.biWidth, height, stride, format,
1431 bits, bitmap);
1432
1433}
GLsizei stride
Definition: glext.h:5848
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929

Referenced by test_drawimage(), test_FromGdiDib(), and test_GdipDrawImagePointsRect().

◆ GdipCreateBitmapFromGraphics()

GpStatus WINGDIPAPI GdipCreateBitmapFromGraphics ( INT  width,
INT  height,
GpGraphics target,
GpBitmap **  bitmap 
)

Definition at line 1542 of file image.c.

1544{
1545 GpStatus ret;
1546
1547 TRACE("(%d, %d, %p, %p)\n", width, height, target, bitmap);
1548
1549 if(!target || !bitmap)
1550 return InvalidParameter;
1551
1553 NULL, bitmap);
1554
1555 if (ret == Ok)
1556 {
1557 GdipGetDpiX(target, &(*bitmap)->image.xres);
1558 GdipGetDpiY(target, &(*bitmap)->image.yres);
1559 }
1560
1561 return ret;
1562}
GpStatus WINGDIPAPI GdipGetDpiX(GpGraphics *graphics, REAL *dpi)
Definition: graphics.c:6621
GpStatus WINGDIPAPI GdipGetDpiY(GpGraphics *graphics, REAL *dpi)
Definition: graphics.c:6635
GLenum target
Definition: glext.h:7315
int ret

Referenced by test_bitmapfromgraphics(), test_texturewrap(), and test_transform().

◆ GdipCreateBitmapFromHBITMAP()

GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP ( HBITMAP  hbm,
HPALETTE  hpal,
GpBitmap **  bitmap 
)

Definition at line 5152 of file image.c.

5153{
5154 BITMAP bm;
5155 GpStatus retval;
5157 BitmapData lockeddata;
5158
5159 TRACE("%p %p %p\n", hbm, hpal, bitmap);
5160
5161 if(!hbm || !bitmap)
5162 return InvalidParameter;
5163
5164 if (GetObjectA(hbm, sizeof(bm), &bm) != sizeof(bm))
5165 return InvalidParameter;
5166
5167 /* TODO: Figure out the correct format for 16, 32, 64 bpp */
5168 switch(bm.bmBitsPixel) {
5169 case 1:
5171 break;
5172 case 4:
5174 break;
5175 case 8:
5177 break;
5178 case 16:
5181 return InvalidParameter;
5182 break;
5183 case 24:
5185 break;
5186 case 32:
5188 break;
5189 case 48:
5191 break;
5192 default:
5193 FIXME("don't know how to handle %d bpp\n", bm.bmBitsPixel);
5194 return InvalidParameter;
5195 }
5196
5197 retval = GdipCreateBitmapFromScan0(bm.bmWidth, bm.bmHeight, 0,
5198 format, NULL, bitmap);
5199
5200 if (retval == Ok)
5201 {
5203 format, &lockeddata);
5204 if (retval == Ok)
5205 {
5206 HDC hdc;
5207 char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors) + 256 * sizeof(RGBQUAD)];
5208 BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf;
5209 INT src_height;
5210
5212
5215
5217
5218 src_height = abs(pbmi->bmiHeader.biHeight);
5219 pbmi->bmiHeader.biHeight = -src_height;
5220
5221 GetDIBits(hdc, hbm, 0, src_height, lockeddata.Scan0, pbmi, DIB_RGB_COLORS);
5222
5223 DeleteDC(hdc);
5224
5225 GdipBitmapUnlockBits(*bitmap, &lockeddata);
5226 }
5227
5228 if (retval == Ok && hpal)
5229 {
5230 PALETTEENTRY entry[256];
5232 int i, num_palette_entries;
5233
5234 num_palette_entries = GetPaletteEntries(hpal, 0, 256, entry);
5235 if (!num_palette_entries)
5236 retval = GenericError;
5237
5238 palette = heap_alloc_zero(sizeof(ColorPalette) + sizeof(ARGB) * (num_palette_entries-1));
5239 if (!palette)
5240 retval = OutOfMemory;
5241
5242 if (retval == Ok)
5243 {
5244 palette->Flags = 0;
5245 palette->Count = num_palette_entries;
5246
5247 for (i=0; i<num_palette_entries; i++)
5248 {
5249 palette->Entries[i] = 0xff000000 | entry[i].peRed << 16 |
5250 entry[i].peGreen << 8 | entry[i].peBlue;
5251 }
5252
5253 retval = GdipSetImagePalette(&(*bitmap)->image, palette);
5254 }
5255
5257 }
5258
5259 if (retval != Ok)
5260 {
5261 GdipDisposeImage(&(*bitmap)->image);
5262 *bitmap = NULL;
5263 }
5264 }
5265
5266 return retval;
5267}
GpStatus WINGDIPAPI GdipSetImagePalette(GpImage *image, GDIPCONST ColorPalette *palette)
Definition: image.c:4744
static PixelFormat get_16bpp_format(HBITMAP hbm)
Definition: image.c:5108
ULONG RGBQUAD
Definition: precomp.h:59
#define PixelFormatUndefined
uint32_t entry
Definition: isohybrid.c:63
static HDC
Definition: imagelist.c:92
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
Definition: bl.h:1331
USHORT biBitCount
Definition: precomp.h:46
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
UINT WINAPI GetPaletteEntries(HPALETTE hpal, UINT iStartIndex, UINT cEntries, LPPALETTEENTRY ppe)
Definition: palette.c:64
#define DIB_RGB_COLORS
Definition: wingdi.h:367
int WINAPI GetObjectA(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)

Referenced by GdipCreateBitmapFromResource(), GdipCreateBitmapFromStream(), and test_GdipCreateBitmapFromHBITMAP().

◆ GdipCreateBitmapFromHICON()

GpStatus WINGDIPAPI GdipCreateBitmapFromHICON ( HICON  hicon,
GpBitmap **  bitmap 
)

Definition at line 1564 of file image.c.

1565{
1566 GpStatus stat;
1567 ICONINFO iinfo;
1568 BITMAP bm;
1569 int ret;
1571 GpRect rect;
1572 BitmapData lockeddata;
1573 HDC screendc;
1574 BOOL has_alpha;
1575 int x, y;
1576 BITMAPINFOHEADER bih;
1577 DWORD *src;
1578 BYTE *dst_row;
1579 DWORD *dst;
1580
1581 TRACE("%p, %p\n", hicon, bitmap);
1582
1583 if(!bitmap || !GetIconInfo(hicon, &iinfo))
1584 return InvalidParameter;
1585
1586 /* get the size of the icon */
1587 ret = GetObjectA(iinfo.hbmColor ? iinfo.hbmColor : iinfo.hbmMask, sizeof(bm), &bm);
1588 if (ret == 0) {
1589 DeleteObject(iinfo.hbmColor);
1590 DeleteObject(iinfo.hbmMask);
1591 return GenericError;
1592 }
1593
1594 width = bm.bmWidth;
1595 height = iinfo.hbmColor ? abs(bm.bmHeight) : abs(bm.bmHeight) / 2;
1596 stride = width * 4;
1597
1599 if (stat != Ok) {
1600 DeleteObject(iinfo.hbmColor);
1601 DeleteObject(iinfo.hbmMask);
1602 return stat;
1603 }
1604
1605 rect.X = 0;
1606 rect.Y = 0;
1607 rect.Width = width;
1608 rect.Height = height;
1609
1611 if (stat != Ok) {
1612 DeleteObject(iinfo.hbmColor);
1613 DeleteObject(iinfo.hbmMask);
1614 GdipDisposeImage(&(*bitmap)->image);
1615 return stat;
1616 }
1617
1618 bih.biSize = sizeof(bih);
1619 bih.biWidth = width;
1620 bih.biHeight = iinfo.hbmColor ? -height: -height * 2;
1621 bih.biPlanes = 1;
1622 bih.biBitCount = 32;
1623 bih.biCompression = BI_RGB;
1624 bih.biSizeImage = 0;
1625 bih.biXPelsPerMeter = 0;
1626 bih.biYPelsPerMeter = 0;
1627 bih.biClrUsed = 0;
1628 bih.biClrImportant = 0;
1629
1630 screendc = CreateCompatibleDC(0);
1631 if (iinfo.hbmColor)
1632 {
1633 GetDIBits(screendc, iinfo.hbmColor, 0, height, lockeddata.Scan0, (BITMAPINFO*)&bih, DIB_RGB_COLORS);
1634
1635 if (bm.bmBitsPixel == 32)
1636 {
1637 has_alpha = FALSE;
1638
1639 /* If any pixel has a non-zero alpha, ignore hbmMask */
1640 src = (DWORD*)lockeddata.Scan0;
1641 for (x=0; x<width && !has_alpha; x++)
1642 for (y=0; y<height && !has_alpha; y++)
1643 if ((*src++ & 0xff000000) != 0)
1644 has_alpha = TRUE;
1645 }
1646 else has_alpha = FALSE;
1647 }
1648 else
1649 {
1650 GetDIBits(screendc, iinfo.hbmMask, 0, height, lockeddata.Scan0, (BITMAPINFO*)&bih, DIB_RGB_COLORS);
1651 has_alpha = FALSE;
1652 }
1653
1654 if (!has_alpha)
1655 {
1656 if (iinfo.hbmMask)
1657 {
1659
1660 /* read alpha data from the mask */
1661 if (iinfo.hbmColor)
1662 GetDIBits(screendc, iinfo.hbmMask, 0, height, bits, (BITMAPINFO*)&bih, DIB_RGB_COLORS);
1663 else
1664 GetDIBits(screendc, iinfo.hbmMask, height, height, bits, (BITMAPINFO*)&bih, DIB_RGB_COLORS);
1665
1666 src = (DWORD*)bits;
1667 dst_row = lockeddata.Scan0;
1668 for (y=0; y<height; y++)
1669 {
1670 dst = (DWORD*)dst_row;
1671 for (x=0; x<height; x++)
1672 {
1673 DWORD src_value = *src++;
1674 if (src_value)
1675 *dst++ = 0;
1676 else
1677 *dst++ |= 0xff000000;
1678 }
1679 dst_row += lockeddata.Stride;
1680 }
1681
1682 heap_free(bits);
1683 }
1684 else
1685 {
1686 /* set constant alpha of 255 */
1687 dst_row = lockeddata.Scan0;
1688 for (y=0; y<height; y++)
1689 {
1690 dst = (DWORD*)dst_row;
1691 for (x=0; x<height; x++)
1692 *dst++ |= 0xff000000;
1693 dst_row += lockeddata.Stride;
1694 }
1695 }
1696 }
1697
1698 DeleteDC(screendc);
1699
1700 DeleteObject(iinfo.hbmColor);
1701 DeleteObject(iinfo.hbmMask);
1702
1703 GdipBitmapUnlockBits(*bitmap, &lockeddata);
1704
1705 return Ok;
1706}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
#define BI_RGB
Definition: precomp.h:56
#define for
Definition: utility.h:88
LONG biYPelsPerMeter
Definition: amvideo.idl:38
DWORD biCompression
Definition: amvideo.idl:35
DWORD biClrImportant
Definition: amvideo.idl:40
LONG biXPelsPerMeter
Definition: amvideo.idl:37
DWORD biSizeImage
Definition: amvideo.idl:36
HBITMAP hbmColor
Definition: winuser.h:3127
HBITMAP hbmMask
Definition: winuser.h:3126
BOOL WINAPI GetIconInfo(_In_ HICON, _Out_ PICONINFO)
Definition: cursoricon.c:2076

Referenced by test_fromhicon().

◆ GdipCreateBitmapFromResource()

GpStatus WINGDIPAPI GdipCreateBitmapFromResource ( HINSTANCE  hInstance,
GDIPCONST WCHAR lpBitmapName,
GpBitmap **  bitmap 
)

Definition at line 1444 of file image.c.

1446{
1447 HBITMAP hbm;
1449
1450 TRACE("%p (%s) %p\n", hInstance, debugstr_w(lpBitmapName), bitmap);
1451
1452 if(!lpBitmapName || !bitmap)
1453 return InvalidParameter;
1454
1455 /* load DIB */
1456 hbm = LoadImageW(hInstance, lpBitmapName, IMAGE_BITMAP, 0, 0,
1458
1459 if(hbm){
1462 }
1463
1464 return stat;
1465}
HINSTANCE hInstance
Definition: charmap.c:19
GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBitmap **bitmap)
Definition: image.c:5152
static HBITMAP
Definition: button.c:44
#define IMAGE_BITMAP
Definition: winuser.h:211
#define LR_CREATEDIBSECTION
Definition: winuser.h:1098
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2234

◆ GdipCreateBitmapFromScan0()

GpStatus WINGDIPAPI GdipCreateBitmapFromScan0 ( INT  width,
INT  height,
INT  stride,
PixelFormat  format,
BYTE scan0,
GpBitmap **  bitmap 
)

Definition at line 1760 of file image.c.

1762{
1764 INT row_size, dib_stride;
1765 BYTE *bits=NULL, *own_bits=NULL;
1766 REAL xres, yres;
1767 GpStatus stat;
1768
1769 TRACE("%d %d %d 0x%x %p %p\n", width, height, stride, format, scan0, bitmap);
1770
1771 if (!bitmap) return InvalidParameter;
1772
1773 if(width <= 0 || height <= 0 || (scan0 && (stride % 4))){
1774 *bitmap = NULL;
1775 return InvalidParameter;
1776 }
1777
1778 if(scan0 && !stride)
1779 return InvalidParameter;
1780
1781 stat = get_screen_resolution(&xres, &yres);
1782 if (stat != Ok) return stat;
1783
1784 row_size = (width * PIXELFORMATBPP(format)+7) / 8;
1785 dib_stride = (row_size + 3) & ~3;
1786
1787 if(stride == 0)
1788 stride = dib_stride;
1789
1791 {
1792 char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors) + 256 * sizeof(RGBQUAD)];
1793 BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf;
1794
1798 pbmi->bmiHeader.biPlanes = 1;
1799 /* FIXME: use the rest of the data from format */
1807
1808 hbitmap = CreateDIBSection(0, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
1809
1810 if (!hbitmap) return GenericError;
1811
1812 stride = dib_stride;
1813 }
1814 else
1815 {
1816 /* Not a GDI format; don't try to make an HBITMAP. */
1817 if (scan0)
1818 bits = scan0;
1819 else
1820 {
1821 INT size = abs(stride) * height;
1822
1823 own_bits = bits = heap_alloc_zero(size);
1824 if (!own_bits) return OutOfMemory;
1825
1826 if (stride < 0)
1827 bits += stride * (1 - height);
1828 }
1829 }
1830
1831 *bitmap = heap_alloc_zero(sizeof(GpBitmap));
1832 if(!*bitmap)
1833 {
1835 heap_free(own_bits);
1836 return OutOfMemory;
1837 }
1838
1839 (*bitmap)->image.type = ImageTypeBitmap;
1840 memcpy(&(*bitmap)->image.format, &ImageFormatMemoryBMP, sizeof(GUID));
1841 (*bitmap)->image.flags = ImageFlagsNone;
1842 (*bitmap)->image.frame_count = 1;
1843 (*bitmap)->image.current_frame = 0;
1844 (*bitmap)->image.palette = NULL;
1845 (*bitmap)->image.xres = xres;
1846 (*bitmap)->image.yres = yres;
1847 (*bitmap)->width = width;
1848 (*bitmap)->height = height;
1849 (*bitmap)->format = format;
1850 (*bitmap)->image.decoder = NULL;
1851 (*bitmap)->hbitmap = hbitmap;
1852 (*bitmap)->hdc = NULL;
1853 (*bitmap)->bits = bits;
1854 (*bitmap)->stride = stride;
1855 (*bitmap)->own_bits = own_bits;
1856 (*bitmap)->metadata_reader = NULL;
1857 (*bitmap)->prop_count = 0;
1858 (*bitmap)->prop_item = NULL;
1859
1860 /* set format-related flags */
1862 (*bitmap)->image.flags |= ImageFlagsHasAlpha;
1863
1867 {
1868 (*bitmap)->image.palette = heap_alloc_zero(sizeof(UINT) * 2 + sizeof(ARGB) * (1 << PIXELFORMATBPP(format)));
1869
1870 if (!(*bitmap)->image.palette)