[GDIPLUS] Sync with Wine 3.0. CORE-14225
[reactos.git] / dll / win32 / gdiplus / image.c
index 214b95f..6390bff 100644 (file)
@@ -38,19 +38,13 @@ static const struct
 {
     { &GUID_WICPixelFormatBlackWhite, PixelFormat1bppIndexed, WICBitmapPaletteTypeFixedBW },
     { &GUID_WICPixelFormat1bppIndexed, PixelFormat1bppIndexed, WICBitmapPaletteTypeFixedBW },
-    { &GUID_WICPixelFormat4bppIndexed, PixelFormat4bppIndexed, WICBitmapPaletteTypeFixedHalftone8 },
     { &GUID_WICPixelFormat8bppGray, PixelFormat8bppIndexed, WICBitmapPaletteTypeFixedGray256 },
     { &GUID_WICPixelFormat8bppIndexed, PixelFormat8bppIndexed, WICBitmapPaletteTypeFixedHalftone256 },
     { &GUID_WICPixelFormat16bppBGR555, PixelFormat16bppRGB555, WICBitmapPaletteTypeFixedHalftone256 },
     { &GUID_WICPixelFormat24bppBGR, PixelFormat24bppRGB, WICBitmapPaletteTypeFixedHalftone256 },
     { &GUID_WICPixelFormat32bppBGR, PixelFormat32bppRGB, WICBitmapPaletteTypeFixedHalftone256 },
-    { &GUID_WICPixelFormat48bppRGB, PixelFormat48bppRGB, WICBitmapPaletteTypeFixedHalftone256 },
     { &GUID_WICPixelFormat32bppBGRA, PixelFormat32bppARGB, WICBitmapPaletteTypeFixedHalftone256 },
     { &GUID_WICPixelFormat32bppPBGRA, PixelFormat32bppPARGB, WICBitmapPaletteTypeFixedHalftone256 },
-    { &GUID_WICPixelFormat32bppCMYK, PixelFormat32bppCMYK, WICBitmapPaletteTypeFixedHalftone256 },
-    { &GUID_WICPixelFormat32bppGrayFloat, PixelFormat32bppARGB, WICBitmapPaletteTypeFixedGray256 },
-    { &GUID_WICPixelFormat64bppCMYK, PixelFormat48bppRGB, WICBitmapPaletteTypeFixedHalftone256 },
-    { &GUID_WICPixelFormat64bppRGBA, PixelFormat48bppRGB, WICBitmapPaletteTypeFixedHalftone256 },
     { NULL }
 };
 
@@ -2074,24 +2068,7 @@ static GpStatus free_image_data(GpImage *image)
         heap_free(((GpBitmap*)image)->prop_item);
     }
     else if (image->type == ImageTypeMetafile)
-    {
-        GpMetafile *metafile = (GpMetafile*)image;
-        heap_free(metafile->comment_data);
-        DeleteEnhMetaFile(CloseEnhMetaFile(metafile->record_dc));
-        if (!metafile->preserve_hemf)
-            DeleteEnhMetaFile(metafile->hemf);
-        if (metafile->record_graphics)
-        {
-            WARN("metafile closed while recording\n");
-            /* not sure what to do here; for now just prevent the graphics from functioning or using this object */
-            metafile->record_graphics->image = NULL;
-            metafile->record_graphics->busy = TRUE;
-        }
-        if (metafile->record_stream)
-        {
-            IStream_Release(metafile->record_stream);
-        }
-    }
+        METAFILE_Free((GpMetafile *)image);
     else
     {
         WARN("invalid image: %p\n", image);
@@ -4568,7 +4545,7 @@ static GpStatus encode_image_jpeg(GpImage *image, IStream* stream,
 static GpStatus encode_image_gif(GpImage *image, IStream* stream,
     GDIPCONST EncoderParameters* params)
 {
-    return encode_image_wic(image, stream, &GUID_ContainerFormatGif, params);
+    return encode_image_wic(image, stream, &CLSID_WICGifEncoder, params);
 }
 
 /*****************************************************************************
@@ -4581,7 +4558,7 @@ GpStatus WINGDIPAPI GdipSaveImageToStream(GpImage *image, IStream* stream,
     encode_image_func encode_image;
     int i;
 
-    TRACE("%p %p %s %p\n", image, stream, wine_dbgstr_guid(clsid), params);
+    TRACE("%p %p %p %p\n", image, stream, clsid, params);
 
     if(!image || !stream)
         return InvalidParameter;
@@ -5595,111 +5572,3 @@ GpStatus WINGDIPAPI GdipBitmapGetHistogramSize(HistogramFormat format, UINT *num
     *num_of_entries = 256;
     return Ok;
 }
-
-static GpStatus create_optimal_palette(ColorPalette *palette, INT desired,
-    BOOL transparent, GpBitmap *bitmap)
-{
-    GpStatus status;
-    BitmapData data;
-    HRESULT hr;
-    IWICImagingFactory *factory;
-    IWICPalette *wic_palette;
-
-    if (!bitmap) return InvalidParameter;
-    if (palette->Count < desired) return GenericError;
-
-    status = GdipBitmapLockBits(bitmap, NULL, ImageLockModeRead, PixelFormat24bppRGB, &data);
-    if (status != Ok) return status;
-
-    hr = WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory);
-    if (hr != S_OK)
-    {
-        GdipBitmapUnlockBits(bitmap, &data);
-        return hresult_to_status(hr);
-    }
-
-    hr = IWICImagingFactory_CreatePalette(factory, &wic_palette);
-    if (hr == S_OK)
-    {
-        IWICBitmap *bitmap;
-
-        /* PixelFormat24bppRGB actually stores the bitmap bits as BGR. */
-        hr = IWICImagingFactory_CreateBitmapFromMemory(factory, data.Width, data.Height,
-                &GUID_WICPixelFormat24bppBGR, data.Stride, data.Stride * data.Width, data.Scan0, &bitmap);
-        if (hr == S_OK)
-        {
-            hr = IWICPalette_InitializeFromBitmap(wic_palette, (IWICBitmapSource *)bitmap, desired, transparent);
-            if (hr == S_OK)
-            {
-                palette->Flags = 0;
-                IWICPalette_GetColorCount(wic_palette, &palette->Count);
-                IWICPalette_GetColors(wic_palette, palette->Count, palette->Entries, &palette->Count);
-            }
-
-            IWICBitmap_Release(bitmap);
-        }
-
-        IWICPalette_Release(wic_palette);
-    }
-
-    IWICImagingFactory_Release(factory);
-    GdipBitmapUnlockBits(bitmap, &data);
-
-    return hresult_to_status(hr);
-}
-
-/*****************************************************************************
- * GdipInitializePalette [GDIPLUS.@]
- */
-GpStatus WINGDIPAPI GdipInitializePalette(ColorPalette *palette,
-    PaletteType type, INT desired, BOOL transparent, GpBitmap *bitmap)
-{
-    TRACE("(%p,%d,%d,%d,%p)\n", palette, type, desired, transparent, bitmap);
-
-    if (!palette) return InvalidParameter;
-
-    switch (type)
-    {
-    case PaletteTypeCustom:
-        return Ok;
-
-    case PaletteTypeOptimal:
-        return create_optimal_palette(palette, desired, transparent, bitmap);
-
-    /* WIC palette type enumeration matches these gdiplus enums */
-    case PaletteTypeFixedBW:
-    case PaletteTypeFixedHalftone8:
-    case PaletteTypeFixedHalftone27:
-    case PaletteTypeFixedHalftone64:
-    case PaletteTypeFixedHalftone125:
-    case PaletteTypeFixedHalftone216:
-    case PaletteTypeFixedHalftone252:
-    case PaletteTypeFixedHalftone256:
-    {
-        ColorPalette *wic_palette;
-        GpStatus status = Ok;
-
-        wic_palette = get_palette(NULL, type);
-        if (!wic_palette) return OutOfMemory;
-
-        if (palette->Count >= wic_palette->Count)
-        {
-            palette->Flags = wic_palette->Flags;
-            palette->Count = wic_palette->Count;
-            memcpy(palette->Entries, wic_palette->Entries, wic_palette->Count * sizeof(wic_palette->Entries[0]));
-        }
-        else
-            status = GenericError;
-
-        heap_free(wic_palette);
-
-        return status;
-    }
-
-    default:
-        FIXME("unknown palette type %d\n", type);
-        break;
-    }
-
-    return InvalidParameter;
-}