2007-07-25 02:19:02 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 Google (Evan Stade)
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2007-07-25 02:19:21 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2009-02-02 17:15:53 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
|
2007-07-25 02:19:02 +02:00
|
|
|
#include "windef.h"
|
2007-07-25 02:19:21 +02:00
|
|
|
#include "winbase.h"
|
2007-08-01 04:15:48 +02:00
|
|
|
#include "winuser.h"
|
2007-07-25 02:19:02 +02:00
|
|
|
#include "wingdi.h"
|
2007-08-01 04:14:57 +02:00
|
|
|
|
|
|
|
#define COBJMACROS
|
2007-07-25 02:19:21 +02:00
|
|
|
#include "objbase.h"
|
2007-08-01 04:15:48 +02:00
|
|
|
#include "olectl.h"
|
2007-08-01 04:15:52 +02:00
|
|
|
#include "ole2.h"
|
2007-07-25 02:19:21 +02:00
|
|
|
|
2008-11-24 10:23:16 +01:00
|
|
|
#include "initguid.h"
|
2009-08-31 23:56:47 +02:00
|
|
|
#include "wincodec.h"
|
2007-07-25 02:19:02 +02:00
|
|
|
#include "gdiplus.h"
|
|
|
|
#include "gdiplus_private.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
|
|
|
|
|
2007-08-04 02:30:30 +02:00
|
|
|
#define PIXELFORMATBPP(x) ((x) ? ((x) >> 8) & 255 : 24)
|
|
|
|
|
2007-08-01 04:16:20 +02:00
|
|
|
static INT ipicture_pixel_height(IPicture *pic)
|
|
|
|
{
|
|
|
|
HDC hdcref;
|
|
|
|
OLE_YSIZE_HIMETRIC y;
|
|
|
|
|
|
|
|
IPicture_get_Height(pic, &y);
|
|
|
|
|
|
|
|
hdcref = GetDC(0);
|
|
|
|
|
2008-03-06 09:28:04 +01:00
|
|
|
y = MulDiv(y, GetDeviceCaps(hdcref, LOGPIXELSY), INCH_HIMETRIC);
|
2007-08-01 04:16:20 +02:00
|
|
|
ReleaseDC(0, hdcref);
|
|
|
|
|
|
|
|
return y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INT ipicture_pixel_width(IPicture *pic)
|
|
|
|
{
|
|
|
|
HDC hdcref;
|
|
|
|
OLE_XSIZE_HIMETRIC x;
|
|
|
|
|
|
|
|
IPicture_get_Width(pic, &x);
|
|
|
|
|
|
|
|
hdcref = GetDC(0);
|
|
|
|
|
2008-03-06 09:28:04 +01:00
|
|
|
x = MulDiv(x, GetDeviceCaps(hdcref, LOGPIXELSX), INCH_HIMETRIC);
|
2007-08-01 04:16:20 +02:00
|
|
|
|
|
|
|
ReleaseDC(0, hdcref);
|
|
|
|
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2009-06-05 06:36:22 +02:00
|
|
|
GpStatus WINGDIPAPI GdipBitmapApplyEffect(GpBitmap* bitmap, CGpEffect* effect,
|
|
|
|
RECT* roi, BOOL useAuxData, VOID** auxData, INT* auxDataSize)
|
|
|
|
{
|
|
|
|
FIXME("(%p %p %p %d %p %p): stub\n", bitmap, effect, roi, useAuxData, auxData, auxDataSize);
|
|
|
|
/*
|
|
|
|
* Note: According to Jose Roca's GDI+ docs, this function is not
|
|
|
|
* implemented in Windows's GDI+.
|
|
|
|
*/
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2009-06-05 06:36:33 +02:00
|
|
|
GpStatus WINGDIPAPI GdipBitmapCreateApplyEffect(GpBitmap** inputBitmaps,
|
|
|
|
INT numInputs, CGpEffect* effect, RECT* roi, RECT* outputRect,
|
|
|
|
GpBitmap** outputBitmap, BOOL useAuxData, VOID** auxData, INT* auxDataSize)
|
|
|
|
{
|
|
|
|
FIXME("(%p %d %p %p %p %p %d %p %p): stub\n", inputBitmaps, numInputs, effect, roi, outputRect, outputBitmap, useAuxData, auxData, auxDataSize);
|
|
|
|
/*
|
|
|
|
* Note: According to Jose Roca's GDI+ docs, this function is not
|
|
|
|
* implemented in Windows's GDI+.
|
|
|
|
*/
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2010-01-31 02:01:52 +01:00
|
|
|
static inline void getpixel_1bppIndexed(BYTE *index, const BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
*index = (row[x/8]>>(7-x%8)) & 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void getpixel_4bppIndexed(BYTE *index, const BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
if (x & 1)
|
|
|
|
*index = row[x/2]&0xf;
|
|
|
|
else
|
|
|
|
*index = row[x/2]>>4;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void getpixel_8bppIndexed(BYTE *index, const BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
*index = row[x];
|
|
|
|
}
|
|
|
|
|
2009-09-23 17:41:13 +02:00
|
|
|
static inline void getpixel_16bppGrayScale(BYTE *r, BYTE *g, BYTE *b, BYTE *a,
|
|
|
|
const BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
*r = *g = *b = row[x*2+1];
|
|
|
|
*a = 255;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void getpixel_16bppRGB555(BYTE *r, BYTE *g, BYTE *b, BYTE *a,
|
|
|
|
const BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
WORD pixel = *((WORD*)(row)+x);
|
|
|
|
*r = (pixel>>7&0xf8)|(pixel>>12&0x7);
|
|
|
|
*g = (pixel>>2&0xf8)|(pixel>>6&0x7);
|
|
|
|
*b = (pixel<<3&0xf8)|(pixel>>2&0x7);
|
|
|
|
*a = 255;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void getpixel_16bppRGB565(BYTE *r, BYTE *g, BYTE *b, BYTE *a,
|
|
|
|
const BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
WORD pixel = *((WORD*)(row)+x);
|
|
|
|
*r = (pixel>>8&0xf8)|(pixel>>13&0x7);
|
|
|
|
*g = (pixel>>3&0xfc)|(pixel>>9&0x3);
|
|
|
|
*b = (pixel<<3&0xf8)|(pixel>>2&0x7);
|
|
|
|
*a = 255;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void getpixel_16bppARGB1555(BYTE *r, BYTE *g, BYTE *b, BYTE *a,
|
|
|
|
const BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
WORD pixel = *((WORD*)(row)+x);
|
|
|
|
*r = (pixel>>7&0xf8)|(pixel>>12&0x7);
|
|
|
|
*g = (pixel>>2&0xf8)|(pixel>>6&0x7);
|
|
|
|
*b = (pixel<<3&0xf8)|(pixel>>2&0x7);
|
|
|
|
if ((pixel&0x8000) == 0x8000)
|
|
|
|
*a = 255;
|
|
|
|
else
|
|
|
|
*a = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void getpixel_24bppRGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a,
|
|
|
|
const BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
*r = row[x*3+2];
|
|
|
|
*g = row[x*3+1];
|
|
|
|
*b = row[x*3];
|
|
|
|
*a = 255;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void getpixel_32bppRGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a,
|
|
|
|
const BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
*r = row[x*4+2];
|
|
|
|
*g = row[x*4+1];
|
|
|
|
*b = row[x*4];
|
|
|
|
*a = 255;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void getpixel_32bppARGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a,
|
|
|
|
const BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
*r = row[x*4+2];
|
|
|
|
*g = row[x*4+1];
|
|
|
|
*b = row[x*4];
|
|
|
|
*a = row[x*4+3];
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void getpixel_32bppPARGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a,
|
|
|
|
const BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
*a = row[x*4+3];
|
|
|
|
if (*a == 0)
|
|
|
|
*r = *g = *b = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*r = row[x*4+2] * 255 / *a;
|
|
|
|
*g = row[x*4+1] * 255 / *a;
|
|
|
|
*b = row[x*4] * 255 / *a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void getpixel_48bppRGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a,
|
|
|
|
const BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
*r = row[x*6+5];
|
|
|
|
*g = row[x*6+3];
|
|
|
|
*b = row[x*6+1];
|
|
|
|
*a = 255;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void getpixel_64bppARGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a,
|
|
|
|
const BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
*r = row[x*8+5];
|
|
|
|
*g = row[x*8+3];
|
|
|
|
*b = row[x*8+1];
|
|
|
|
*a = row[x*8+7];
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void getpixel_64bppPARGB(BYTE *r, BYTE *g, BYTE *b, BYTE *a,
|
|
|
|
const BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
*a = row[x*8+7];
|
|
|
|
if (*a == 0)
|
|
|
|
*r = *g = *b = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*r = row[x*8+5] * 255 / *a;
|
|
|
|
*g = row[x*8+3] * 255 / *a;
|
|
|
|
*b = row[x*8+1] * 255 / *a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-01 04:16:13 +02:00
|
|
|
GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap* bitmap, INT x, INT y,
|
|
|
|
ARGB *color)
|
|
|
|
{
|
2009-09-23 17:41:13 +02:00
|
|
|
BYTE r, g, b, a;
|
2010-01-31 02:01:52 +01:00
|
|
|
BYTE index;
|
2009-09-23 17:41:13 +02:00
|
|
|
BYTE *row;
|
2007-08-01 04:16:13 +02:00
|
|
|
TRACE("%p %d %d %p\n", bitmap, x, y, color);
|
|
|
|
|
2009-09-23 17:41:13 +02:00
|
|
|
if(!bitmap || !color ||
|
|
|
|
x < 0 || y < 0 || x >= bitmap->width || y >= bitmap->height)
|
2007-08-01 04:16:13 +02:00
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-09-23 17:41:13 +02:00
|
|
|
row = bitmap->bits+bitmap->stride*y;
|
2007-08-01 04:16:13 +02:00
|
|
|
|
2009-09-23 17:41:13 +02:00
|
|
|
switch (bitmap->format)
|
|
|
|
{
|
2010-01-31 02:01:52 +01:00
|
|
|
case PixelFormat1bppIndexed:
|
|
|
|
getpixel_1bppIndexed(&index,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat4bppIndexed:
|
|
|
|
getpixel_4bppIndexed(&index,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat8bppIndexed:
|
|
|
|
getpixel_8bppIndexed(&index,row,x);
|
|
|
|
break;
|
2009-09-23 17:41:13 +02:00
|
|
|
case PixelFormat16bppGrayScale:
|
|
|
|
getpixel_16bppGrayScale(&r,&g,&b,&a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat16bppRGB555:
|
|
|
|
getpixel_16bppRGB555(&r,&g,&b,&a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat16bppRGB565:
|
|
|
|
getpixel_16bppRGB565(&r,&g,&b,&a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat16bppARGB1555:
|
|
|
|
getpixel_16bppARGB1555(&r,&g,&b,&a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat24bppRGB:
|
|
|
|
getpixel_24bppRGB(&r,&g,&b,&a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat32bppRGB:
|
|
|
|
getpixel_32bppRGB(&r,&g,&b,&a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat32bppARGB:
|
|
|
|
getpixel_32bppARGB(&r,&g,&b,&a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat32bppPARGB:
|
|
|
|
getpixel_32bppPARGB(&r,&g,&b,&a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat48bppRGB:
|
|
|
|
getpixel_48bppRGB(&r,&g,&b,&a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat64bppARGB:
|
|
|
|
getpixel_64bppARGB(&r,&g,&b,&a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat64bppPARGB:
|
|
|
|
getpixel_64bppPARGB(&r,&g,&b,&a,row,x);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("not implemented for format 0x%x\n", bitmap->format);
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
2007-08-01 04:16:13 +02:00
|
|
|
|
2010-01-31 02:01:52 +01:00
|
|
|
if (bitmap->format & PixelFormatIndexed)
|
|
|
|
*color = bitmap->image.palette_entries[index];
|
|
|
|
else
|
|
|
|
*color = a<<24|r<<16|g<<8|b;
|
2009-09-23 17:41:13 +02:00
|
|
|
|
|
|
|
return Ok;
|
2007-08-01 04:16:13 +02:00
|
|
|
}
|
|
|
|
|
2009-09-23 18:22:39 +02:00
|
|
|
static inline void setpixel_16bppGrayScale(BYTE r, BYTE g, BYTE b, BYTE a,
|
|
|
|
BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
*((WORD*)(row)+x) = (r+g+b)*85;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void setpixel_16bppRGB555(BYTE r, BYTE g, BYTE b, BYTE a,
|
|
|
|
BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
*((WORD*)(row)+x) = (r<<7&0x7c00)|
|
|
|
|
(g<<2&0x03e0)|
|
|
|
|
(b>>3&0x001f);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void setpixel_16bppRGB565(BYTE r, BYTE g, BYTE b, BYTE a,
|
|
|
|
BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
*((WORD*)(row)+x) = (r<<8&0xf800)|
|
|
|
|
(g<<3&0x07e0)|
|
|
|
|
(b>>3&0x001f);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void setpixel_16bppARGB1555(BYTE r, BYTE g, BYTE b, BYTE a,
|
|
|
|
BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
*((WORD*)(row)+x) = (a<<8&0x8000)|
|
|
|
|
(r<<7&0x7c00)|
|
|
|
|
(g<<2&0x03e0)|
|
|
|
|
(b>>3&0x001f);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void setpixel_24bppRGB(BYTE r, BYTE g, BYTE b, BYTE a,
|
|
|
|
BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
row[x*3+2] = r;
|
|
|
|
row[x*3+1] = g;
|
|
|
|
row[x*3] = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void setpixel_32bppRGB(BYTE r, BYTE g, BYTE b, BYTE a,
|
|
|
|
BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
*((DWORD*)(row)+x) = (r<<16)|(g<<8)|b;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void setpixel_32bppARGB(BYTE r, BYTE g, BYTE b, BYTE a,
|
|
|
|
BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
*((DWORD*)(row)+x) = (a<<24)|(r<<16)|(g<<8)|b;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void setpixel_32bppPARGB(BYTE r, BYTE g, BYTE b, BYTE a,
|
|
|
|
BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
r = r * a / 255;
|
|
|
|
g = g * a / 255;
|
|
|
|
b = b * a / 255;
|
|
|
|
*((DWORD*)(row)+x) = (a<<24)|(r<<16)|(g<<8)|b;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void setpixel_48bppRGB(BYTE r, BYTE g, BYTE b, BYTE a,
|
|
|
|
BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
row[x*6+5] = row[x*6+4] = r;
|
|
|
|
row[x*6+3] = row[x*6+2] = g;
|
|
|
|
row[x*6+1] = row[x*6] = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void setpixel_64bppARGB(BYTE r, BYTE g, BYTE b, BYTE a,
|
|
|
|
BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
UINT64 a64=a, r64=r, g64=g, b64=b;
|
|
|
|
*((UINT64*)(row)+x) = (a64<<56)|(a64<<48)|(r64<<40)|(r64<<32)|(g64<<24)|(g64<<16)|(b64<<8)|b64;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void setpixel_64bppPARGB(BYTE r, BYTE g, BYTE b, BYTE a,
|
|
|
|
BYTE *row, UINT x)
|
|
|
|
{
|
|
|
|
UINT64 a64, r64, g64, b64;
|
|
|
|
a64 = a * 257;
|
|
|
|
r64 = r * a / 255;
|
|
|
|
g64 = g * a / 255;
|
|
|
|
b64 = b * a / 255;
|
|
|
|
*((UINT64*)(row)+x) = (a64<<48)|(r64<<32)|(g64<<16)|b64;
|
|
|
|
}
|
|
|
|
|
2009-04-27 23:20:27 +02:00
|
|
|
GpStatus WINGDIPAPI GdipBitmapSetPixel(GpBitmap* bitmap, INT x, INT y,
|
|
|
|
ARGB color)
|
|
|
|
{
|
2009-09-23 18:22:39 +02:00
|
|
|
BYTE a, r, g, b;
|
|
|
|
BYTE *row;
|
2009-04-27 23:20:27 +02:00
|
|
|
TRACE("bitmap:%p, x:%d, y:%d, color:%08x\n", bitmap, x, y, color);
|
|
|
|
|
2009-09-23 18:22:39 +02:00
|
|
|
if(!bitmap || x < 0 || y < 0 || x >= bitmap->width || y >= bitmap->height)
|
2009-04-27 23:20:27 +02:00
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-09-23 18:22:39 +02:00
|
|
|
a = color>>24;
|
|
|
|
r = color>>16;
|
|
|
|
g = color>>8;
|
|
|
|
b = color;
|
2009-04-27 23:20:27 +02:00
|
|
|
|
2009-09-23 18:22:39 +02:00
|
|
|
row = bitmap->bits + bitmap->stride * y;
|
|
|
|
|
|
|
|
switch (bitmap->format)
|
|
|
|
{
|
|
|
|
case PixelFormat16bppGrayScale:
|
|
|
|
setpixel_16bppGrayScale(r,g,b,a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat16bppRGB555:
|
|
|
|
setpixel_16bppRGB555(r,g,b,a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat16bppRGB565:
|
|
|
|
setpixel_16bppRGB565(r,g,b,a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat16bppARGB1555:
|
|
|
|
setpixel_16bppARGB1555(r,g,b,a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat24bppRGB:
|
|
|
|
setpixel_24bppRGB(r,g,b,a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat32bppRGB:
|
|
|
|
setpixel_32bppRGB(r,g,b,a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat32bppARGB:
|
|
|
|
setpixel_32bppARGB(r,g,b,a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat32bppPARGB:
|
|
|
|
setpixel_32bppPARGB(r,g,b,a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat48bppRGB:
|
|
|
|
setpixel_48bppRGB(r,g,b,a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat64bppARGB:
|
|
|
|
setpixel_64bppARGB(r,g,b,a,row,x);
|
|
|
|
break;
|
|
|
|
case PixelFormat64bppPARGB:
|
|
|
|
setpixel_64bppPARGB(r,g,b,a,row,x);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("not implemented for format 0x%x\n", bitmap->format);
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Ok;
|
2009-04-27 23:20:27 +02:00
|
|
|
}
|
|
|
|
|
2010-02-05 02:05:54 +01:00
|
|
|
GpStatus convert_pixels(UINT width, UINT height,
|
|
|
|
INT dst_stride, BYTE *dst_bits, PixelFormat dst_format,
|
|
|
|
INT src_stride, const BYTE *src_bits, PixelFormat src_format, ARGB *src_palette)
|
|
|
|
{
|
|
|
|
UINT x, y;
|
|
|
|
|
|
|
|
if (src_format == dst_format ||
|
|
|
|
(dst_format == PixelFormat32bppRGB && PIXELFORMATBPP(src_format) == 32))
|
|
|
|
{
|
|
|
|
UINT widthbytes = PIXELFORMATBPP(src_format) * width / 8;
|
|
|
|
for (y=0; y<height; y++)
|
|
|
|
memcpy(dst_bits+dst_stride*y, src_bits+src_stride*y, widthbytes);
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define convert_indexed_to_rgb(getpixel_function, setpixel_function) do { \
|
|
|
|
for (x=0; x<width; x++) \
|
|
|
|
for (y=0; y<height; y++) { \
|
|
|
|
BYTE index; \
|
|
|
|
BYTE *color; \
|
|
|
|
getpixel_function(&index, src_bits+src_stride*y, x); \
|
|
|
|
color = (BYTE*)(&src_palette[index]); \
|
|
|
|
setpixel_function(color[2], color[1], color[0], color[3], dst_bits+dst_stride*y, x); \
|
|
|
|
} \
|
|
|
|
return Ok; \
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
#define convert_rgb_to_rgb(getpixel_function, setpixel_function) do { \
|
|
|
|
for (x=0; x<width; x++) \
|
|
|
|
for (y=0; y<height; y++) { \
|
|
|
|
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);
|
|
|
|
|
|
|
|
switch (src_format)
|
|
|
|
{
|
|
|
|
case PixelFormat1bppIndexed:
|
|
|
|
switch (dst_format)
|
|
|
|
{
|
|
|
|
case PixelFormat16bppGrayScale:
|
|
|
|
convert_indexed_to_rgb(getpixel_1bppIndexed, setpixel_16bppGrayScale);
|
|
|
|
case PixelFormat16bppRGB555:
|
|
|
|
convert_indexed_to_rgb(getpixel_1bppIndexed, setpixel_16bppRGB555);
|
|
|
|
case PixelFormat16bppRGB565:
|
|
|
|
convert_indexed_to_rgb(getpixel_1bppIndexed, setpixel_16bppRGB565);
|
|
|
|
case PixelFormat16bppARGB1555:
|
|
|
|
convert_indexed_to_rgb(getpixel_1bppIndexed, setpixel_16bppARGB1555);
|
|
|
|
case PixelFormat24bppRGB:
|
|
|
|
convert_indexed_to_rgb(getpixel_1bppIndexed, setpixel_24bppRGB);
|
|
|
|
case PixelFormat32bppRGB:
|
|
|
|
convert_indexed_to_rgb(getpixel_1bppIndexed, setpixel_32bppRGB);
|
|
|
|
case PixelFormat32bppARGB:
|
|
|
|
convert_indexed_to_rgb(getpixel_1bppIndexed, setpixel_32bppARGB);
|
|
|
|
case PixelFormat32bppPARGB:
|
|
|
|
convert_indexed_to_rgb(getpixel_1bppIndexed, setpixel_32bppPARGB);
|
|
|
|
case PixelFormat48bppRGB:
|
|
|
|
convert_indexed_to_rgb(getpixel_1bppIndexed, setpixel_48bppRGB);
|
|
|
|
case PixelFormat64bppARGB:
|
|
|
|
convert_indexed_to_rgb(getpixel_1bppIndexed, setpixel_64bppARGB);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PixelFormat4bppIndexed:
|
|
|
|
switch (dst_format)
|
|
|
|
{
|
|
|
|
case PixelFormat16bppGrayScale:
|
|
|
|
convert_indexed_to_rgb(getpixel_4bppIndexed, setpixel_16bppGrayScale);
|
|
|
|
case PixelFormat16bppRGB555:
|
|
|
|
convert_indexed_to_rgb(getpixel_4bppIndexed, setpixel_16bppRGB555);
|
|
|
|
case PixelFormat16bppRGB565:
|
|
|
|
convert_indexed_to_rgb(getpixel_4bppIndexed, setpixel_16bppRGB565);
|
|
|
|
case PixelFormat16bppARGB1555:
|
|
|
|
convert_indexed_to_rgb(getpixel_4bppIndexed, setpixel_16bppARGB1555);
|
|
|
|
case PixelFormat24bppRGB:
|
|
|
|
convert_indexed_to_rgb(getpixel_4bppIndexed, setpixel_24bppRGB);
|
|
|
|
case PixelFormat32bppRGB:
|
|
|
|
convert_indexed_to_rgb(getpixel_4bppIndexed, setpixel_32bppRGB);
|
|
|
|
case PixelFormat32bppARGB:
|
|
|
|
convert_indexed_to_rgb(getpixel_4bppIndexed, setpixel_32bppARGB);
|
|
|
|
case PixelFormat32bppPARGB:
|
|
|
|
convert_indexed_to_rgb(getpixel_4bppIndexed, setpixel_32bppPARGB);
|
|
|
|
case PixelFormat48bppRGB:
|
|
|
|
convert_indexed_to_rgb(getpixel_4bppIndexed, setpixel_48bppRGB);
|
|
|
|
case PixelFormat64bppARGB:
|
|
|
|
convert_indexed_to_rgb(getpixel_4bppIndexed, setpixel_64bppARGB);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PixelFormat8bppIndexed:
|
|
|
|
switch (dst_format)
|
|
|
|
{
|
|
|
|
case PixelFormat16bppGrayScale:
|
|
|
|
convert_indexed_to_rgb(getpixel_8bppIndexed, setpixel_16bppGrayScale);
|
|
|
|
case PixelFormat16bppRGB555:
|
|
|
|
convert_indexed_to_rgb(getpixel_8bppIndexed, setpixel_16bppRGB555);
|
|
|
|
case PixelFormat16bppRGB565:
|
|
|
|
convert_indexed_to_rgb(getpixel_8bppIndexed, setpixel_16bppRGB565);
|
|
|
|
case PixelFormat16bppARGB1555:
|
|
|
|
convert_indexed_to_rgb(getpixel_8bppIndexed, setpixel_16bppARGB1555);
|
|
|
|
case PixelFormat24bppRGB:
|
|
|
|
convert_indexed_to_rgb(getpixel_8bppIndexed, setpixel_24bppRGB);
|
|
|
|
case PixelFormat32bppRGB:
|
|
|
|
convert_indexed_to_rgb(getpixel_8bppIndexed, setpixel_32bppRGB);
|
|
|
|
case PixelFormat32bppARGB:
|
|
|
|
convert_indexed_to_rgb(getpixel_8bppIndexed, setpixel_32bppARGB);
|
|
|
|
case PixelFormat32bppPARGB:
|
|
|
|
convert_indexed_to_rgb(getpixel_8bppIndexed, setpixel_32bppPARGB);
|
|
|
|
case PixelFormat48bppRGB:
|
|
|
|
convert_indexed_to_rgb(getpixel_8bppIndexed, setpixel_48bppRGB);
|
|
|
|
case PixelFormat64bppARGB:
|
|
|
|
convert_indexed_to_rgb(getpixel_8bppIndexed, setpixel_64bppARGB);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PixelFormat16bppGrayScale:
|
|
|
|
switch (dst_format)
|
|
|
|
{
|
|
|
|
case PixelFormat16bppRGB555:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppGrayScale, setpixel_16bppRGB555);
|
|
|
|
case PixelFormat16bppRGB565:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppGrayScale, setpixel_16bppRGB565);
|
|
|
|
case PixelFormat16bppARGB1555:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppGrayScale, setpixel_16bppARGB1555);
|
|
|
|
case PixelFormat24bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppGrayScale, setpixel_24bppRGB);
|
|
|
|
case PixelFormat32bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppGrayScale, setpixel_32bppRGB);
|
|
|
|
case PixelFormat32bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppGrayScale, setpixel_32bppARGB);
|
|
|
|
case PixelFormat32bppPARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppGrayScale, setpixel_32bppPARGB);
|
|
|
|
case PixelFormat48bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppGrayScale, setpixel_48bppRGB);
|
|
|
|
case PixelFormat64bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppGrayScale, setpixel_64bppARGB);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PixelFormat16bppRGB555:
|
|
|
|
switch (dst_format)
|
|
|
|
{
|
|
|
|
case PixelFormat16bppGrayScale:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppRGB555, setpixel_16bppGrayScale);
|
|
|
|
case PixelFormat16bppRGB565:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppRGB555, setpixel_16bppRGB565);
|
|
|
|
case PixelFormat16bppARGB1555:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppRGB555, setpixel_16bppARGB1555);
|
|
|
|
case PixelFormat24bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppRGB555, setpixel_24bppRGB);
|
|
|
|
case PixelFormat32bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppRGB555, setpixel_32bppRGB);
|
|
|
|
case PixelFormat32bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppRGB555, setpixel_32bppARGB);
|
|
|
|
case PixelFormat32bppPARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppRGB555, setpixel_32bppPARGB);
|
|
|
|
case PixelFormat48bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppRGB555, setpixel_48bppRGB);
|
|
|
|
case PixelFormat64bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppRGB555, setpixel_64bppARGB);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PixelFormat16bppRGB565:
|
|
|
|
switch (dst_format)
|
|
|
|
{
|
|
|
|
case PixelFormat16bppGrayScale:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppRGB565, setpixel_16bppGrayScale);
|
|
|
|
case PixelFormat16bppRGB555:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppRGB565, setpixel_16bppRGB555);
|
|
|
|
case PixelFormat16bppARGB1555:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppRGB565, setpixel_16bppARGB1555);
|
|
|
|
case PixelFormat24bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppRGB565, setpixel_24bppRGB);
|
|
|
|
case PixelFormat32bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppRGB565, setpixel_32bppRGB);
|
|
|
|
case PixelFormat32bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppRGB565, setpixel_32bppARGB);
|
|
|
|
case PixelFormat32bppPARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppRGB565, setpixel_32bppPARGB);
|
|
|
|
case PixelFormat48bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppRGB565, setpixel_48bppRGB);
|
|
|
|
case PixelFormat64bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppRGB565, setpixel_64bppARGB);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PixelFormat16bppARGB1555:
|
|
|
|
switch (dst_format)
|
|
|
|
{
|
|
|
|
case PixelFormat16bppGrayScale:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppARGB1555, setpixel_16bppGrayScale);
|
|
|
|
case PixelFormat16bppRGB555:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppARGB1555, setpixel_16bppRGB555);
|
|
|
|
case PixelFormat16bppRGB565:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppARGB1555, setpixel_16bppRGB565);
|
|
|
|
case PixelFormat24bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppARGB1555, setpixel_24bppRGB);
|
|
|
|
case PixelFormat32bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppARGB1555, setpixel_32bppRGB);
|
|
|
|
case PixelFormat32bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppARGB1555, setpixel_32bppARGB);
|
|
|
|
case PixelFormat32bppPARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppARGB1555, setpixel_32bppPARGB);
|
|
|
|
case PixelFormat48bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppARGB1555, setpixel_48bppRGB);
|
|
|
|
case PixelFormat64bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_16bppARGB1555, setpixel_64bppARGB);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PixelFormat24bppRGB:
|
|
|
|
switch (dst_format)
|
|
|
|
{
|
|
|
|
case PixelFormat16bppGrayScale:
|
|
|
|
convert_rgb_to_rgb(getpixel_24bppRGB, setpixel_16bppGrayScale);
|
|
|
|
case PixelFormat16bppRGB555:
|
|
|
|
convert_rgb_to_rgb(getpixel_24bppRGB, setpixel_16bppRGB555);
|
|
|
|
case PixelFormat16bppRGB565:
|
|
|
|
convert_rgb_to_rgb(getpixel_24bppRGB, setpixel_16bppRGB565);
|
|
|
|
case PixelFormat16bppARGB1555:
|
|
|
|
convert_rgb_to_rgb(getpixel_24bppRGB, setpixel_16bppARGB1555);
|
|
|
|
case PixelFormat32bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_24bppRGB, setpixel_32bppRGB);
|
|
|
|
case PixelFormat32bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_24bppRGB, setpixel_32bppARGB);
|
|
|
|
case PixelFormat32bppPARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_24bppRGB, setpixel_32bppPARGB);
|
|
|
|
case PixelFormat48bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_24bppRGB, setpixel_48bppRGB);
|
|
|
|
case PixelFormat64bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_24bppRGB, setpixel_64bppARGB);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PixelFormat32bppRGB:
|
|
|
|
switch (dst_format)
|
|
|
|
{
|
|
|
|
case PixelFormat16bppGrayScale:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppRGB, setpixel_16bppGrayScale);
|
|
|
|
case PixelFormat16bppRGB555:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppRGB, setpixel_16bppRGB555);
|
|
|
|
case PixelFormat16bppRGB565:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppRGB, setpixel_16bppRGB565);
|
|
|
|
case PixelFormat16bppARGB1555:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppRGB, setpixel_16bppARGB1555);
|
|
|
|
case PixelFormat24bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppRGB, setpixel_24bppRGB);
|
|
|
|
case PixelFormat32bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppRGB, setpixel_32bppARGB);
|
|
|
|
case PixelFormat32bppPARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppRGB, setpixel_32bppPARGB);
|
|
|
|
case PixelFormat48bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppRGB, setpixel_48bppRGB);
|
|
|
|
case PixelFormat64bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppRGB, setpixel_64bppARGB);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PixelFormat32bppARGB:
|
|
|
|
switch (dst_format)
|
|
|
|
{
|
|
|
|
case PixelFormat16bppGrayScale:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppARGB, setpixel_16bppGrayScale);
|
|
|
|
case PixelFormat16bppRGB555:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppARGB, setpixel_16bppRGB555);
|
|
|
|
case PixelFormat16bppRGB565:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppARGB, setpixel_16bppRGB565);
|
|
|
|
case PixelFormat16bppARGB1555:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppARGB, setpixel_16bppARGB1555);
|
|
|
|
case PixelFormat24bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppARGB, setpixel_24bppRGB);
|
|
|
|
case PixelFormat32bppPARGB:
|
|
|
|
convert_32bppARGB_to_32bppPARGB(width, height, dst_bits, dst_stride, src_bits, src_stride);
|
|
|
|
return Ok;
|
|
|
|
case PixelFormat48bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppARGB, setpixel_48bppRGB);
|
|
|
|
case PixelFormat64bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppARGB, setpixel_64bppARGB);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PixelFormat32bppPARGB:
|
|
|
|
switch (dst_format)
|
|
|
|
{
|
|
|
|
case PixelFormat16bppGrayScale:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppPARGB, setpixel_16bppGrayScale);
|
|
|
|
case PixelFormat16bppRGB555:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppPARGB, setpixel_16bppRGB555);
|
|
|
|
case PixelFormat16bppRGB565:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppPARGB, setpixel_16bppRGB565);
|
|
|
|
case PixelFormat16bppARGB1555:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppPARGB, setpixel_16bppARGB1555);
|
|
|
|
case PixelFormat24bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppPARGB, setpixel_24bppRGB);
|
|
|
|
case PixelFormat32bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppPARGB, setpixel_32bppRGB);
|
|
|
|
case PixelFormat32bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppPARGB, setpixel_32bppARGB);
|
|
|
|
case PixelFormat48bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppPARGB, setpixel_48bppRGB);
|
|
|
|
case PixelFormat64bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_32bppPARGB, setpixel_64bppARGB);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PixelFormat48bppRGB:
|
|
|
|
switch (dst_format)
|
|
|
|
{
|
|
|
|
case PixelFormat16bppGrayScale:
|
|
|
|
convert_rgb_to_rgb(getpixel_48bppRGB, setpixel_16bppGrayScale);
|
|
|
|
case PixelFormat16bppRGB555:
|
|
|
|
convert_rgb_to_rgb(getpixel_48bppRGB, setpixel_16bppRGB555);
|
|
|
|
case PixelFormat16bppRGB565:
|
|
|
|
convert_rgb_to_rgb(getpixel_48bppRGB, setpixel_16bppRGB565);
|
|
|
|
case PixelFormat16bppARGB1555:
|
|
|
|
convert_rgb_to_rgb(getpixel_48bppRGB, setpixel_16bppARGB1555);
|
|
|
|
case PixelFormat24bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_48bppRGB, setpixel_24bppRGB);
|
|
|
|
case PixelFormat32bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_48bppRGB, setpixel_32bppRGB);
|
|
|
|
case PixelFormat32bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_48bppRGB, setpixel_32bppARGB);
|
|
|
|
case PixelFormat32bppPARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_48bppRGB, setpixel_32bppPARGB);
|
|
|
|
case PixelFormat64bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_48bppRGB, setpixel_64bppARGB);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PixelFormat64bppARGB:
|
|
|
|
switch (dst_format)
|
|
|
|
{
|
|
|
|
case PixelFormat16bppGrayScale:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppARGB, setpixel_16bppGrayScale);
|
|
|
|
case PixelFormat16bppRGB555:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppARGB, setpixel_16bppRGB555);
|
|
|
|
case PixelFormat16bppRGB565:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppARGB, setpixel_16bppRGB565);
|
|
|
|
case PixelFormat16bppARGB1555:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppARGB, setpixel_16bppARGB1555);
|
|
|
|
case PixelFormat24bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppARGB, setpixel_24bppRGB);
|
|
|
|
case PixelFormat32bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppARGB, setpixel_32bppRGB);
|
|
|
|
case PixelFormat32bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppARGB, setpixel_32bppARGB);
|
|
|
|
case PixelFormat32bppPARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppARGB, setpixel_32bppPARGB);
|
|
|
|
case PixelFormat48bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppARGB, setpixel_48bppRGB);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PixelFormat64bppPARGB:
|
|
|
|
switch (dst_format)
|
|
|
|
{
|
|
|
|
case PixelFormat16bppGrayScale:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppPARGB, setpixel_16bppGrayScale);
|
|
|
|
case PixelFormat16bppRGB555:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppPARGB, setpixel_16bppRGB555);
|
|
|
|
case PixelFormat16bppRGB565:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppPARGB, setpixel_16bppRGB565);
|
|
|
|
case PixelFormat16bppARGB1555:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppPARGB, setpixel_16bppARGB1555);
|
|
|
|
case PixelFormat24bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppPARGB, setpixel_24bppRGB);
|
|
|
|
case PixelFormat32bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppPARGB, setpixel_32bppRGB);
|
|
|
|
case PixelFormat32bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppPARGB, setpixel_32bppARGB);
|
|
|
|
case PixelFormat32bppPARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppPARGB, setpixel_32bppPARGB);
|
|
|
|
case PixelFormat48bppRGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppPARGB, setpixel_48bppRGB);
|
|
|
|
case PixelFormat64bppARGB:
|
|
|
|
convert_rgb_to_rgb(getpixel_64bppPARGB, setpixel_64bppARGB);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef convert_indexed_to_rgb
|
|
|
|
#undef convert_rgb_to_rgb
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2007-08-08 03:41:55 +02:00
|
|
|
/* This function returns a pointer to an array of pixels that represents the
|
|
|
|
* bitmap. The *entire* bitmap is locked according to the lock mode specified by
|
|
|
|
* flags. It is correct behavior that a user who calls this function with write
|
|
|
|
* privileges can write to the whole bitmap (not just the area in rect).
|
|
|
|
*
|
|
|
|
* FIXME: only used portion of format is bits per pixel. */
|
|
|
|
GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
|
|
|
|
UINT flags, PixelFormat format, BitmapData* lockeddata)
|
|
|
|
{
|
|
|
|
INT stride, bitspp = PIXELFORMATBPP(format);
|
|
|
|
BYTE *buff = NULL;
|
|
|
|
UINT abs_height;
|
2008-05-21 17:47:50 +02:00
|
|
|
GpRect act_rect; /* actual rect to be used */
|
2010-02-05 02:05:54 +01:00
|
|
|
GpStatus stat;
|
2007-08-08 03:41:55 +02:00
|
|
|
|
2009-12-18 23:22:25 +01:00
|
|
|
TRACE("%p %p %d 0x%x %p\n", bitmap, rect, flags, format, lockeddata);
|
2007-08-08 03:41:55 +02:00
|
|
|
|
2008-05-21 17:47:50 +02:00
|
|
|
if(!lockeddata || !bitmap)
|
2007-08-08 03:41:55 +02:00
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-05-21 17:47:50 +02:00
|
|
|
if(rect){
|
|
|
|
if(rect->X < 0 || rect->Y < 0 || (rect->X + rect->Width > bitmap->width) ||
|
|
|
|
(rect->Y + rect->Height > bitmap->height) || !flags)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
act_rect = *rect;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
act_rect.X = act_rect.Y = 0;
|
|
|
|
act_rect.Width = bitmap->width;
|
|
|
|
act_rect.Height = bitmap->height;
|
|
|
|
}
|
2007-08-08 03:41:55 +02:00
|
|
|
|
|
|
|
if(flags & ImageLockModeUserInputBuf)
|
2010-02-05 02:05:54 +01:00
|
|
|
{
|
|
|
|
static int fixme=0;
|
|
|
|
if (!fixme++) FIXME("ImageLockModeUserInputBuf not implemented\n");
|
2007-08-08 03:41:55 +02:00
|
|
|
return NotImplemented;
|
2010-02-05 02:05:54 +01:00
|
|
|
}
|
2007-08-08 03:41:55 +02:00
|
|
|
|
2008-03-07 10:19:05 +01:00
|
|
|
if(bitmap->lockmode)
|
2010-02-05 02:05:54 +01:00
|
|
|
{
|
|
|
|
WARN("bitmap is already locked and cannot be locked again\n");
|
2007-08-08 03:41:55 +02:00
|
|
|
return WrongState;
|
2010-02-05 02:05:54 +01:00
|
|
|
}
|
2007-08-08 03:41:55 +02:00
|
|
|
|
2009-08-28 23:53:57 +02:00
|
|
|
if (bitmap->bits && bitmap->format == format)
|
|
|
|
{
|
|
|
|
/* no conversion is necessary; just use the bits directly */
|
|
|
|
lockeddata->Width = act_rect.Width;
|
|
|
|
lockeddata->Height = act_rect.Height;
|
|
|
|
lockeddata->PixelFormat = format;
|
|
|
|
lockeddata->Reserved = flags;
|
|
|
|
lockeddata->Stride = bitmap->stride;
|
|
|
|
lockeddata->Scan0 = bitmap->bits + (bitspp / 8) * act_rect.X +
|
|
|
|
bitmap->stride * act_rect.Y;
|
|
|
|
|
|
|
|
bitmap->lockmode = flags;
|
|
|
|
bitmap->numlocks++;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2010-02-05 02:05:54 +01:00
|
|
|
/* Make sure we can convert to the requested format. */
|
|
|
|
stat = convert_pixels(0, 0, 0, NULL, format, 0, NULL, bitmap->format, NULL);
|
|
|
|
if (stat == NotImplemented)
|
|
|
|
{
|
|
|
|
FIXME("cannot read bitmap from %x to %x\n", bitmap->format, format);
|
|
|
|
return NotImplemented;
|
2007-08-08 03:41:55 +02:00
|
|
|
}
|
|
|
|
|
2010-02-05 02:05:54 +01:00
|
|
|
/* If we're opening for writing, make sure we'll be able to write back in
|
|
|
|
* the original format. */
|
|
|
|
if (flags & ImageLockModeWrite)
|
|
|
|
{
|
|
|
|
stat = convert_pixels(0, 0, 0, NULL, bitmap->format, 0, NULL, format, NULL);
|
|
|
|
if (stat == NotImplemented)
|
|
|
|
{
|
|
|
|
FIXME("cannot write bitmap from %x to %x\n", format, bitmap->format);
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
}
|
2007-08-08 03:41:55 +02:00
|
|
|
|
2010-02-05 02:05:54 +01:00
|
|
|
abs_height = bitmap->height;
|
|
|
|
stride = (bitmap->width * bitspp + 7) / 8;
|
2007-08-08 03:41:55 +02:00
|
|
|
stride = (stride + 3) & ~3;
|
|
|
|
|
|
|
|
buff = GdipAlloc(stride * abs_height);
|
|
|
|
|
2010-02-05 02:05:54 +01:00
|
|
|
if (!buff) return OutOfMemory;
|
2007-08-08 03:41:55 +02:00
|
|
|
|
2010-02-05 02:05:54 +01:00
|
|
|
stat = convert_pixels(bitmap->width, bitmap->height,
|
|
|
|
stride, buff, format,
|
|
|
|
bitmap->stride, bitmap->bits, bitmap->format, bitmap->image.palette_entries);
|
2007-08-08 03:41:55 +02:00
|
|
|
|
2010-02-05 02:05:54 +01:00
|
|
|
if (stat != Ok)
|
|
|
|
{
|
|
|
|
GdipFree(buff);
|
|
|
|
return stat;
|
2008-09-28 21:21:47 +02:00
|
|
|
}
|
2007-08-10 03:25:27 +02:00
|
|
|
|
2008-05-21 17:47:50 +02:00
|
|
|
lockeddata->Width = act_rect.Width;
|
|
|
|
lockeddata->Height = act_rect.Height;
|
2007-08-08 03:41:55 +02:00
|
|
|
lockeddata->PixelFormat = format;
|
|
|
|
lockeddata->Reserved = flags;
|
2010-02-05 02:05:54 +01:00
|
|
|
lockeddata->Stride = stride;
|
|
|
|
lockeddata->Scan0 = buff + (bitspp / 8) * act_rect.X + stride * act_rect.Y;
|
2007-08-08 03:41:55 +02:00
|
|
|
|
|
|
|
bitmap->lockmode = flags;
|
|
|
|
bitmap->numlocks++;
|
2008-03-07 10:19:03 +01:00
|
|
|
bitmap->bitmapbits = buff;
|
2007-08-08 03:41:55 +02:00
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2009-04-20 09:46:36 +02:00
|
|
|
GpStatus WINGDIPAPI GdipBitmapSetResolution(GpBitmap* bitmap, REAL xdpi, REAL ydpi)
|
|
|
|
{
|
2009-12-27 03:05:58 +01:00
|
|
|
TRACE("(%p, %.2f, %.2f)\n", bitmap, xdpi, ydpi);
|
2009-04-20 09:46:36 +02:00
|
|
|
|
2009-12-27 03:05:58 +01:00
|
|
|
if (!bitmap || xdpi == 0.0 || ydpi == 0.0)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
bitmap->image.xres = xdpi;
|
|
|
|
bitmap->image.yres = ydpi;
|
|
|
|
|
|
|
|
return Ok;
|
2009-04-20 09:46:36 +02:00
|
|
|
}
|
|
|
|
|
2007-08-08 03:41:55 +02:00
|
|
|
GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap,
|
|
|
|
BitmapData* lockeddata)
|
|
|
|
{
|
2010-02-05 02:05:54 +01:00
|
|
|
GpStatus stat;
|
2007-08-08 03:41:55 +02:00
|
|
|
|
2009-12-18 23:07:12 +01:00
|
|
|
TRACE("(%p,%p)\n", bitmap, lockeddata);
|
|
|
|
|
2007-08-08 03:41:55 +02:00
|
|
|
if(!bitmap || !lockeddata)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(!bitmap->lockmode)
|
|
|
|
return WrongState;
|
|
|
|
|
|
|
|
if(lockeddata->Reserved & ImageLockModeUserInputBuf)
|
|
|
|
return NotImplemented;
|
|
|
|
|
|
|
|
if(lockeddata->Reserved & ImageLockModeRead){
|
|
|
|
if(!(--bitmap->numlocks))
|
|
|
|
bitmap->lockmode = 0;
|
|
|
|
|
2008-03-07 10:19:03 +01:00
|
|
|
GdipFree(bitmap->bitmapbits);
|
|
|
|
bitmap->bitmapbits = NULL;
|
2007-08-08 03:41:55 +02:00
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2009-08-28 23:53:57 +02:00
|
|
|
if (!bitmap->bitmapbits)
|
|
|
|
{
|
|
|
|
/* we passed a direct reference; no need to do anything */
|
|
|
|
bitmap->lockmode = 0;
|
2010-01-01 21:55:54 +01:00
|
|
|
bitmap->numlocks = 0;
|
2009-08-28 23:53:57 +02:00
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2010-02-05 02:05:54 +01:00
|
|
|
stat = convert_pixels(bitmap->width, bitmap->height,
|
|
|
|
bitmap->stride, bitmap->bits, bitmap->format,
|
|
|
|
lockeddata->Stride, bitmap->bitmapbits, lockeddata->PixelFormat, NULL);
|
2007-08-08 03:41:55 +02:00
|
|
|
|
2010-02-05 02:05:54 +01:00
|
|
|
if (stat != Ok)
|
|
|
|
{
|
|
|
|
ERR("failed to convert pixels; this should never happen\n");
|
2007-08-08 03:41:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GdipFree(bitmap->bitmapbits);
|
2008-03-07 10:19:03 +01:00
|
|
|
bitmap->bitmapbits = NULL;
|
2008-03-07 10:19:04 +01:00
|
|
|
bitmap->lockmode = 0;
|
2010-01-01 21:55:54 +01:00
|
|
|
bitmap->numlocks = 0;
|
2007-08-08 03:41:55 +02:00
|
|
|
|
2010-02-05 02:05:54 +01:00
|
|
|
return stat;
|
2007-08-08 03:41:55 +02:00
|
|
|
}
|
|
|
|
|
2009-06-02 03:01:26 +02:00
|
|
|
GpStatus WINGDIPAPI GdipCloneBitmapArea(REAL x, REAL y, REAL width, REAL height,
|
|
|
|
PixelFormat format, GpBitmap* srcBitmap, GpBitmap** dstBitmap)
|
|
|
|
{
|
2009-12-07 03:02:35 +01:00
|
|
|
BitmapData lockeddata_src, lockeddata_dst;
|
|
|
|
int i;
|
|
|
|
UINT row_size;
|
|
|
|
Rect area;
|
|
|
|
GpStatus stat;
|
2009-06-02 03:01:26 +02:00
|
|
|
|
2009-12-18 23:22:25 +01:00
|
|
|
TRACE("(%f,%f,%f,%f,0x%x,%p,%p)\n", x, y, width, height, format, srcBitmap, dstBitmap);
|
2009-12-07 03:02:35 +01:00
|
|
|
|
|
|
|
if (!srcBitmap || !dstBitmap || srcBitmap->image.type != ImageTypeBitmap ||
|
|
|
|
x < 0 || y < 0 ||
|
|
|
|
x + width > srcBitmap->width || y + height > srcBitmap->height)
|
|
|
|
{
|
|
|
|
TRACE("<-- InvalidParameter\n");
|
|
|
|
return InvalidParameter;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (format == PixelFormatDontCare)
|
|
|
|
format = srcBitmap->format;
|
|
|
|
|
|
|
|
area.X = roundr(x);
|
|
|
|
area.Y = roundr(y);
|
|
|
|
area.Width = roundr(width);
|
|
|
|
area.Height = roundr(height);
|
|
|
|
|
|
|
|
stat = GdipBitmapLockBits(srcBitmap, &area, ImageLockModeRead, format,
|
|
|
|
&lockeddata_src);
|
|
|
|
if (stat != Ok) return stat;
|
|
|
|
|
|
|
|
stat = GdipCreateBitmapFromScan0(lockeddata_src.Width, lockeddata_src.Height,
|
|
|
|
0, lockeddata_src.PixelFormat, NULL, dstBitmap);
|
|
|
|
if (stat == Ok)
|
|
|
|
{
|
|
|
|
stat = GdipBitmapLockBits(*dstBitmap, NULL, ImageLockModeWrite,
|
|
|
|
lockeddata_src.PixelFormat, &lockeddata_dst);
|
|
|
|
|
|
|
|
if (stat == Ok)
|
|
|
|
{
|
|
|
|
/* copy the image data */
|
|
|
|
row_size = (lockeddata_src.Width * PIXELFORMATBPP(lockeddata_src.PixelFormat) +7)/8;
|
|
|
|
for (i=0; i<lockeddata_src.Height; i++)
|
|
|
|
memcpy((BYTE*)lockeddata_dst.Scan0+lockeddata_dst.Stride*i,
|
|
|
|
(BYTE*)lockeddata_src.Scan0+lockeddata_src.Stride*i,
|
|
|
|
row_size);
|
|
|
|
|
|
|
|
GdipBitmapUnlockBits(*dstBitmap, &lockeddata_dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stat != Ok)
|
|
|
|
GdipDisposeImage((GpImage*)*dstBitmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
GdipBitmapUnlockBits(srcBitmap, &lockeddata_src);
|
|
|
|
|
|
|
|
if (stat != Ok)
|
|
|
|
{
|
|
|
|
*dstBitmap = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return stat;
|
2009-06-02 03:01:26 +02:00
|
|
|
}
|
|
|
|
|
2009-03-07 18:33:55 +01:00
|
|
|
GpStatus WINGDIPAPI GdipCloneBitmapAreaI(INT x, INT y, INT width, INT height,
|
|
|
|
PixelFormat format, GpBitmap* srcBitmap, GpBitmap** dstBitmap)
|
|
|
|
{
|
2009-12-18 23:22:25 +01:00
|
|
|
TRACE("(%i,%i,%i,%i,0x%x,%p,%p)\n", x, y, width, height, format, srcBitmap, dstBitmap);
|
2009-03-07 18:33:55 +01:00
|
|
|
|
2009-12-07 03:02:35 +01:00
|
|
|
return GdipCloneBitmapArea(x, y, width, height, format, srcBitmap, dstBitmap);
|
2009-03-07 18:33:55 +01:00
|
|
|
}
|
|
|
|
|
2008-07-02 03:03:34 +02:00
|
|
|
GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage)
|
|
|
|
{
|
2008-10-20 15:10:10 +02:00
|
|
|
GpStatus stat = GenericError;
|
2008-07-02 03:03:34 +02:00
|
|
|
|
2008-09-05 12:41:49 +02:00
|
|
|
TRACE("%p, %p\n", image, cloneImage);
|
2008-07-02 03:03:34 +02:00
|
|
|
|
2008-09-05 12:41:49 +02:00
|
|
|
if (!image || !cloneImage)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-08-28 23:21:27 +02:00
|
|
|
if (image->picture)
|
2008-09-05 12:41:49 +02:00
|
|
|
{
|
2009-08-28 23:21:27 +02:00
|
|
|
IStream* stream;
|
|
|
|
HRESULT hr;
|
|
|
|
INT size;
|
|
|
|
LARGE_INTEGER move;
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(0, TRUE, &stream);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return GenericError;
|
|
|
|
|
|
|
|
hr = IPicture_SaveAsFile(image->picture, stream, FALSE, &size);
|
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to save image on stream\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set seek pointer back to the beginning of the picture */
|
|
|
|
move.QuadPart = 0;
|
|
|
|
hr = IStream_Seek(stream, move, STREAM_SEEK_SET, NULL);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
stat = GdipLoadImageFromStream(stream, cloneImage);
|
|
|
|
if (stat != Ok) WARN("Failed to load image from stream\n");
|
|
|
|
|
|
|
|
out:
|
|
|
|
IStream_Release(stream);
|
|
|
|
return stat;
|
2008-09-05 12:41:49 +02:00
|
|
|
}
|
2009-08-28 23:21:27 +02:00
|
|
|
else if (image->type == ImageTypeBitmap)
|
|
|
|
{
|
|
|
|
GpBitmap *bitmap = (GpBitmap*)image;
|
|
|
|
BitmapData lockeddata_src, lockeddata_dst;
|
|
|
|
int i;
|
|
|
|
UINT row_size;
|
2008-09-05 12:41:49 +02:00
|
|
|
|
2009-08-28 23:21:27 +02:00
|
|
|
stat = GdipBitmapLockBits(bitmap, NULL, ImageLockModeRead, bitmap->format,
|
|
|
|
&lockeddata_src);
|
|
|
|
if (stat != Ok) return stat;
|
2008-10-16 16:07:44 +02:00
|
|
|
|
2009-08-28 23:21:27 +02:00
|
|
|
stat = GdipCreateBitmapFromScan0(lockeddata_src.Width, lockeddata_src.Height,
|
|
|
|
0, lockeddata_src.PixelFormat, NULL, (GpBitmap**)cloneImage);
|
|
|
|
if (stat == Ok)
|
|
|
|
{
|
|
|
|
stat = GdipBitmapLockBits((GpBitmap*)*cloneImage, NULL, ImageLockModeWrite,
|
|
|
|
lockeddata_src.PixelFormat, &lockeddata_dst);
|
2008-09-05 12:41:49 +02:00
|
|
|
|
2009-08-28 23:21:27 +02:00
|
|
|
if (stat == Ok)
|
|
|
|
{
|
|
|
|
/* copy the image data */
|
|
|
|
row_size = (lockeddata_src.Width * PIXELFORMATBPP(lockeddata_src.PixelFormat) +7)/8;
|
|
|
|
for (i=0; i<lockeddata_src.Height; i++)
|
|
|
|
memcpy((BYTE*)lockeddata_dst.Scan0+lockeddata_dst.Stride*i,
|
|
|
|
(BYTE*)lockeddata_src.Scan0+lockeddata_src.Stride*i,
|
|
|
|
row_size);
|
|
|
|
|
|
|
|
GdipBitmapUnlockBits((GpBitmap*)*cloneImage, &lockeddata_dst);
|
|
|
|
}
|
|
|
|
|
2009-12-07 03:07:40 +01:00
|
|
|
if (stat != Ok)
|
|
|
|
GdipDisposeImage(*cloneImage);
|
2009-08-28 23:21:27 +02:00
|
|
|
}
|
|
|
|
|
2009-12-07 03:07:40 +01:00
|
|
|
GdipBitmapUnlockBits(bitmap, &lockeddata_src);
|
|
|
|
|
2009-08-28 23:21:27 +02:00
|
|
|
if (stat != Ok)
|
|
|
|
{
|
|
|
|
*cloneImage = NULL;
|
|
|
|
}
|
2009-09-20 18:48:39 +02:00
|
|
|
else memcpy(&(*cloneImage)->format, &image->format, sizeof(GUID));
|
2009-09-14 18:23:45 +02:00
|
|
|
|
2009-08-28 23:21:27 +02:00
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("GpImage with no IPicture or bitmap?!\n");
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
2008-07-02 03:03:34 +02:00
|
|
|
}
|
|
|
|
|
2007-08-08 03:42:04 +02:00
|
|
|
GpStatus WINGDIPAPI GdipCreateBitmapFromFile(GDIPCONST WCHAR* filename,
|
|
|
|
GpBitmap **bitmap)
|
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
IStream *stream;
|
|
|
|
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("(%s) %p\n", debugstr_w(filename), bitmap);
|
|
|
|
|
2007-08-08 03:42:04 +02:00
|
|
|
if(!filename || !bitmap)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
stat = GdipCreateStreamOnFile(filename, GENERIC_READ, &stream);
|
|
|
|
|
|
|
|
if(stat != Ok)
|
|
|
|
return stat;
|
|
|
|
|
|
|
|
stat = GdipCreateBitmapFromStream(stream, bitmap);
|
|
|
|
|
2008-02-24 16:41:27 +01:00
|
|
|
IStream_Release(stream);
|
2007-08-08 03:42:04 +02:00
|
|
|
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
2008-07-10 16:39:29 +02:00
|
|
|
GpStatus WINGDIPAPI GdipCreateBitmapFromGdiDib(GDIPCONST BITMAPINFO* info,
|
|
|
|
VOID *bits, GpBitmap **bitmap)
|
|
|
|
{
|
|
|
|
DWORD height, stride;
|
|
|
|
PixelFormat format;
|
|
|
|
|
|
|
|
FIXME("(%p, %p, %p) - partially implemented\n", info, bits, bitmap);
|
|
|
|
|
|
|
|
height = abs(info->bmiHeader.biHeight);
|
|
|
|
stride = ((info->bmiHeader.biWidth * info->bmiHeader.biBitCount + 31) >> 3) & ~3;
|
|
|
|
|
|
|
|
if(info->bmiHeader.biHeight > 0) /* bottom-up */
|
|
|
|
{
|
|
|
|
bits = (BYTE*)bits + (height - 1) * stride;
|
|
|
|
stride = -stride;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(info->bmiHeader.biBitCount) {
|
|
|
|
case 1:
|
|
|
|
format = PixelFormat1bppIndexed;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
format = PixelFormat4bppIndexed;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
format = PixelFormat8bppIndexed;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
format = PixelFormat24bppRGB;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("don't know how to handle %d bpp\n", info->bmiHeader.biBitCount);
|
|
|
|
*bitmap = NULL;
|
|
|
|
return InvalidParameter;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GdipCreateBitmapFromScan0(info->bmiHeader.biWidth, height, stride, format,
|
|
|
|
bits, bitmap);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-03-05 04:22:01 +01:00
|
|
|
/* FIXME: no icm */
|
|
|
|
GpStatus WINGDIPAPI GdipCreateBitmapFromFileICM(GDIPCONST WCHAR* filename,
|
|
|
|
GpBitmap **bitmap)
|
|
|
|
{
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("(%s) %p\n", debugstr_w(filename), bitmap);
|
|
|
|
|
2008-03-05 04:22:01 +01:00
|
|
|
return GdipCreateBitmapFromFile(filename, bitmap);
|
|
|
|
}
|
|
|
|
|
2008-07-11 22:43:50 +02:00
|
|
|
GpStatus WINGDIPAPI GdipCreateBitmapFromResource(HINSTANCE hInstance,
|
|
|
|
GDIPCONST WCHAR* lpBitmapName, GpBitmap** bitmap)
|
|
|
|
{
|
|
|
|
HBITMAP hbm;
|
|
|
|
GpStatus stat = InvalidParameter;
|
|
|
|
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("%p (%s) %p\n", hInstance, debugstr_w(lpBitmapName), bitmap);
|
|
|
|
|
2008-07-11 22:43:50 +02:00
|
|
|
if(!lpBitmapName || !bitmap)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
/* load DIB */
|
2008-12-05 07:53:04 +01:00
|
|
|
hbm = LoadImageW(hInstance, lpBitmapName, IMAGE_BITMAP, 0, 0,
|
|
|
|
LR_CREATEDIBSECTION);
|
2008-07-11 22:43:50 +02:00
|
|
|
|
|
|
|
if(hbm){
|
|
|
|
stat = GdipCreateBitmapFromHBITMAP(hbm, NULL, bitmap);
|
|
|
|
DeleteObject(hbm);
|
|
|
|
}
|
|
|
|
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
2007-12-19 09:58:51 +01:00
|
|
|
GpStatus WINGDIPAPI GdipCreateHBITMAPFromBitmap(GpBitmap* bitmap,
|
|
|
|
HBITMAP* hbmReturn, ARGB background)
|
|
|
|
{
|
2009-08-27 23:58:11 +02:00
|
|
|
GpStatus stat;
|
|
|
|
HBITMAP result, oldbitmap;
|
|
|
|
UINT width, height;
|
|
|
|
HDC hdc;
|
|
|
|
GpGraphics *graphics;
|
|
|
|
BITMAPINFOHEADER bih;
|
|
|
|
void *bits;
|
|
|
|
TRACE("(%p,%p,%x)\n", bitmap, hbmReturn, background);
|
|
|
|
|
|
|
|
if (!bitmap || !hbmReturn) return InvalidParameter;
|
|
|
|
|
|
|
|
GdipGetImageWidth((GpImage*)bitmap, &width);
|
|
|
|
GdipGetImageHeight((GpImage*)bitmap, &height);
|
|
|
|
|
|
|
|
bih.biSize = sizeof(bih);
|
|
|
|
bih.biWidth = width;
|
|
|
|
bih.biHeight = height;
|
|
|
|
bih.biPlanes = 1;
|
|
|
|
bih.biBitCount = 32;
|
|
|
|
bih.biCompression = BI_RGB;
|
|
|
|
bih.biSizeImage = 0;
|
|
|
|
bih.biXPelsPerMeter = 0;
|
|
|
|
bih.biYPelsPerMeter = 0;
|
|
|
|
bih.biClrUsed = 0;
|
|
|
|
bih.biClrImportant = 0;
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(NULL);
|
|
|
|
if (!hdc) return GenericError;
|
|
|
|
|
|
|
|
result = CreateDIBSection(hdc, (BITMAPINFO*)&bih, DIB_RGB_COLORS, &bits,
|
|
|
|
NULL, 0);
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
oldbitmap = SelectObject(hdc, result);
|
2007-12-19 09:58:51 +01:00
|
|
|
|
2009-08-27 23:58:11 +02:00
|
|
|
stat = GdipCreateFromHDC(hdc, &graphics);
|
|
|
|
if (stat == Ok)
|
|
|
|
{
|
|
|
|
stat = GdipGraphicsClear(graphics, background);
|
2007-12-19 09:58:51 +01:00
|
|
|
|
2009-08-27 23:58:11 +02:00
|
|
|
if (stat == Ok)
|
|
|
|
stat = GdipDrawImage(graphics, (GpImage*)bitmap, 0, 0);
|
|
|
|
|
|
|
|
GdipDeleteGraphics(graphics);
|
|
|
|
}
|
|
|
|
|
|
|
|
SelectObject(hdc, oldbitmap);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
stat = GenericError;
|
|
|
|
|
|
|
|
DeleteDC(hdc);
|
|
|
|
|
|
|
|
if (stat != Ok && result)
|
|
|
|
{
|
|
|
|
DeleteObject(result);
|
|
|
|
result = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*hbmReturn = result;
|
|
|
|
|
|
|
|
return stat;
|
2007-12-19 09:58:51 +01:00
|
|
|
}
|
|
|
|
|
2007-08-10 03:25:37 +02:00
|
|
|
GpStatus WINGDIPAPI GdipConvertToEmfPlus(const GpGraphics* ref,
|
|
|
|
GpMetafile* metafile, BOOL* succ, EmfType emfType,
|
|
|
|
const WCHAR* description, GpMetafile** out_metafile)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
2009-12-18 23:12:51 +01:00
|
|
|
TRACE("(%p,%p,%p,%u,%s,%p)\n", ref, metafile, succ, emfType,
|
|
|
|
debugstr_w(description), out_metafile);
|
|
|
|
|
2007-08-10 03:25:37 +02:00
|
|
|
if(!ref || !metafile || !out_metafile)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
*succ = FALSE;
|
|
|
|
*out_metafile = NULL;
|
|
|
|
|
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2007-08-09 04:42:28 +02:00
|
|
|
/* FIXME: this should create a bitmap in the given size with the attributes
|
|
|
|
* (resolution etc.) of the graphics object */
|
|
|
|
GpStatus WINGDIPAPI GdipCreateBitmapFromGraphics(INT width, INT height,
|
|
|
|
GpGraphics* target, GpBitmap** bitmap)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
GpStatus ret;
|
|
|
|
|
|
|
|
if(!target || !bitmap)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(!(calls++))
|
|
|
|
FIXME("hacked stub\n");
|
|
|
|
|
|
|
|
ret = GdipCreateBitmapFromScan0(width, height, 0, PixelFormat24bppRGB,
|
|
|
|
NULL, bitmap);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-02-02 17:15:53 +01:00
|
|
|
GpStatus WINGDIPAPI GdipCreateBitmapFromHICON(HICON hicon, GpBitmap** bitmap)
|
|
|
|
{
|
2009-08-25 00:05:24 +02:00
|
|
|
GpStatus stat;
|
2009-02-02 17:15:53 +01:00
|
|
|
ICONINFO iinfo;
|
2009-08-25 00:05:24 +02:00
|
|
|
BITMAP bm;
|
|
|
|
int ret;
|
|
|
|
UINT width, height;
|
|
|
|
GpRect rect;
|
|
|
|
BitmapData lockeddata;
|
|
|
|
HDC screendc;
|
|
|
|
BOOL has_alpha;
|
|
|
|
int x, y;
|
|
|
|
BYTE *bits;
|
|
|
|
BITMAPINFOHEADER bih;
|
|
|
|
DWORD *src;
|
|
|
|
BYTE *dst_row;
|
|
|
|
DWORD *dst;
|
2009-02-02 17:15:53 +01:00
|
|
|
|
|
|
|
TRACE("%p, %p\n", hicon, bitmap);
|
|
|
|
|
|
|
|
if(!bitmap || !GetIconInfo(hicon, &iinfo))
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-08-25 00:05:24 +02:00
|
|
|
/* get the size of the icon */
|
|
|
|
ret = GetObjectA(iinfo.hbmColor ? iinfo.hbmColor : iinfo.hbmMask, sizeof(bm), &bm);
|
|
|
|
if (ret == 0) {
|
|
|
|
DeleteObject(iinfo.hbmColor);
|
|
|
|
DeleteObject(iinfo.hbmMask);
|
|
|
|
return GenericError;
|
|
|
|
}
|
2009-02-02 17:15:53 +01:00
|
|
|
|
2009-08-25 00:05:24 +02:00
|
|
|
width = bm.bmWidth;
|
2009-02-02 17:15:53 +01:00
|
|
|
|
2009-08-25 00:05:24 +02:00
|
|
|
if (iinfo.hbmColor)
|
|
|
|
height = abs(bm.bmHeight);
|
|
|
|
else /* combined bitmap + mask */
|
|
|
|
height = abs(bm.bmHeight) / 2;
|
|
|
|
|
|
|
|
bits = HeapAlloc(GetProcessHeap(), 0, 4*width*height);
|
|
|
|
if (!bits) {
|
|
|
|
DeleteObject(iinfo.hbmColor);
|
|
|
|
DeleteObject(iinfo.hbmMask);
|
|
|
|
return OutOfMemory;
|
2009-02-02 17:15:53 +01:00
|
|
|
}
|
|
|
|
|
2009-08-25 00:05:24 +02:00
|
|
|
stat = GdipCreateBitmapFromScan0(width, height, 0, PixelFormat32bppARGB, NULL, bitmap);
|
|
|
|
if (stat != Ok) {
|
|
|
|
DeleteObject(iinfo.hbmColor);
|
|
|
|
DeleteObject(iinfo.hbmMask);
|
|
|
|
HeapFree(GetProcessHeap(), 0, bits);
|
|
|
|
return stat;
|
|
|
|
}
|
2009-02-02 17:15:53 +01:00
|
|
|
|
2009-08-25 00:05:24 +02:00
|
|
|
rect.X = 0;
|
|
|
|
rect.Y = 0;
|
|
|
|
rect.Width = width;
|
|
|
|
rect.Height = height;
|
|
|
|
|
|
|
|
stat = GdipBitmapLockBits(*bitmap, &rect, ImageLockModeWrite, PixelFormat32bppARGB, &lockeddata);
|
|
|
|
if (stat != Ok) {
|
|
|
|
DeleteObject(iinfo.hbmColor);
|
|
|
|
DeleteObject(iinfo.hbmMask);
|
|
|
|
HeapFree(GetProcessHeap(), 0, bits);
|
|
|
|
GdipDisposeImage((GpImage*)*bitmap);
|
|
|
|
return stat;
|
2009-02-02 17:15:53 +01:00
|
|
|
}
|
|
|
|
|
2009-08-25 00:05:24 +02:00
|
|
|
bih.biSize = sizeof(bih);
|
|
|
|
bih.biWidth = width;
|
|
|
|
bih.biHeight = -height;
|
|
|
|
bih.biPlanes = 1;
|
|
|
|
bih.biBitCount = 32;
|
|
|
|
bih.biCompression = BI_RGB;
|
|
|
|
bih.biSizeImage = 0;
|
|
|
|
bih.biXPelsPerMeter = 0;
|
|
|
|
bih.biYPelsPerMeter = 0;
|
|
|
|
bih.biClrUsed = 0;
|
|
|
|
bih.biClrImportant = 0;
|
|
|
|
|
|
|
|
screendc = GetDC(0);
|
|
|
|
if (iinfo.hbmColor)
|
|
|
|
{
|
|
|
|
GetDIBits(screendc, iinfo.hbmColor, 0, height, bits, (BITMAPINFO*)&bih, DIB_RGB_COLORS);
|
|
|
|
|
|
|
|
if (bm.bmBitsPixel == 32)
|
|
|
|
{
|
|
|
|
has_alpha = FALSE;
|
|
|
|
|
|
|
|
/* If any pixel has a non-zero alpha, ignore hbmMask */
|
|
|
|
src = (DWORD*)bits;
|
|
|
|
for (x=0; x<width && !has_alpha; x++)
|
|
|
|
for (y=0; y<height && !has_alpha; y++)
|
|
|
|
if ((*src++ & 0xff000000) != 0)
|
|
|
|
has_alpha = TRUE;
|
|
|
|
}
|
|
|
|
else has_alpha = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GetDIBits(screendc, iinfo.hbmMask, 0, height, bits, (BITMAPINFO*)&bih, DIB_RGB_COLORS);
|
|
|
|
has_alpha = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* copy the image data to the Bitmap */
|
|
|
|
src = (DWORD*)bits;
|
|
|
|
dst_row = lockeddata.Scan0;
|
|
|
|
for (y=0; y<height; y++)
|
|
|
|
{
|
|
|
|
memcpy(dst_row, src, width*4);
|
|
|
|
src += width;
|
|
|
|
dst_row += lockeddata.Stride;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!has_alpha)
|
|
|
|
{
|
|
|
|
if (iinfo.hbmMask)
|
|
|
|
{
|
|
|
|
/* read alpha data from the mask */
|
|
|
|
if (iinfo.hbmColor)
|
|
|
|
GetDIBits(screendc, iinfo.hbmMask, 0, height, bits, (BITMAPINFO*)&bih, DIB_RGB_COLORS);
|
|
|
|
else
|
|
|
|
GetDIBits(screendc, iinfo.hbmMask, height, height, bits, (BITMAPINFO*)&bih, DIB_RGB_COLORS);
|
|
|
|
|
|
|
|
src = (DWORD*)bits;
|
|
|
|
dst_row = lockeddata.Scan0;
|
|
|
|
for (y=0; y<height; y++)
|
|
|
|
{
|
|
|
|
dst = (DWORD*)dst_row;
|
|
|
|
for (x=0; x<height; x++)
|
|
|
|
{
|
|
|
|
DWORD src_value = *src++;
|
|
|
|
if (src_value)
|
|
|
|
*dst++ = 0;
|
|
|
|
else
|
|
|
|
*dst++ |= 0xff000000;
|
|
|
|
}
|
|
|
|
dst_row += lockeddata.Stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* set constant alpha of 255 */
|
|
|
|
dst_row = bits;
|
|
|
|
for (y=0; y<height; y++)
|
|
|
|
{
|
|
|
|
dst = (DWORD*)dst_row;
|
|
|
|
for (x=0; x<height; x++)
|
|
|
|
*dst++ |= 0xff000000;
|
|
|
|
dst_row += lockeddata.Stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReleaseDC(0, screendc);
|
2009-02-02 17:15:53 +01:00
|
|
|
|
|
|
|
DeleteObject(iinfo.hbmColor);
|
|
|
|
DeleteObject(iinfo.hbmMask);
|
|
|
|
|
2009-08-25 00:05:24 +02:00
|
|
|
GdipBitmapUnlockBits(*bitmap, &lockeddata);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, bits);
|
|
|
|
|
2009-02-02 17:15:53 +01:00
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2009-12-12 00:16:21 +01:00
|
|
|
static void generate_halftone_palette(ARGB *entries, UINT count)
|
|
|
|
{
|
|
|
|
static const BYTE halftone_values[6]={0x00,0x33,0x66,0x99,0xcc,0xff};
|
|
|
|
UINT i;
|
|
|
|
|
|
|
|
for (i=0; i<8 && i<count; i++)
|
|
|
|
{
|
|
|
|
entries[i] = 0xff000000;
|
|
|
|
if (i&1) entries[i] |= 0x800000;
|
|
|
|
if (i&2) entries[i] |= 0x8000;
|
|
|
|
if (i&4) entries[i] |= 0x80;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (8 < count)
|
|
|
|
entries[i] = 0xffc0c0c0;
|
|
|
|
|
|
|
|
for (i=9; i<16 && i<count; i++)
|
|
|
|
{
|
|
|
|
entries[i] = 0xff000000;
|
|
|
|
if (i&1) entries[i] |= 0xff0000;
|
|
|
|
if (i&2) entries[i] |= 0xff00;
|
|
|
|
if (i&4) entries[i] |= 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=16; i<40 && i<count; i++)
|
|
|
|
{
|
|
|
|
entries[i] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=40; i<256 && i<count; i++)
|
|
|
|
{
|
|
|
|
entries[i] = 0xff000000;
|
|
|
|
entries[i] |= halftone_values[(i-40)%6];
|
|
|
|
entries[i] |= halftone_values[((i-40)/6)%6] << 8;
|
|
|
|
entries[i] |= halftone_values[((i-40)/36)%6] << 16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-27 02:46:55 +01:00
|
|
|
static GpStatus get_screen_resolution(REAL *xres, REAL *yres)
|
|
|
|
{
|
|
|
|
HDC screendc = GetDC(0);
|
|
|
|
|
|
|
|
if (!screendc) return GenericError;
|
|
|
|
|
|
|
|
*xres = (REAL)GetDeviceCaps(screendc, LOGPIXELSX);
|
|
|
|
*yres = (REAL)GetDeviceCaps(screendc, LOGPIXELSY);
|
|
|
|
|
|
|
|
ReleaseDC(0, screendc);
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-08-01 04:15:52 +02:00
|
|
|
GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
|
|
|
|
PixelFormat format, BYTE* scan0, GpBitmap** bitmap)
|
|
|
|
{
|
2009-08-28 23:21:27 +02:00
|
|
|
BITMAPINFOHEADER bmih;
|
|
|
|
HBITMAP hbitmap;
|
|
|
|
INT row_size, dib_stride;
|
|
|
|
HDC hdc;
|
|
|
|
BYTE *bits;
|
|
|
|
int i;
|
2009-12-27 02:46:55 +01:00
|
|
|
REAL xres, yres;
|
|
|
|
GpStatus stat;
|
2007-08-01 04:15:52 +02:00
|
|
|
|
2009-12-18 23:22:25 +01:00
|
|
|
TRACE("%d %d %d 0x%x %p %p\n", width, height, stride, format, scan0, bitmap);
|
2007-08-01 04:15:52 +02:00
|
|
|
|
2008-10-16 16:09:49 +02:00
|
|
|
if (!bitmap) return InvalidParameter;
|
|
|
|
|
|
|
|
if(width <= 0 || height <= 0 || (scan0 && (stride % 4))){
|
2007-08-09 04:42:24 +02:00
|
|
|
*bitmap = NULL;
|
2007-08-01 04:15:52 +02:00
|
|
|
return InvalidParameter;
|
2007-08-09 04:42:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(scan0 && !stride)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-12-27 02:46:55 +01:00
|
|
|
stat = get_screen_resolution(&xres, &yres);
|
|
|
|
if (stat != Ok) return stat;
|
|
|
|
|
2009-08-28 23:21:27 +02:00
|
|
|
row_size = (width * PIXELFORMATBPP(format)+7) / 8;
|
|
|
|
dib_stride = (row_size + 3) & ~3;
|
2007-08-01 04:15:52 +02:00
|
|
|
|
2009-08-28 23:21:27 +02:00
|
|
|
if(stride == 0)
|
|
|
|
stride = dib_stride;
|
2007-08-09 04:42:24 +02:00
|
|
|
|
2009-08-28 23:21:27 +02:00
|
|
|
bmih.biSize = sizeof(BITMAPINFOHEADER);
|
|
|
|
bmih.biWidth = width;
|
|
|
|
bmih.biHeight = -height;
|
|
|
|
bmih.biPlanes = 1;
|
|
|
|
/* FIXME: use the rest of the data from format */
|
|
|
|
bmih.biBitCount = PIXELFORMATBPP(format);
|
|
|
|
bmih.biCompression = BI_RGB;
|
|
|
|
bmih.biSizeImage = 0;
|
|
|
|
bmih.biXPelsPerMeter = 0;
|
|
|
|
bmih.biYPelsPerMeter = 0;
|
|
|
|
bmih.biClrUsed = 0;
|
|
|
|
bmih.biClrImportant = 0;
|
2007-08-01 04:15:52 +02:00
|
|
|
|
2009-08-28 23:21:27 +02:00
|
|
|
hdc = CreateCompatibleDC(NULL);
|
|
|
|
if (!hdc) return GenericError;
|
2007-08-01 04:15:52 +02:00
|
|
|
|
2009-08-28 23:21:27 +02:00
|
|
|
hbitmap = CreateDIBSection(hdc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, (void**)&bits,
|
|
|
|
NULL, 0);
|
2007-08-01 04:15:52 +02:00
|
|
|
|
2009-08-28 23:21:27 +02:00
|
|
|
DeleteDC(hdc);
|
2007-08-01 04:15:52 +02:00
|
|
|
|
2009-08-28 23:21:27 +02:00
|
|
|
if (!hbitmap) return GenericError;
|
2007-08-01 04:15:52 +02:00
|
|
|
|
2009-08-28 23:21:27 +02:00
|
|
|
/* copy bits to the dib if necessary */
|
2009-08-28 23:53:57 +02:00
|
|
|
/* FIXME: should reference the bits instead of copying them */
|
2009-08-28 23:21:27 +02:00
|
|
|
if (scan0)
|
|
|
|
for (i=0; i<height; i++)
|
|
|
|
memcpy(bits+i*dib_stride, scan0+i*stride, row_size);
|
2007-08-01 04:15:52 +02:00
|
|
|
|
2009-08-28 23:21:27 +02:00
|
|
|
*bitmap = GdipAlloc(sizeof(GpBitmap));
|
|
|
|
if(!*bitmap)
|
|
|
|
{
|
|
|
|
DeleteObject(hbitmap);
|
|
|
|
return OutOfMemory;
|
2007-08-01 04:15:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
(*bitmap)->image.type = ImageTypeBitmap;
|
2009-09-14 18:23:45 +02:00
|
|
|
memcpy(&(*bitmap)->image.format, &ImageFormatMemoryBMP, sizeof(GUID));
|
2008-05-09 14:39:43 +02:00
|
|
|
(*bitmap)->image.flags = ImageFlagsNone;
|
2009-12-11 23:51:46 +01:00
|
|
|
(*bitmap)->image.palette_flags = 0;
|
|
|
|
(*bitmap)->image.palette_count = 0;
|
|
|
|
(*bitmap)->image.palette_size = 0;
|
|
|
|
(*bitmap)->image.palette_entries = NULL;
|
2009-12-27 02:46:55 +01:00
|
|
|
(*bitmap)->image.xres = xres;
|
|
|
|
(*bitmap)->image.yres = yres;
|
2007-08-01 04:16:20 +02:00
|
|
|
(*bitmap)->width = width;
|
|
|
|
(*bitmap)->height = height;
|
2007-08-04 02:30:30 +02:00
|
|
|
(*bitmap)->format = format;
|
2009-08-28 23:21:27 +02:00
|
|
|
(*bitmap)->image.picture = NULL;
|
|
|
|
(*bitmap)->hbitmap = hbitmap;
|
|
|
|
(*bitmap)->hdc = NULL;
|
2009-08-28 23:53:57 +02:00
|
|
|
(*bitmap)->bits = bits;
|
|
|
|
(*bitmap)->stride = dib_stride;
|
2007-08-01 04:15:52 +02:00
|
|
|
|
2009-12-12 00:16:21 +01:00
|
|
|
if (format == PixelFormat1bppIndexed ||
|
|
|
|
format == PixelFormat4bppIndexed ||
|
|
|
|
format == PixelFormat8bppIndexed)
|
|
|
|
{
|
|
|
|
(*bitmap)->image.palette_size = (*bitmap)->image.palette_count = 1 << PIXELFORMATBPP(format);
|
|
|
|
(*bitmap)->image.palette_entries = GdipAlloc(sizeof(ARGB) * ((*bitmap)->image.palette_size));
|
|
|
|
|
|
|
|
if (!(*bitmap)->image.palette_entries)
|
|
|
|
{
|
|
|
|
GdipDisposeImage(&(*bitmap)->image);
|
|
|
|
*bitmap = NULL;
|
|
|
|
return OutOfMemory;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (format == PixelFormat1bppIndexed)
|
|
|
|
{
|
|
|
|
(*bitmap)->image.palette_flags = PaletteFlagsGrayScale;
|
|
|
|
(*bitmap)->image.palette_entries[0] = 0xff000000;
|
|
|
|
(*bitmap)->image.palette_entries[1] = 0xffffffff;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (format == PixelFormat8bppIndexed)
|
|
|
|
(*bitmap)->image.palette_flags = PaletteFlagsHalftone;
|
|
|
|
|
|
|
|
generate_halftone_palette((*bitmap)->image.palette_entries,
|
|
|
|
(*bitmap)->image.palette_count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-18 22:09:45 +01:00
|
|
|
TRACE("<-- %p\n", *bitmap);
|
|
|
|
|
2007-08-01 04:15:52 +02:00
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-08-04 02:30:22 +02:00
|
|
|
GpStatus WINGDIPAPI GdipCreateBitmapFromStream(IStream* stream,
|
|
|
|
GpBitmap **bitmap)
|
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("%p %p\n", stream, bitmap);
|
|
|
|
|
2007-08-04 02:30:22 +02:00
|
|
|
stat = GdipLoadImageFromStream(stream, (GpImage**) bitmap);
|
|
|
|
|
|
|
|
if(stat != Ok)
|
|
|
|
return stat;
|
|
|
|
|
2007-08-08 03:42:20 +02:00
|
|
|
if((*bitmap)->image.type != ImageTypeBitmap){
|
2009-08-20 23:43:47 +02:00
|
|
|
GdipDisposeImage(&(*bitmap)->image);
|
|
|
|
*bitmap = NULL;
|
2007-08-08 03:42:20 +02:00
|
|
|
return GenericError; /* FIXME: what error to return? */
|
2007-08-04 02:30:30 +02:00
|
|
|
}
|
|
|
|
|
2007-08-04 02:30:22 +02:00
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-08-04 02:30:30 +02:00
|
|
|
/* FIXME: no icm */
|
2007-08-01 04:16:04 +02:00
|
|
|
GpStatus WINGDIPAPI GdipCreateBitmapFromStreamICM(IStream* stream,
|
|
|
|
GpBitmap **bitmap)
|
|
|
|
{
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("%p %p\n", stream, bitmap);
|
|
|
|
|
2007-08-04 02:30:30 +02:00
|
|
|
return GdipCreateBitmapFromStream(stream, bitmap);
|
2007-08-01 04:16:04 +02:00
|
|
|
}
|
|
|
|
|
2008-11-04 06:54:32 +01:00
|
|
|
GpStatus WINGDIPAPI GdipCreateCachedBitmap(GpBitmap *bitmap, GpGraphics *graphics,
|
|
|
|
GpCachedBitmap **cachedbmp)
|
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
|
|
|
|
TRACE("%p %p %p\n", bitmap, graphics, cachedbmp);
|
|
|
|
|
|
|
|
if(!bitmap || !graphics || !cachedbmp)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
*cachedbmp = GdipAlloc(sizeof(GpCachedBitmap));
|
|
|
|
if(!*cachedbmp)
|
|
|
|
return OutOfMemory;
|
|
|
|
|
2008-11-21 23:57:48 +01:00
|
|
|
stat = GdipCloneImage(&(bitmap->image), &(*cachedbmp)->image);
|
2008-11-04 06:54:32 +01:00
|
|
|
if(stat != Ok){
|
|
|
|
GdipFree(*cachedbmp);
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2009-05-27 20:16:20 +02:00
|
|
|
GpStatus WINGDIPAPI GdipCreateHICONFromBitmap(GpBitmap *bitmap, HICON *hicon)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p)\n", bitmap, hicon);
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2008-11-04 06:54:32 +01:00
|
|
|
GpStatus WINGDIPAPI GdipDeleteCachedBitmap(GpCachedBitmap *cachedbmp)
|
|
|
|
{
|
|
|
|
TRACE("%p\n", cachedbmp);
|
|
|
|
|
|
|
|
if(!cachedbmp)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-11-21 23:57:48 +01:00
|
|
|
GdipDisposeImage(cachedbmp->image);
|
|
|
|
GdipFree(cachedbmp);
|
2008-11-04 06:54:32 +01:00
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipDrawCachedBitmap(GpGraphics *graphics,
|
|
|
|
GpCachedBitmap *cachedbmp, INT x, INT y)
|
|
|
|
{
|
|
|
|
TRACE("%p %p %d %d\n", graphics, cachedbmp, x, y);
|
|
|
|
|
|
|
|
if(!graphics || !cachedbmp)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-11-21 23:57:48 +01:00
|
|
|
return GdipDrawImage(graphics, cachedbmp->image, (REAL)x, (REAL)y);
|
2008-11-04 06:54:32 +01:00
|
|
|
}
|
|
|
|
|
2009-06-04 06:31:34 +02:00
|
|
|
GpStatus WINGDIPAPI GdipEmfToWmfBits(HENHMETAFILE hemf, UINT cbData16,
|
|
|
|
LPBYTE pData16, INT iMapMode, INT eFlags)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %d, %p, %d, %d): stub\n", hemf, cbData16, pData16, iMapMode, eFlags);
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2007-07-25 02:19:18 +02:00
|
|
|
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
|
|
|
|
{
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("%p\n", image);
|
|
|
|
|
2007-08-01 04:14:57 +02:00
|
|
|
if(!image)
|
|
|
|
return InvalidParameter;
|
2007-07-25 02:19:18 +02:00
|
|
|
|
2009-08-28 23:21:27 +02:00
|
|
|
if (image->picture)
|
|
|
|
IPicture_Release(image->picture);
|
2008-03-07 10:19:03 +01:00
|
|
|
if (image->type == ImageTypeBitmap)
|
2009-08-28 22:05:38 +02:00
|
|
|
{
|
2008-03-07 10:19:03 +01:00
|
|
|
GdipFree(((GpBitmap*)image)->bitmapbits);
|
2009-08-28 22:05:38 +02:00
|
|
|
DeleteDC(((GpBitmap*)image)->hdc);
|
|
|
|
}
|
2009-12-11 23:51:46 +01:00
|
|
|
GdipFree(image->palette_entries);
|
2007-08-01 04:14:57 +02:00
|
|
|
GdipFree(image);
|
2007-07-25 02:19:18 +02:00
|
|
|
|
2007-08-01 04:14:57 +02:00
|
|
|
return Ok;
|
2007-07-25 02:19:18 +02:00
|
|
|
}
|
|
|
|
|
2007-08-01 04:15:33 +02:00
|
|
|
GpStatus WINGDIPAPI GdipFindFirstImageItem(GpImage *image, ImageItemData* item)
|
|
|
|
{
|
2009-12-18 23:12:51 +01:00
|
|
|
static int calls;
|
|
|
|
|
|
|
|
TRACE("(%p,%p)\n", image, item);
|
|
|
|
|
2007-08-01 04:15:33 +02:00
|
|
|
if(!image || !item)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-12-18 23:12:51 +01:00
|
|
|
if (!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
2007-08-01 04:15:33 +02:00
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2007-07-31 04:09:37 +02:00
|
|
|
GpStatus WINGDIPAPI GdipGetImageBounds(GpImage *image, GpRectF *srcRect,
|
|
|
|
GpUnit *srcUnit)
|
|
|
|
{
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("%p %p %p\n", image, srcRect, srcUnit);
|
|
|
|
|
2007-07-31 04:09:37 +02:00
|
|
|
if(!image || !srcRect || !srcUnit)
|
|
|
|
return InvalidParameter;
|
2007-07-31 04:09:57 +02:00
|
|
|
if(image->type == ImageTypeMetafile){
|
2008-02-29 23:06:47 +01:00
|
|
|
*srcRect = ((GpMetafile*)image)->bounds;
|
2007-07-31 04:09:57 +02:00
|
|
|
*srcUnit = ((GpMetafile*)image)->unit;
|
|
|
|
}
|
2007-08-01 04:16:20 +02:00
|
|
|
else if(image->type == ImageTypeBitmap){
|
|
|
|
srcRect->X = srcRect->Y = 0.0;
|
|
|
|
srcRect->Width = (REAL) ((GpBitmap*)image)->width;
|
|
|
|
srcRect->Height = (REAL) ((GpBitmap*)image)->height;
|
|
|
|
*srcUnit = UnitPixel;
|
|
|
|
}
|
2007-07-31 04:09:57 +02:00
|
|
|
else{
|
2007-08-01 04:16:20 +02:00
|
|
|
srcRect->X = srcRect->Y = 0.0;
|
|
|
|
srcRect->Width = ipicture_pixel_width(image->picture);
|
|
|
|
srcRect->Height = ipicture_pixel_height(image->picture);
|
|
|
|
*srcUnit = UnitPixel;
|
2007-07-31 04:09:57 +02:00
|
|
|
}
|
2007-07-31 04:09:37 +02:00
|
|
|
|
2007-08-01 04:16:20 +02:00
|
|
|
TRACE("returning (%f, %f) (%f, %f) unit type %d\n", srcRect->X, srcRect->Y,
|
|
|
|
srcRect->Width, srcRect->Height, *srcUnit);
|
|
|
|
|
2007-07-31 04:09:57 +02:00
|
|
|
return Ok;
|
2007-07-31 04:09:37 +02:00
|
|
|
}
|
|
|
|
|
2008-02-27 10:36:44 +01:00
|
|
|
GpStatus WINGDIPAPI GdipGetImageDimension(GpImage *image, REAL *width,
|
|
|
|
REAL *height)
|
|
|
|
{
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("%p %p %p\n", image, width, height);
|
|
|
|
|
2008-02-27 10:36:44 +01:00
|
|
|
if(!image || !height || !width)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(image->type == ImageTypeMetafile){
|
|
|
|
HDC hdc = GetDC(0);
|
|
|
|
|
|
|
|
*height = convert_unit(hdc, ((GpMetafile*)image)->unit) *
|
|
|
|
((GpMetafile*)image)->bounds.Height;
|
|
|
|
|
|
|
|
*width = convert_unit(hdc, ((GpMetafile*)image)->unit) *
|
|
|
|
((GpMetafile*)image)->bounds.Width;
|
|
|
|
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(image->type == ImageTypeBitmap){
|
|
|
|
*height = ((GpBitmap*)image)->height;
|
|
|
|
*width = ((GpBitmap*)image)->width;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
*height = ipicture_pixel_height(image->picture);
|
|
|
|
*width = ipicture_pixel_width(image->picture);
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("returning (%f, %f)\n", *height, *width);
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-08-10 03:25:01 +02:00
|
|
|
GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image,
|
|
|
|
GpGraphics **graphics)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("%p %p\n", image, graphics);
|
|
|
|
|
2007-08-10 03:25:01 +02:00
|
|
|
if(!image || !graphics)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(image->type != ImageTypeBitmap){
|
|
|
|
FIXME("not implemented for image type %d\n", image->type);
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2009-08-28 22:05:38 +02:00
|
|
|
hdc = ((GpBitmap*)image)->hdc;
|
2007-08-10 03:25:01 +02:00
|
|
|
|
|
|
|
if(!hdc){
|
|
|
|
hdc = CreateCompatibleDC(0);
|
2009-08-28 22:05:38 +02:00
|
|
|
SelectObject(hdc, ((GpBitmap*)image)->hbitmap);
|
|
|
|
((GpBitmap*)image)->hdc = hdc;
|
2007-08-10 03:25:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return GdipCreateFromHDC(hdc, graphics);
|
|
|
|
}
|
|
|
|
|
2007-07-25 02:19:02 +02:00
|
|
|
GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height)
|
|
|
|
{
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("%p %p\n", image, height);
|
|
|
|
|
2007-07-25 02:19:02 +02:00
|
|
|
if(!image || !height)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2007-08-01 04:16:20 +02:00
|
|
|
if(image->type == ImageTypeMetafile){
|
2007-08-08 03:42:09 +02:00
|
|
|
HDC hdc = GetDC(0);
|
|
|
|
|
|
|
|
*height = roundr(convert_unit(hdc, ((GpMetafile*)image)->unit) *
|
|
|
|
((GpMetafile*)image)->bounds.Height);
|
|
|
|
|
|
|
|
ReleaseDC(0, hdc);
|
2007-08-01 04:16:20 +02:00
|
|
|
}
|
|
|
|
else if(image->type == ImageTypeBitmap)
|
|
|
|
*height = ((GpBitmap*)image)->height;
|
|
|
|
else
|
|
|
|
*height = ipicture_pixel_height(image->picture);
|
2007-07-25 02:19:02 +02:00
|
|
|
|
2007-08-01 04:16:20 +02:00
|
|
|
TRACE("returning %d\n", *height);
|
|
|
|
|
|
|
|
return Ok;
|
2007-07-25 02:19:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipGetImageHorizontalResolution(GpImage *image, REAL *res)
|
|
|
|
{
|
|
|
|
if(!image || !res)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-12-27 02:46:55 +01:00
|
|
|
*res = image->xres;
|
2007-07-25 02:19:02 +02:00
|
|
|
|
2009-12-27 02:46:55 +01:00
|
|
|
TRACE("(%p) <-- %0.2f\n", image, *res);
|
|
|
|
|
|
|
|
return Ok;
|
2007-07-25 02:19:02 +02:00
|
|
|
}
|
|
|
|
|
2008-12-01 22:17:10 +01:00
|
|
|
GpStatus WINGDIPAPI GdipGetImagePaletteSize(GpImage *image, INT *size)
|
|
|
|
{
|
2009-12-11 23:56:08 +01:00
|
|
|
TRACE("%p %p\n", image, size);
|
2008-12-01 22:17:10 +01:00
|
|
|
|
|
|
|
if(!image || !size)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-12-11 23:56:08 +01:00
|
|
|
if (image->palette_count == 0)
|
|
|
|
*size = sizeof(ColorPalette);
|
|
|
|
else
|
|
|
|
*size = sizeof(UINT)*2 + sizeof(ARGB)*image->palette_count;
|
|
|
|
|
|
|
|
TRACE("<-- %u\n", *size);
|
|
|
|
|
|
|
|
return Ok;
|
2008-12-01 22:17:10 +01:00
|
|
|
}
|
|
|
|
|
2007-08-04 02:30:30 +02:00
|
|
|
/* FIXME: test this function for non-bitmap types */
|
|
|
|
GpStatus WINGDIPAPI GdipGetImagePixelFormat(GpImage *image, PixelFormat *format)
|
|
|
|
{
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("%p %p\n", image, format);
|
|
|
|
|
2007-08-04 02:30:30 +02:00
|
|
|
if(!image || !format)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(image->type != ImageTypeBitmap)
|
|
|
|
*format = PixelFormat24bppRGB;
|
|
|
|
else
|
|
|
|
*format = ((GpBitmap*) image)->format;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-07-25 02:19:02 +02:00
|
|
|
GpStatus WINGDIPAPI GdipGetImageRawFormat(GpImage *image, GUID *format)
|
|
|
|
{
|
|
|
|
if(!image || !format)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-09-14 18:23:45 +02:00
|
|
|
memcpy(format, &image->format, sizeof(GUID));
|
2007-07-25 02:19:02 +02:00
|
|
|
|
2008-11-24 10:23:16 +01:00
|
|
|
return Ok;
|
2007-07-25 02:19:02 +02:00
|
|
|
}
|
|
|
|
|
2007-07-25 02:19:12 +02:00
|
|
|
GpStatus WINGDIPAPI GdipGetImageType(GpImage *image, ImageType *type)
|
|
|
|
{
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("%p %p\n", image, type);
|
|
|
|
|
2007-07-25 02:19:12 +02:00
|
|
|
if(!image || !type)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2007-08-01 04:15:08 +02:00
|
|
|
*type = image->type;
|
2007-07-25 02:19:12 +02:00
|
|
|
|
2007-07-31 04:09:49 +02:00
|
|
|
return Ok;
|
2007-07-25 02:19:12 +02:00
|
|
|
}
|
|
|
|
|
2007-07-25 02:19:02 +02:00
|
|
|
GpStatus WINGDIPAPI GdipGetImageVerticalResolution(GpImage *image, REAL *res)
|
|
|
|
{
|
|
|
|
if(!image || !res)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-12-27 02:46:55 +01:00
|
|
|
*res = image->yres;
|
2007-07-25 02:19:02 +02:00
|
|
|
|
2009-12-27 02:46:55 +01:00
|
|
|
TRACE("(%p) <-- %0.2f\n", image, *res);
|
|
|
|
|
|
|
|
return Ok;
|
2007-07-25 02:19:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width)
|
|
|
|
{
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("%p %p\n", image, width);
|
|
|
|
|
2007-07-25 02:19:02 +02:00
|
|
|
if(!image || !width)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2007-08-01 04:16:20 +02:00
|
|
|
if(image->type == ImageTypeMetafile){
|
2007-08-08 03:42:09 +02:00
|
|
|
HDC hdc = GetDC(0);
|
|
|
|
|
|
|
|
*width = roundr(convert_unit(hdc, ((GpMetafile*)image)->unit) *
|
|
|
|
((GpMetafile*)image)->bounds.Width);
|
|
|
|
|
|
|
|
ReleaseDC(0, hdc);
|
2007-08-01 04:16:20 +02:00
|
|
|
}
|
|
|
|
else if(image->type == ImageTypeBitmap)
|
|
|
|
*width = ((GpBitmap*)image)->width;
|
|
|
|
else
|
|
|
|
*width = ipicture_pixel_width(image->picture);
|
2007-07-25 02:19:02 +02:00
|
|
|
|
2007-08-01 04:16:20 +02:00
|
|
|
TRACE("returning %d\n", *width);
|
|
|
|
|
|
|
|
return Ok;
|
2007-07-25 02:19:02 +02:00
|
|
|
}
|
|
|
|
|
2007-08-01 04:15:29 +02:00
|
|
|
GpStatus WINGDIPAPI GdipGetMetafileHeaderFromMetafile(GpMetafile * metafile,
|
|
|
|
MetafileHeader * header)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
|
|
|
if(!metafile || !header)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
2007-08-08 03:42:24 +02:00
|
|
|
return Ok;
|
2007-08-01 04:15:29 +02:00
|
|
|
}
|
|
|
|
|
2008-09-07 23:25:04 +02:00
|
|
|
GpStatus WINGDIPAPI GdipGetAllPropertyItems(GpImage *image, UINT size,
|
|
|
|
UINT num, PropertyItem* items)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return InvalidParameter;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipGetPropertyCount(GpImage *image, UINT* num)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return InvalidParameter;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipGetPropertyIdList(GpImage *image, UINT num, PROPID* list)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return InvalidParameter;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipGetPropertyItem(GpImage *image, PROPID id, UINT size,
|
|
|
|
PropertyItem* buffer)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return InvalidParameter;
|
|
|
|
}
|
|
|
|
|
2007-08-01 04:15:56 +02:00
|
|
|
GpStatus WINGDIPAPI GdipGetPropertyItemSize(GpImage *image, PROPID pid,
|
|
|
|
UINT* size)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
|
|
|
TRACE("%p %x %p\n", image, pid, size);
|
|
|
|
|
|
|
|
if(!size || !image)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2008-09-07 23:25:04 +02:00
|
|
|
GpStatus WINGDIPAPI GdipGetPropertySize(GpImage *image, UINT* size, UINT* num)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
2009-12-18 23:12:51 +01:00
|
|
|
TRACE("(%p,%p,%p)\n", image, size, num);
|
|
|
|
|
2008-09-07 23:25:04 +02:00
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return InvalidParameter;
|
|
|
|
}
|
|
|
|
|
2009-12-24 22:04:32 +01:00
|
|
|
struct image_format_dimension
|
|
|
|
{
|
|
|
|
const GUID *format;
|
|
|
|
const GUID *dimension;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct image_format_dimension image_format_dimensions[] =
|
|
|
|
{
|
|
|
|
{&ImageFormatGIF, &FrameDimensionTime},
|
|
|
|
{&ImageFormatIcon, &FrameDimensionResolution},
|
|
|
|
{NULL}
|
|
|
|
};
|
|
|
|
|
2007-07-25 02:19:02 +02:00
|
|
|
GpStatus WINGDIPAPI GdipImageGetFrameCount(GpImage *image,
|
|
|
|
GDIPCONST GUID* dimensionID, UINT* count)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
2009-12-18 23:12:51 +01:00
|
|
|
TRACE("(%p,%s,%p)\n", image, debugstr_guid(dimensionID), count);
|
|
|
|
|
2007-07-25 02:19:02 +02:00
|
|
|
if(!image || !dimensionID || !count)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
2007-07-25 02:19:21 +02:00
|
|
|
|
2008-06-19 10:38:09 +02:00
|
|
|
GpStatus WINGDIPAPI GdipImageGetFrameDimensionsCount(GpImage *image,
|
|
|
|
UINT* count)
|
|
|
|
{
|
2009-12-24 21:52:02 +01:00
|
|
|
/* Native gdiplus 1.1 does not yet support multiple frame dimensions. */
|
|
|
|
|
2008-06-19 10:38:09 +02:00
|
|
|
if(!image || !count)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
*count = 1;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-08-04 02:30:26 +02:00
|
|
|
GpStatus WINGDIPAPI GdipImageGetFrameDimensionsList(GpImage* image,
|
|
|
|
GUID* dimensionIDs, UINT count)
|
|
|
|
{
|
2009-12-24 22:04:32 +01:00
|
|
|
int i;
|
|
|
|
const GUID *result=NULL;
|
2007-08-04 02:30:26 +02:00
|
|
|
|
2009-12-24 22:04:32 +01:00
|
|
|
TRACE("(%p,%p,%u)\n", image, dimensionIDs, count);
|
|
|
|
|
|
|
|
if(!image || !dimensionIDs || count != 1)
|
2007-08-04 02:30:26 +02:00
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-12-24 22:04:32 +01:00
|
|
|
for (i=0; image_format_dimensions[i].format; i++)
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(&image->format, image_format_dimensions[i].format))
|
|
|
|
{
|
|
|
|
result = image_format_dimensions[i].dimension;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
result = &FrameDimensionPage;
|
|
|
|
|
|
|
|
memcpy(dimensionIDs, result, sizeof(GUID));
|
2007-08-04 02:30:26 +02:00
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-08-04 02:30:34 +02:00
|
|
|
GpStatus WINGDIPAPI GdipImageSelectActiveFrame(GpImage *image,
|
|
|
|
GDIPCONST GUID* dimensionID, UINT frameidx)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
|
|
|
if(!image || !dimensionID)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2008-02-24 16:41:29 +01:00
|
|
|
GpStatus WINGDIPAPI GdipLoadImageFromFile(GDIPCONST WCHAR* filename,
|
|
|
|
GpImage **image)
|
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
IStream *stream;
|
|
|
|
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("(%s) %p\n", debugstr_w(filename), image);
|
|
|
|
|
2008-02-24 16:41:29 +01:00
|
|
|
if (!filename || !image)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
stat = GdipCreateStreamOnFile(filename, GENERIC_READ, &stream);
|
|
|
|
|
|
|
|
if (stat != Ok)
|
|
|
|
return stat;
|
|
|
|
|
|
|
|
stat = GdipLoadImageFromStream(stream, image);
|
|
|
|
|
|
|
|
IStream_Release(stream);
|
|
|
|
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
2008-05-09 14:40:21 +02:00
|
|
|
/* FIXME: no icm handling */
|
|
|
|
GpStatus WINGDIPAPI GdipLoadImageFromFileICM(GDIPCONST WCHAR* filename,GpImage **image)
|
|
|
|
{
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("(%s) %p\n", debugstr_w(filename), image);
|
|
|
|
|
2008-05-09 14:40:21 +02:00
|
|
|
return GdipLoadImageFromFile(filename, image);
|
|
|
|
}
|
|
|
|
|
2009-08-31 23:56:47 +02:00
|
|
|
static const WICPixelFormatGUID *wic_pixel_formats[] = {
|
|
|
|
&GUID_WICPixelFormat16bppBGR555,
|
|
|
|
&GUID_WICPixelFormat24bppBGR,
|
|
|
|
&GUID_WICPixelFormat32bppBGR,
|
|
|
|
&GUID_WICPixelFormat32bppBGRA,
|
|
|
|
&GUID_WICPixelFormat32bppPBGRA,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const PixelFormat wic_gdip_formats[] = {
|
|
|
|
PixelFormat16bppRGB555,
|
|
|
|
PixelFormat24bppRGB,
|
|
|
|
PixelFormat32bppRGB,
|
|
|
|
PixelFormat32bppARGB,
|
|
|
|
PixelFormat32bppPARGB,
|
|
|
|
};
|
|
|
|
|
|
|
|
static GpStatus decode_image_wic(IStream* stream, REFCLSID clsid, GpImage **image)
|
2007-07-25 02:19:21 +02:00
|
|
|
{
|
2009-08-31 23:56:47 +02:00
|
|
|
GpStatus status=Ok;
|
|
|
|
GpBitmap *bitmap;
|
|
|
|
HRESULT hr;
|
|
|
|
IWICBitmapDecoder *decoder;
|
|
|
|
IWICBitmapFrameDecode *frame;
|
|
|
|
IWICBitmapSource *source=NULL;
|
|
|
|
WICPixelFormatGUID wic_format;
|
|
|
|
PixelFormat gdip_format=0;
|
|
|
|
int i;
|
|
|
|
UINT width, height;
|
|
|
|
BitmapData lockeddata;
|
|
|
|
WICRect wrc;
|
|
|
|
HRESULT initresult;
|
2007-08-08 03:42:20 +02:00
|
|
|
|
2009-08-31 23:56:47 +02:00
|
|
|
initresult = CoInitialize(NULL);
|
2008-09-10 22:20:42 +02:00
|
|
|
|
2009-08-31 23:56:47 +02:00
|
|
|
hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IWICBitmapDecoder, (void**)&decoder);
|
|
|
|
if (FAILED(hr)) goto end;
|
2007-07-25 02:19:21 +02:00
|
|
|
|
2009-08-31 23:56:47 +02:00
|
|
|
hr = IWICBitmapDecoder_Initialize(decoder, (IStream*)stream, WICDecodeMetadataCacheOnLoad);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr)) /* got frame */
|
|
|
|
{
|
|
|
|
hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &wic_format);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
for (i=0; wic_pixel_formats[i]; i++)
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(&wic_format, wic_pixel_formats[i]))
|
|
|
|
{
|
|
|
|
source = (IWICBitmapSource*)frame;
|
|
|
|
IWICBitmapSource_AddRef(source);
|
|
|
|
gdip_format = wic_gdip_formats[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!source)
|
|
|
|
{
|
|
|
|
/* unknown format; fall back on 32bppARGB */
|
|
|
|
hr = WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGRA, (IWICBitmapSource*)frame, &source);
|
|
|
|
gdip_format = PixelFormat32bppARGB;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr)) /* got source */
|
|
|
|
{
|
|
|
|
hr = IWICBitmapSource_GetSize(source, &width, &height);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
status = GdipCreateBitmapFromScan0(width, height, 0, gdip_format,
|
|
|
|
NULL, &bitmap);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr) && status == Ok) /* created bitmap */
|
|
|
|
{
|
|
|
|
status = GdipBitmapLockBits(bitmap, NULL, ImageLockModeWrite,
|
|
|
|
gdip_format, &lockeddata);
|
|
|
|
if (status == Ok) /* locked bitmap */
|
|
|
|
{
|
|
|
|
wrc.X = 0;
|
|
|
|
wrc.Width = width;
|
|
|
|
wrc.Height = 1;
|
|
|
|
for (i=0; i<height; i++)
|
|
|
|
{
|
|
|
|
wrc.Y = i;
|
|
|
|
hr = IWICBitmapSource_CopyPixels(source, &wrc, abs(lockeddata.Stride),
|
|
|
|
abs(lockeddata.Stride), (BYTE*)lockeddata.Scan0+lockeddata.Stride*i);
|
|
|
|
if (FAILED(hr)) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdipBitmapUnlockBits(bitmap, &lockeddata);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr) && status == Ok)
|
|
|
|
*image = (GpImage*)bitmap;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*image = NULL;
|
|
|
|
GdipDisposeImage((GpImage*)bitmap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IWICBitmapSource_Release(source);
|
|
|
|
}
|
|
|
|
|
|
|
|
IWICBitmapFrameDecode_Release(frame);
|
2007-08-01 04:15:48 +02:00
|
|
|
}
|
|
|
|
|
2009-08-31 23:56:47 +02:00
|
|
|
IWICBitmapDecoder_Release(decoder);
|
2007-08-08 03:42:20 +02:00
|
|
|
|
2009-08-31 23:56:47 +02:00
|
|
|
end:
|
|
|
|
if (SUCCEEDED(initresult)) CoUninitialize();
|
|
|
|
|
|
|
|
if (FAILED(hr) && status == Ok) status = hresult_to_status(hr);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GpStatus decode_image_icon(IStream* stream, REFCLSID clsid, GpImage **image)
|
|
|
|
{
|
|
|
|
return decode_image_wic(stream, &CLSID_WICIcoDecoder, image);
|
2009-08-26 00:43:33 +02:00
|
|
|
}
|
2007-08-08 03:42:20 +02:00
|
|
|
|
2009-09-04 16:54:55 +02:00
|
|
|
static GpStatus decode_image_bmp(IStream* stream, REFCLSID clsid, GpImage **image)
|
|
|
|
{
|
2009-09-04 17:23:30 +02:00
|
|
|
GpStatus status;
|
|
|
|
GpBitmap* bitmap;
|
|
|
|
|
|
|
|
status = decode_image_wic(stream, &CLSID_WICBmpDecoder, image);
|
|
|
|
|
|
|
|
bitmap = (GpBitmap*)*image;
|
|
|
|
|
|
|
|
if (status == Ok && bitmap->format == PixelFormat32bppARGB)
|
|
|
|
{
|
|
|
|
/* WIC supports bmp files with alpha, but gdiplus does not */
|
|
|
|
bitmap->format = PixelFormat32bppRGB;
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
2009-09-04 16:54:55 +02:00
|
|
|
}
|
|
|
|
|
2009-09-02 00:54:45 +02:00
|
|
|
static GpStatus decode_image_jpeg(IStream* stream, REFCLSID clsid, GpImage **image)
|
|
|
|
{
|
|
|
|
return decode_image_wic(stream, &CLSID_WICJpegDecoder, image);
|
|
|
|
}
|
|
|
|
|
2009-09-04 16:59:46 +02:00
|
|
|
static GpStatus decode_image_png(IStream* stream, REFCLSID clsid, GpImage **image)
|
2009-09-02 00:56:42 +02:00
|
|
|
{
|
2009-09-04 16:59:46 +02:00
|
|
|
return decode_image_wic(stream, &CLSID_WICPngDecoder, image);
|
2009-09-02 00:56:42 +02:00
|
|
|
}
|
|
|
|
|
2009-09-04 16:59:46 +02:00
|
|
|
static GpStatus decode_image_gif(IStream* stream, REFCLSID clsid, GpImage **image)
|
2009-08-26 00:43:33 +02:00
|
|
|
{
|
2009-09-04 16:59:46 +02:00
|
|
|
return decode_image_wic(stream, &CLSID_WICGifDecoder, image);
|
2009-08-26 00:43:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static GpStatus decode_image_olepicture_metafile(IStream* stream, REFCLSID clsid, GpImage **image)
|
|
|
|
{
|
|
|
|
IPicture *pic;
|
|
|
|
|
|
|
|
TRACE("%p %p\n", stream, image);
|
|
|
|
|
|
|
|
if(!stream || !image)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(OleLoadPicture(stream, 0, FALSE, &IID_IPicture,
|
|
|
|
(LPVOID*) &pic) != S_OK){
|
|
|
|
TRACE("Could not load picture\n");
|
|
|
|
return GenericError;
|
2007-08-08 03:42:20 +02:00
|
|
|
}
|
|
|
|
|
2009-08-26 00:43:33 +02:00
|
|
|
/* FIXME: missing initialization code */
|
|
|
|
*image = GdipAlloc(sizeof(GpMetafile));
|
|
|
|
if(!*image) return OutOfMemory;
|
|
|
|
(*image)->type = ImageTypeMetafile;
|
2007-08-08 03:42:20 +02:00
|
|
|
(*image)->picture = pic;
|
2008-05-09 14:39:43 +02:00
|
|
|
(*image)->flags = ImageFlagsNone;
|
2009-12-11 23:51:46 +01:00
|
|
|
(*image)->palette_flags = 0;
|
|
|
|
(*image)->palette_count = 0;
|
|
|
|
(*image)->palette_size = 0;
|
|
|
|
(*image)->palette_entries = NULL;
|
2007-08-01 04:15:48 +02:00
|
|
|
|
2009-12-18 22:09:45 +01:00
|
|
|
TRACE("<-- %p\n", *image);
|
|
|
|
|
2007-08-01 04:15:48 +02:00
|
|
|
return Ok;
|
2007-07-25 02:19:21 +02:00
|
|
|
}
|
2007-08-01 04:16:00 +02:00
|
|
|
|
2009-08-24 22:15:31 +02:00
|
|
|
typedef GpStatus (*encode_image_func)(GpImage *image, IStream* stream,
|
|
|
|
GDIPCONST CLSID* clsid, GDIPCONST EncoderParameters* params);
|
2009-08-26 00:43:33 +02:00
|
|
|
|
|
|
|
typedef GpStatus (*decode_image_func)(IStream *stream, REFCLSID clsid, GpImage** image);
|
|
|
|
|
|
|
|
typedef struct image_codec {
|
|
|
|
ImageCodecInfo info;
|
|
|
|
encode_image_func encode_func;
|
|
|
|
decode_image_func decode_func;
|
|
|
|
} image_codec;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
BMP,
|
|
|
|
JPEG,
|
|
|
|
GIF,
|
|
|
|
EMF,
|
|
|
|
WMF,
|
|
|
|
PNG,
|
|
|
|
ICO,
|
|
|
|
NUM_CODECS
|
|
|
|
} ImageFormat;
|
|
|
|
|
|
|
|
static const struct image_codec codecs[NUM_CODECS];
|
|
|
|
|
|
|
|
static GpStatus get_decoder_info(IStream* stream, const struct image_codec **result)
|
|
|
|
{
|
|
|
|
BYTE signature[8];
|
|
|
|
LARGE_INTEGER seek;
|
|
|
|
HRESULT hr;
|
|
|
|
UINT bytesread;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
/* seek to the start of the stream */
|
|
|
|
seek.QuadPart = 0;
|
|
|
|
hr = IStream_Seek(stream, seek, STREAM_SEEK_SET, NULL);
|
|
|
|
if (FAILED(hr)) return hresult_to_status(hr);
|
|
|
|
|
|
|
|
/* read the first 8 bytes */
|
|
|
|
/* FIXME: This assumes all codecs have one signature <= 8 bytes in length */
|
|
|
|
hr = IStream_Read(stream, signature, 8, &bytesread);
|
|
|
|
if (FAILED(hr)) return hresult_to_status(hr);
|
|
|
|
if (hr == S_FALSE || bytesread == 0) return GenericError;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_CODECS; i++) {
|
|
|
|
if ((codecs[i].info.Flags & ImageCodecFlagsDecoder) &&
|
|
|
|
bytesread >= codecs[i].info.SigSize)
|
|
|
|
{
|
|
|
|
for (j=0; j<codecs[i].info.SigSize; j++)
|
|
|
|
if ((signature[j] & codecs[i].info.SigMask[j]) != codecs[i].info.SigPattern[j])
|
|
|
|
break;
|
|
|
|
if (j == codecs[i].info.SigSize)
|
|
|
|
{
|
|
|
|
*result = &codecs[i];
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("no match for %i byte signature %x %x %x %x %x %x %x %x\n", bytesread,
|
|
|
|
signature[0],signature[1],signature[2],signature[3],
|
|
|
|
signature[4],signature[5],signature[6],signature[7]);
|
|
|
|
|
|
|
|
return GenericError;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream* stream, GpImage **image)
|
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
LARGE_INTEGER seek;
|
|
|
|
HRESULT hr;
|
|
|
|
const struct image_codec *codec=NULL;
|
|
|
|
|
|
|
|
/* choose an appropriate image decoder */
|
|
|
|
stat = get_decoder_info(stream, &codec);
|
|
|
|
if (stat != Ok) return stat;
|
|
|
|
|
|
|
|
/* seek to the start of the stream */
|
|
|
|
seek.QuadPart = 0;
|
|
|
|
hr = IStream_Seek(stream, seek, STREAM_SEEK_SET, NULL);
|
|
|
|
if (FAILED(hr)) return hresult_to_status(hr);
|
|
|
|
|
|
|
|
/* call on the image decoder to do the real work */
|
2009-09-14 18:23:45 +02:00
|
|
|
stat = codec->decode_func(stream, &codec->info.Clsid, image);
|
|
|
|
|
|
|
|
/* take note of the original data format */
|
|
|
|
if (stat == Ok)
|
|
|
|
{
|
|
|
|
memcpy(&(*image)->format, &codec->info.FormatID, sizeof(GUID));
|
|
|
|
}
|
|
|
|
|
|
|
|
return stat;
|
2009-08-26 00:43:33 +02:00
|
|
|
}
|
|
|
|
|
2007-08-04 02:30:22 +02:00
|
|
|
/* FIXME: no ICM */
|
|
|
|
GpStatus WINGDIPAPI GdipLoadImageFromStreamICM(IStream* stream, GpImage **image)
|
|
|
|
{
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("%p %p\n", stream, image);
|
|
|
|
|
2007-08-04 02:30:22 +02:00
|
|
|
return GdipLoadImageFromStream(stream, image);
|
|
|
|
}
|
|
|
|
|
2007-08-01 04:16:08 +02:00
|
|
|
GpStatus WINGDIPAPI GdipRemovePropertyItem(GpImage *image, PROPID propId)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
2009-12-18 23:12:51 +01:00
|
|
|
TRACE("(%p,%u)\n", image, propId);
|
|
|
|
|
2007-08-01 04:16:08 +02:00
|
|
|
if(!image)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2008-09-07 23:25:04 +02:00
|
|
|
GpStatus WINGDIPAPI GdipSetPropertyItem(GpImage *image, GDIPCONST PropertyItem* item)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
2009-12-18 23:12:51 +01:00
|
|
|
TRACE("(%p,%p)\n", image, item);
|
|
|
|
|
2008-09-07 23:25:04 +02:00
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2008-03-10 16:16:54 +01:00
|
|
|
GpStatus WINGDIPAPI GdipSaveImageToFile(GpImage *image, GDIPCONST WCHAR* filename,
|
|
|
|
GDIPCONST CLSID *clsidEncoder,
|
|
|
|
GDIPCONST EncoderParameters *encoderParams)
|
|
|
|
{
|
|
|
|
GpStatus stat;
|
|
|
|
IStream *stream;
|
|
|
|
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("%p (%s) %p %p\n", image, debugstr_w(filename), clsidEncoder, encoderParams);
|
|
|
|
|
2008-03-10 16:16:54 +01:00
|
|
|
if (!image || !filename|| !clsidEncoder)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
stat = GdipCreateStreamOnFile(filename, GENERIC_WRITE, &stream);
|
|
|
|
if (stat != Ok)
|
|
|
|
return GenericError;
|
|
|
|
|
|
|
|
stat = GdipSaveImageToStream(image, stream, clsidEncoder, encoderParams);
|
|
|
|
|
|
|
|
IStream_Release(stream);
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
2008-03-10 16:16:55 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* Encoding functions -
|
|
|
|
* These functions encode an image in different image file formats.
|
|
|
|
*/
|
2008-03-10 16:16:56 +01:00
|
|
|
#define BITMAP_FORMAT_BMP 0x4d42 /* "BM" */
|
|
|
|
#define BITMAP_FORMAT_JPEG 0xd8ff
|
|
|
|
#define BITMAP_FORMAT_GIF 0x4947
|
|
|
|
#define BITMAP_FORMAT_PNG 0x5089
|
|
|
|
#define BITMAP_FORMAT_APM 0xcdd7
|
|
|
|
|
2009-08-24 22:15:31 +02:00
|
|
|
static GpStatus encode_image_WIC(GpImage *image, IStream* stream,
|
|
|
|
GDIPCONST CLSID* clsid, GDIPCONST EncoderParameters* params)
|
2008-03-10 16:16:55 +01:00
|
|
|
{
|
2009-08-24 22:15:31 +02:00
|
|
|
GpStatus stat;
|
|
|
|
GpBitmap *bitmap;
|
|
|
|
IWICBitmapEncoder *encoder;
|
|
|
|
IWICBitmapFrameEncode *frameencode;
|
|
|
|
IPropertyBag2 *encoderoptions;
|
|
|
|
HRESULT hr;
|
|
|
|
UINT width, height;
|
|
|
|
PixelFormat gdipformat=0;
|
|
|
|
WICPixelFormatGUID wicformat;
|
|
|
|
GpRect rc;
|
|
|
|
BitmapData lockeddata;
|
|
|
|
HRESULT initresult;
|
|
|
|
UINT i;
|
2008-03-10 16:16:56 +01:00
|
|
|
|
2009-08-24 22:15:31 +02:00
|
|
|
if (image->type != ImageTypeBitmap)
|
|
|
|
return GenericError;
|
|
|
|
|
|
|
|
bitmap = (GpBitmap*)image;
|
|
|
|
|
|
|
|
GdipGetImageWidth(image, &width);
|
|
|
|
GdipGetImageHeight(image, &height);
|
|
|
|
|
|
|
|
rc.X = 0;
|
|
|
|
rc.Y = 0;
|
|
|
|
rc.Width = width;
|
|
|
|
rc.Height = height;
|
|
|
|
|
|
|
|
initresult = CoInitialize(NULL);
|
|
|
|
|
|
|
|
hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IWICBitmapEncoder, (void**)&encoder);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (SUCCEEDED(initresult)) CoUninitialize();
|
|
|
|
return hresult_to_status(hr);
|
2008-03-10 16:16:56 +01:00
|
|
|
}
|
|
|
|
|
2009-08-24 22:15:31 +02:00
|
|
|
hr = IWICBitmapEncoder_Initialize(encoder, stream, WICBitmapEncoderNoCache);
|
2008-03-10 16:16:56 +01:00
|
|
|
|
2009-08-24 22:15:31 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IWICBitmapEncoder_CreateNewFrame(encoder, &frameencode, &encoderoptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr)) /* created frame */
|
|
|
|
{
|
|
|
|
hr = IWICBitmapFrameEncode_Initialize(frameencode, encoderoptions);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = IWICBitmapFrameEncode_SetSize(frameencode, width, height);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
/* FIXME: use the resolution from the image */
|
|
|
|
hr = IWICBitmapFrameEncode_SetResolution(frameencode, 96.0, 96.0);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
for (i=0; wic_pixel_formats[i]; i++)
|
|
|
|
{
|
|
|
|
if (wic_gdip_formats[i] == bitmap->format)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (wic_pixel_formats[i])
|
|
|
|
memcpy(&wicformat, wic_pixel_formats[i], sizeof(GUID));
|
|
|
|
else
|
|
|
|
memcpy(&wicformat, &GUID_WICPixelFormat32bppBGRA, sizeof(GUID));
|
|
|
|
|
|
|
|
hr = IWICBitmapFrameEncode_SetPixelFormat(frameencode, &wicformat);
|
|
|
|
|
|
|
|
for (i=0; wic_pixel_formats[i]; i++)
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(&wicformat, wic_pixel_formats[i]))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (wic_pixel_formats[i])
|
|
|
|
gdipformat = wic_gdip_formats[i];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("cannot provide pixel format %s\n", debugstr_guid(&wicformat));
|
|
|
|
hr = E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
stat = GdipBitmapLockBits(bitmap, &rc, ImageLockModeRead, gdipformat,
|
|
|
|
&lockeddata);
|
|
|
|
|
|
|
|
if (stat == Ok)
|
|
|
|
{
|
|
|
|
UINT row_size = (lockeddata.Width * PIXELFORMATBPP(gdipformat) + 7)/8;
|
|
|
|
BYTE *row;
|
|
|
|
|
|
|
|
/* write one row at a time in case stride is negative */
|
|
|
|
row = lockeddata.Scan0;
|
|
|
|
for (i=0; i<lockeddata.Height; i++)
|
|
|
|
{
|
|
|
|
hr = IWICBitmapFrameEncode_WritePixels(frameencode, 1, row_size, row_size, row);
|
|
|
|
if (FAILED(hr)) break;
|
|
|
|
row += lockeddata.Stride;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdipBitmapUnlockBits(bitmap, &lockeddata);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = IWICBitmapFrameEncode_Commit(frameencode);
|
|
|
|
|
|
|
|
IWICBitmapFrameEncode_Release(frameencode);
|
|
|
|
IPropertyBag2_Release(encoderoptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = IWICBitmapEncoder_Commit(encoder);
|
|
|
|
|
|
|
|
IWICBitmapEncoder_Release(encoder);
|
|
|
|
|
|
|
|
if (SUCCEEDED(initresult)) CoUninitialize();
|
|
|
|
|
|
|
|
return hresult_to_status(hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GpStatus encode_image_BMP(GpImage *image, IStream* stream,
|
|
|
|
GDIPCONST CLSID* clsid, GDIPCONST EncoderParameters* params)
|
|
|
|
{
|
|
|
|
return encode_image_WIC(image, stream, &CLSID_WICBmpEncoder, params);
|
2008-03-10 16:16:55 +01:00
|
|
|
}
|
|
|
|
|
2009-09-24 00:33:53 +02:00
|
|
|
static GpStatus encode_image_png(GpImage *image, IStream* stream,
|
|
|
|
GDIPCONST CLSID* clsid, GDIPCONST EncoderParameters* params)
|
|
|
|
{
|
|
|
|
return encode_image_WIC(image, stream, &CLSID_WICPngEncoder, params);
|
|
|
|
}
|
|
|
|
|
2008-07-26 19:20:33 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* GdipSaveImageToStream [GDIPLUS.@]
|
|
|
|
*/
|
2007-08-01 04:16:00 +02:00
|
|
|
GpStatus WINGDIPAPI GdipSaveImageToStream(GpImage *image, IStream* stream,
|
|
|
|
GDIPCONST CLSID* clsid, GDIPCONST EncoderParameters* params)
|
|
|
|
{
|
2008-03-10 16:16:55 +01:00
|
|
|
GpStatus stat;
|
2009-08-21 00:21:41 +02:00
|
|
|
encode_image_func encode_image;
|
2008-03-10 16:16:55 +01:00
|
|
|
int i;
|
|
|
|
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("%p %p %p %p\n", image, stream, clsid, params);
|
|
|
|
|
2007-08-01 04:16:00 +02:00
|
|
|
if(!image || !stream)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2008-03-10 16:16:55 +01:00
|
|
|
/* select correct encoder */
|
|
|
|
encode_image = NULL;
|
2009-08-21 00:33:39 +02:00
|
|
|
for (i = 0; i < NUM_CODECS; i++) {
|
2009-08-21 00:36:36 +02:00
|
|
|
if ((codecs[i].info.Flags & ImageCodecFlagsEncoder) &&
|
|
|
|
IsEqualCLSID(clsid, &codecs[i].info.Clsid))
|
2009-08-21 00:21:41 +02:00
|
|
|
encode_image = codecs[i].encode_func;
|
2008-03-10 16:16:55 +01:00
|
|
|
}
|
|
|
|
if (encode_image == NULL)
|
|
|
|
return UnknownImageFormat;
|
2007-08-01 04:16:00 +02:00
|
|
|
|
2009-08-24 22:15:31 +02:00
|
|
|
stat = encode_image(image, stream, clsid, params);
|
2008-03-10 16:16:55 +01:00
|
|
|
|
|
|
|
return stat;
|
2007-08-01 04:16:00 +02:00
|
|
|
}
|
2007-08-09 04:42:16 +02:00
|
|
|
|
2009-07-24 13:48:15 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* GdipGetImagePalette [GDIPLUS.@]
|
|
|
|
*/
|
|
|
|
GpStatus WINGDIPAPI GdipGetImagePalette(GpImage *image, ColorPalette *palette, INT size)
|
|
|
|
{
|
2009-12-12 00:00:19 +01:00
|
|
|
TRACE("(%p,%p,%i)\n", image, palette, size);
|
2009-07-24 13:48:15 +02:00
|
|
|
|
2009-12-12 00:00:19 +01:00
|
|
|
if (!image || !palette)
|
2009-07-24 13:48:15 +02:00
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-12-12 00:00:19 +01:00
|
|
|
if (size < (sizeof(UINT)*2+sizeof(ARGB)*image->palette_count))
|
|
|
|
{
|
|
|
|
TRACE("<-- InsufficientBuffer\n");
|
|
|
|
return InsufficientBuffer;
|
|
|
|
}
|
2009-07-24 13:48:15 +02:00
|
|
|
|
2009-12-12 00:00:19 +01:00
|
|
|
palette->Flags = image->palette_flags;
|
|
|
|
palette->Count = image->palette_count;
|
|
|
|
memcpy(palette->Entries, image->palette_entries, sizeof(ARGB)*image->palette_count);
|
|
|
|
|
|
|
|
return Ok;
|
2009-07-24 13:48:15 +02:00
|
|
|
}
|
|
|
|
|
2008-07-26 19:20:33 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* GdipSetImagePalette [GDIPLUS.@]
|
|
|
|
*/
|
2007-08-09 04:42:16 +02:00
|
|
|
GpStatus WINGDIPAPI GdipSetImagePalette(GpImage *image,
|
|
|
|
GDIPCONST ColorPalette *palette)
|
|
|
|
{
|
2009-12-11 23:51:46 +01:00
|
|
|
TRACE("(%p,%p)\n", image, palette);
|
2007-08-09 04:42:16 +02:00
|
|
|
|
2009-12-11 23:51:46 +01:00
|
|
|
if(!image || !palette || palette->Count > 256)
|
2007-08-09 04:42:16 +02:00
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-12-11 23:51:46 +01:00
|
|
|
if (palette->Count > image->palette_size)
|
|
|
|
{
|
|
|
|
ARGB *new_palette;
|
2007-08-09 04:42:16 +02:00
|
|
|
|
2009-12-11 23:51:46 +01:00
|
|
|
new_palette = GdipAlloc(sizeof(ARGB) * palette->Count);
|
|
|
|
if (!new_palette) return OutOfMemory;
|
|
|
|
|
|
|
|
GdipFree(image->palette_entries);
|
|
|
|
image->palette_entries = new_palette;
|
|
|
|
image->palette_size = palette->Count;
|
|
|
|
}
|
|
|
|
|
|
|
|
image->palette_flags = palette->Flags;
|
|
|
|
image->palette_count = palette->Count;
|
|
|
|
memcpy(image->palette_entries, palette->Entries, sizeof(ARGB)*palette->Count);
|
|
|
|
|
|
|
|
return Ok;
|
2007-08-09 04:42:16 +02:00
|
|
|
}
|
2008-03-06 10:17:00 +01:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* Encoders -
|
|
|
|
* Structures that represent which formats we support for encoding.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* ImageCodecInfo creation routines taken from libgdiplus */
|
|
|
|
static const WCHAR bmp_codecname[] = {'B', 'u', 'i','l', 't', '-','i', 'n', ' ', 'B', 'M', 'P', 0}; /* Built-in BMP */
|
|
|
|
static const WCHAR bmp_extension[] = {'*','.','B', 'M', 'P',';', '*','.', 'D','I', 'B',';', '*','.', 'R', 'L', 'E',0}; /* *.BMP;*.DIB;*.RLE */
|
|
|
|
static const WCHAR bmp_mimetype[] = {'i', 'm', 'a','g', 'e', '/', 'b', 'm', 'p', 0}; /* image/bmp */
|
|
|
|
static const WCHAR bmp_format[] = {'B', 'M', 'P', 0}; /* BMP */
|
|
|
|
static const BYTE bmp_sig_pattern[] = { 0x42, 0x4D };
|
|
|
|
static const BYTE bmp_sig_mask[] = { 0xFF, 0xFF };
|
|
|
|
|
2009-08-21 00:59:13 +02:00
|
|
|
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[4] = "GIF8";
|
|
|
|
static const BYTE gif_sig_mask[] = { 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 };
|
|
|
|
|
2009-08-25 23:53:56 +02:00
|
|
|
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 };
|
|
|
|
|
2009-08-21 00:59:13 +02:00
|
|
|
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 };
|
|
|
|
|
2009-08-21 00:33:39 +02:00
|
|
|
static const struct image_codec codecs[NUM_CODECS] = {
|
2008-03-06 10:17:00 +01:00
|
|
|
{
|
|
|
|
{ /* BMP */
|
|
|
|
/* Clsid */ { 0x557cf400, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } },
|
|
|
|
/* FormatID */ { 0xb96b3cabU, 0x0728U, 0x11d3U, {0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e} },
|
|
|
|
/* CodecName */ bmp_codecname,
|
|
|
|
/* DllName */ NULL,
|
|
|
|
/* FormatDescription */ bmp_format,
|
|
|
|
/* FilenameExtension */ bmp_extension,
|
|
|
|
/* MimeType */ bmp_mimetype,
|
|
|
|
/* Flags */ ImageCodecFlagsEncoder | ImageCodecFlagsDecoder | ImageCodecFlagsSupportBitmap | ImageCodecFlagsBuiltin,
|
|
|
|
/* Version */ 1,
|
|
|
|
/* SigCount */ 1,
|
|
|
|
/* SigSize */ 2,
|
|
|
|
/* SigPattern */ bmp_sig_pattern,
|
|
|
|
/* SigMask */ bmp_sig_mask,
|
|
|
|
},
|
2009-08-26 00:43:33 +02:00
|
|
|
encode_image_BMP,
|
2009-09-04 16:54:55 +02:00
|
|
|
decode_image_bmp
|
2009-08-21 00:59:13 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
{ /* JPEG */
|
|
|
|
/* Clsid */ { 0x557cf401, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } },
|
|
|
|
/* FormatID */ { 0xb96b3caeU, 0x0728U, 0x11d3U, {0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e} },
|
|
|
|
/* CodecName */ jpeg_codecname,
|
|
|
|
/* DllName */ NULL,
|
|
|
|
/* FormatDescription */ jpeg_format,
|
|
|
|
/* FilenameExtension */ jpeg_extension,
|
|
|
|
/* MimeType */ jpeg_mimetype,
|
|
|
|
/* Flags */ ImageCodecFlagsDecoder | ImageCodecFlagsSupportBitmap | ImageCodecFlagsBuiltin,
|
|
|
|
/* Version */ 1,
|
|
|
|
/* SigCount */ 1,
|
|
|
|
/* SigSize */ 2,
|
|
|
|
/* SigPattern */ jpeg_sig_pattern,
|
|
|
|
/* SigMask */ jpeg_sig_mask,
|
|
|
|
},
|
2009-08-26 00:43:33 +02:00
|
|
|
NULL,
|
2009-09-02 00:54:45 +02:00
|
|
|
decode_image_jpeg
|
2009-08-21 00:59:13 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
{ /* GIF */
|
|
|
|
/* Clsid */ { 0x557cf402, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } },
|
|
|
|
/* FormatID */ { 0xb96b3cb0U, 0x0728U, 0x11d3U, {0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e} },
|
|
|
|
/* CodecName */ gif_codecname,
|
|
|
|
/* DllName */ NULL,
|
|
|
|
/* FormatDescription */ gif_format,
|
|
|
|
/* FilenameExtension */ gif_extension,
|
|
|
|
/* MimeType */ gif_mimetype,
|
|
|
|
/* Flags */ ImageCodecFlagsDecoder | ImageCodecFlagsSupportBitmap | ImageCodecFlagsBuiltin,
|
|
|
|
/* Version */ 1,
|
|
|
|
/* SigCount */ 1,
|
|
|
|
/* SigSize */ 4,
|
|
|
|
/* SigPattern */ gif_sig_pattern,
|
|
|
|
/* SigMask */ gif_sig_mask,
|
|
|
|
},
|
2009-08-26 00:43:33 +02:00
|
|
|
NULL,
|
2009-09-02 00:56:42 +02:00
|
|
|
decode_image_gif
|
2009-08-21 00:59:13 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
{ /* EMF */
|
|
|
|
/* Clsid */ { 0x557cf403, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } },
|
|
|
|
/* FormatID */ { 0xb96b3cacU, 0x0728U, 0x11d3U, {0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e} },
|
|
|
|
/* CodecName */ emf_codecname,
|
|
|
|
/* DllName */ NULL,
|
|
|
|
/* FormatDescription */ emf_format,
|
|
|
|
/* FilenameExtension */ emf_extension,
|
|
|
|
/* MimeType */ emf_mimetype,
|
|
|
|
/* Flags */ ImageCodecFlagsDecoder | ImageCodecFlagsSupportVector | ImageCodecFlagsBuiltin,
|
|
|
|
/* Version */ 1,
|
|
|
|
/* SigCount */ 1,
|
|
|
|
/* SigSize */ 4,
|
|
|
|
/* SigPattern */ emf_sig_pattern,
|
|
|
|
/* SigMask */ emf_sig_mask,
|
|
|
|
},
|
2009-08-26 00:43:33 +02:00
|
|
|
NULL,
|
|
|
|
decode_image_olepicture_metafile
|
2009-08-21 00:59:13 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
{ /* WMF */
|
|
|
|
/* Clsid */ { 0x557cf404, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } },
|
|
|
|
/* FormatID */ { 0xb96b3cadU, 0x0728U, 0x11d3U, {0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e} },
|
|
|
|
/* CodecName */ wmf_codecname,
|
|
|
|
/* DllName */ NULL,
|
|
|
|
/* FormatDescription */ wmf_format,
|
|
|
|
/* FilenameExtension */ wmf_extension,
|
|
|
|
/* MimeType */ wmf_mimetype,
|
|
|
|
/* Flags */ ImageCodecFlagsDecoder | ImageCodecFlagsSupportVector | ImageCodecFlagsBuiltin,
|
|
|
|
/* Version */ 1,
|
|
|
|
/* SigCount */ 1,
|
|
|
|
/* SigSize */ 2,
|
|
|
|
/* SigPattern */ wmf_sig_pattern,
|
|
|
|
/* SigMask */ wmf_sig_mask,
|
|
|
|
},
|
2009-08-26 00:43:33 +02:00
|
|
|
NULL,
|
|
|
|
decode_image_olepicture_metafile
|
2009-08-21 00:59:13 +02:00
|
|
|
},
|
2009-08-25 23:53:56 +02:00
|
|
|
{
|
|
|
|
{ /* PNG */
|
|
|
|
/* Clsid */ { 0x557cf406, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } },
|
|
|
|
/* FormatID */ { 0xb96b3cafU, 0x0728U, 0x11d3U, {0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e} },
|
|
|
|
/* CodecName */ png_codecname,
|
|
|
|
/* DllName */ NULL,
|
|
|
|
/* FormatDescription */ png_format,
|
|
|
|
/* FilenameExtension */ png_extension,
|
|
|
|
/* MimeType */ png_mimetype,
|
2009-09-24 00:33:53 +02:00
|
|
|
/* Flags */ ImageCodecFlagsEncoder | ImageCodecFlagsDecoder | ImageCodecFlagsSupportBitmap | ImageCodecFlagsBuiltin,
|
2009-08-25 23:53:56 +02:00
|
|
|
/* Version */ 1,
|
|
|
|
/* SigCount */ 1,
|
|
|
|
/* SigSize */ 8,
|
|
|
|
/* SigPattern */ png_sig_pattern,
|
|
|
|
/* SigMask */ png_sig_mask,
|
|
|
|
},
|
2009-09-24 00:33:53 +02:00
|
|
|
encode_image_png,
|
2009-09-04 16:59:46 +02:00
|
|
|
decode_image_png
|
2009-08-25 23:53:56 +02:00
|
|
|
},
|
2009-08-21 00:59:13 +02:00
|
|
|
{
|
|
|
|
{ /* ICO */
|
|
|
|
/* Clsid */ { 0x557cf407, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } },
|
|
|
|
/* FormatID */ { 0xb96b3cabU, 0x0728U, 0x11d3U, {0x9d, 0x7b, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e} },
|
|
|
|
/* CodecName */ ico_codecname,
|
|
|
|
/* DllName */ NULL,
|
|
|
|
/* FormatDescription */ ico_format,
|
|
|
|
/* FilenameExtension */ ico_extension,
|
|
|
|
/* MimeType */ ico_mimetype,
|
|
|
|
/* Flags */ ImageCodecFlagsDecoder | ImageCodecFlagsSupportBitmap | ImageCodecFlagsBuiltin,
|
|
|
|
/* Version */ 1,
|
|
|
|
/* SigCount */ 1,
|
|
|
|
/* SigSize */ 4,
|
|
|
|
/* SigPattern */ ico_sig_pattern,
|
|
|
|
/* SigMask */ ico_sig_mask,
|
|
|
|
},
|
2009-08-26 00:43:33 +02:00
|
|
|
NULL,
|
2009-08-31 23:56:47 +02:00
|
|
|
decode_image_icon
|
2009-08-21 00:59:13 +02:00
|
|
|
},
|
2009-08-21 00:21:41 +02:00
|
|
|
};
|
2008-03-06 10:17:00 +01:00
|
|
|
|
2008-09-13 02:40:28 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* GdipGetImageDecodersSize [GDIPLUS.@]
|
|
|
|
*/
|
|
|
|
GpStatus WINGDIPAPI GdipGetImageDecodersSize(UINT *numDecoders, UINT *size)
|
|
|
|
{
|
2009-08-21 00:33:39 +02:00
|
|
|
int decoder_count=0;
|
|
|
|
int i;
|
|
|
|
TRACE("%p %p\n", numDecoders, size);
|
2008-09-13 02:40:28 +02:00
|
|
|
|
|
|
|
if (!numDecoders || !size)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-08-21 00:33:39 +02:00
|
|
|
for (i=0; i<NUM_CODECS; i++)
|
|
|
|
{
|
|
|
|
if (codecs[i].info.Flags & ImageCodecFlagsDecoder)
|
|
|
|
decoder_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*numDecoders = decoder_count;
|
|
|
|
*size = decoder_count * sizeof(ImageCodecInfo);
|
2008-09-13 02:40:28 +02:00
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* GdipGetImageDecoders [GDIPLUS.@]
|
|
|
|
*/
|
|
|
|
GpStatus WINGDIPAPI GdipGetImageDecoders(UINT numDecoders, UINT size, ImageCodecInfo *decoders)
|
|
|
|
{
|
2009-08-21 00:33:39 +02:00
|
|
|
int i, decoder_count=0;
|
|
|
|
TRACE("%u %u %p\n", numDecoders, size, decoders);
|
2008-09-13 02:40:28 +02:00
|
|
|
|
2009-08-21 00:33:39 +02:00
|
|
|
if (!decoders ||
|
|
|
|
size != numDecoders * sizeof(ImageCodecInfo))
|
2008-09-13 02:40:28 +02:00
|
|
|
return GenericError;
|
|
|
|
|
2009-08-21 00:33:39 +02:00
|
|
|
for (i=0; i<NUM_CODECS; i++)
|
|
|
|
{
|
|
|
|
if (codecs[i].info.Flags & ImageCodecFlagsDecoder)
|
|
|
|
{
|
|
|
|
if (decoder_count == numDecoders) return GenericError;
|
|
|
|
memcpy(&decoders[decoder_count], &codecs[i].info, sizeof(ImageCodecInfo));
|
|
|
|
decoder_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (decoder_count < numDecoders) return GenericError;
|
|
|
|
|
|
|
|
return Ok;
|
2008-09-13 02:40:28 +02:00
|
|
|
}
|
|
|
|
|
2008-07-26 19:20:33 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* GdipGetImageEncodersSize [GDIPLUS.@]
|
|
|
|
*/
|
2008-03-06 10:17:00 +01:00
|
|
|
GpStatus WINGDIPAPI GdipGetImageEncodersSize(UINT *numEncoders, UINT *size)
|
|
|
|
{
|
2009-08-21 00:33:39 +02:00
|
|
|
int encoder_count=0;
|
|
|
|
int i;
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("%p %p\n", numEncoders, size);
|
|
|
|
|
2008-03-06 10:17:00 +01:00
|
|
|
if (!numEncoders || !size)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-08-21 00:33:39 +02:00
|
|
|
for (i=0; i<NUM_CODECS; i++)
|
|
|
|
{
|
|
|
|
if (codecs[i].info.Flags & ImageCodecFlagsEncoder)
|
|
|
|
encoder_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*numEncoders = encoder_count;
|
|
|
|
*size = encoder_count * sizeof(ImageCodecInfo);
|
2008-03-06 10:17:00 +01:00
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2008-07-26 19:20:33 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* GdipGetImageEncoders [GDIPLUS.@]
|
|
|
|
*/
|
2008-03-06 10:17:00 +01:00
|
|
|
GpStatus WINGDIPAPI GdipGetImageEncoders(UINT numEncoders, UINT size, ImageCodecInfo *encoders)
|
|
|
|
{
|
2009-08-21 00:33:39 +02:00
|
|
|
int i, encoder_count=0;
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("%u %u %p\n", numEncoders, size, encoders);
|
|
|
|
|
2008-03-06 10:17:00 +01:00
|
|
|
if (!encoders ||
|
2009-08-21 00:33:39 +02:00
|
|
|
size != numEncoders * sizeof(ImageCodecInfo))
|
2008-03-06 10:17:00 +01:00
|
|
|
return GenericError;
|
|
|
|
|
2009-08-21 00:33:39 +02:00
|
|
|
for (i=0; i<NUM_CODECS; i++)
|
|
|
|
{
|
|
|
|
if (codecs[i].info.Flags & ImageCodecFlagsEncoder)
|
|
|
|
{
|
|
|
|
if (encoder_count == numEncoders) return GenericError;
|
|
|
|
memcpy(&encoders[encoder_count], &codecs[i].info, sizeof(ImageCodecInfo));
|
|
|
|
encoder_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (encoder_count < numEncoders) return GenericError;
|
2008-03-06 10:17:00 +01:00
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
2008-07-26 19:20:33 +02:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* GdipCreateBitmapFromHBITMAP [GDIPLUS.@]
|
|
|
|
*/
|
2008-03-22 00:39:22 +01:00
|
|
|
GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBitmap** bitmap)
|
|
|
|
{
|
|
|
|
BITMAP bm;
|
|
|
|
GpStatus retval;
|
|
|
|
PixelFormat format;
|
2009-12-13 00:13:39 +01:00
|
|
|
BitmapData lockeddata;
|
|
|
|
INT y;
|
2008-03-22 00:39:22 +01:00
|
|
|
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("%p %p %p\n", hbm, hpal, bitmap);
|
|
|
|
|
2008-03-22 00:39:22 +01:00
|
|
|
if(!hbm || !bitmap)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
/* TODO: Support for device-dependent bitmaps */
|
|
|
|
if(hpal){
|
|
|
|
FIXME("no support for device-dependent bitmaps\n");
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetObjectA(hbm, sizeof(bm), &bm) != sizeof(bm))
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
/* TODO: Figure out the correct format for 16, 32, 64 bpp */
|
|
|
|
switch(bm.bmBitsPixel) {
|
|
|
|
case 1:
|
|
|
|
format = PixelFormat1bppIndexed;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
format = PixelFormat4bppIndexed;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
format = PixelFormat8bppIndexed;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
format = PixelFormat24bppRGB;
|
|
|
|
break;
|
2008-10-04 11:30:09 +02:00
|
|
|
case 32:
|
|
|
|
format = PixelFormat32bppRGB;
|
|
|
|
break;
|
2008-03-22 00:39:22 +01:00
|
|
|
case 48:
|
|
|
|
format = PixelFormat48bppRGB;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("don't know how to handle %d bpp\n", bm.bmBitsPixel);
|
|
|
|
return InvalidParameter;
|
|
|
|
}
|
|
|
|
|
2009-12-13 00:13:39 +01:00
|
|
|
retval = GdipCreateBitmapFromScan0(bm.bmWidth, bm.bmHeight, 0,
|
|
|
|
format, NULL, bitmap);
|
|
|
|
|
|
|
|
if (retval == Ok)
|
2009-02-17 21:39:17 +01:00
|
|
|
{
|
2009-12-13 00:13:39 +01:00
|
|
|
retval = GdipBitmapLockBits(*bitmap, NULL, ImageLockModeWrite,
|
|
|
|
format, &lockeddata);
|
|
|
|
if (retval == Ok)
|
|
|
|
{
|
|
|
|
if (bm.bmBits)
|
|
|
|
{
|
|
|
|
for (y=0; y<bm.bmHeight; y++)
|
|
|
|
{
|
|
|
|
memcpy((BYTE*)lockeddata.Scan0+lockeddata.Stride*y,
|
|
|
|
(BYTE*)bm.bmBits+bm.bmWidthBytes*(bm.bmHeight-1-y),
|
|
|
|
bm.bmWidthBytes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-12-13 00:33:58 +01:00
|
|
|
HDC hdc;
|
|
|
|
HBITMAP oldhbm;
|
|
|
|
BITMAPINFO *pbmi;
|
|
|
|
INT src_height, dst_stride;
|
|
|
|
BYTE *dst_bits;
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(NULL);
|
|
|
|
oldhbm = SelectObject(hdc, hbm);
|
|
|
|
|
|
|
|
pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
|
|
|
|
|
|
|
|
if (pbmi)
|
|
|
|
{
|
|
|
|
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
|
|
|
pbmi->bmiHeader.biBitCount = 0;
|
|
|
|
|
|
|
|
GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
|
|
|
|
|
|
|
|
src_height = abs(pbmi->bmiHeader.biHeight);
|
|
|
|
|
|
|
|
if (pbmi->bmiHeader.biHeight > 0)
|
|
|
|
{
|
|
|
|
dst_bits = (BYTE*)lockeddata.Scan0+lockeddata.Stride*(src_height-1);
|
|
|
|
dst_stride = -lockeddata.Stride;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dst_bits = lockeddata.Scan0;
|
|
|
|
dst_stride = lockeddata.Stride;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (y=0; y<src_height; y++)
|
|
|
|
{
|
|
|
|
GetDIBits(hdc, hbm, y, 1, dst_bits+dst_stride*y,
|
|
|
|
pbmi, DIB_RGB_COLORS);
|
|
|
|
}
|
|
|
|
|
|
|
|
GdipFree(pbmi);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
retval = OutOfMemory;
|
|
|
|
|
|
|
|
SelectObject(hdc, oldhbm);
|
|
|
|
DeleteDC(hdc);
|
2009-12-13 00:13:39 +01:00
|
|
|
}
|
2009-02-17 21:39:17 +01:00
|
|
|
|
2009-12-13 00:13:39 +01:00
|
|
|
GdipBitmapUnlockBits(*bitmap, &lockeddata);
|
|
|
|
}
|
|
|
|
}
|
2008-03-22 00:39:22 +01:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
2008-04-09 22:00:16 +02:00
|
|
|
|
2009-06-03 05:33:32 +02:00
|
|
|
GpStatus WINGDIPAPI GdipDeleteEffect(CGpEffect *effect)
|
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", effect);
|
|
|
|
/* note: According to Jose Roca's GDI+ Docs, this is not implemented
|
|
|
|
* in Windows's gdiplus */
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
2008-07-26 19:20:33 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* GdipSetEffectParameters [GDIPLUS.@]
|
|
|
|
*/
|
2008-04-09 22:00:16 +02:00
|
|
|
GpStatus WINGDIPAPI GdipSetEffectParameters(CGpEffect *effect,
|
|
|
|
const VOID *params, const UINT size)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
2009-12-18 23:12:51 +01:00
|
|
|
TRACE("(%p,%p,%u)\n", effect, params, size);
|
|
|
|
|
2008-04-09 22:00:16 +02:00
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
2008-05-09 14:39:43 +02:00
|
|
|
|
2008-07-26 19:20:33 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* GdipGetImageFlags [GDIPLUS.@]
|
|
|
|
*/
|
2008-05-09 14:39:43 +02:00
|
|
|
GpStatus WINGDIPAPI GdipGetImageFlags(GpImage *image, UINT *flags)
|
|
|
|
{
|
2008-09-10 22:20:42 +02:00
|
|
|
TRACE("%p %p\n", image, flags);
|
|
|
|
|
2008-05-09 14:39:43 +02:00
|
|
|
if(!image || !flags)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
*flags = image->flags;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
2008-09-06 23:40:26 +02:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipTestControl(GpTestControlEnum control, void *param)
|
|
|
|
{
|
|
|
|
TRACE("(%d, %p)\n", control, param);
|
|
|
|
|
|
|
|
switch(control){
|
|
|
|
case TestControlForceBilinear:
|
|
|
|
if(param)
|
|
|
|
FIXME("TestControlForceBilinear not handled\n");
|
|
|
|
break;
|
|
|
|
case TestControlNoICM:
|
|
|
|
if(param)
|
|
|
|
FIXME("TestControlNoICM not handled\n");
|
|
|
|
break;
|
|
|
|
case TestControlGetBuildNumber:
|
|
|
|
*((DWORD*)param) = 3102;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
2008-10-03 12:56:40 +02:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipRecordMetafileFileName(GDIPCONST WCHAR* fileName,
|
|
|
|
HDC hdc, EmfType type, GDIPCONST GpRectF *pFrameRect,
|
|
|
|
MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc,
|
|
|
|
GpMetafile **metafile)
|
|
|
|
{
|
|
|
|
FIXME("%s %p %d %p %d %s %p stub!\n", debugstr_w(fileName), hdc, type, pFrameRect,
|
|
|
|
frameUnit, debugstr_w(desc), metafile);
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipRecordMetafileFileNameI(GDIPCONST WCHAR* fileName, HDC hdc, EmfType type,
|
|
|
|
GDIPCONST GpRect *pFrameRect, MetafileFrameUnit frameUnit,
|
|
|
|
GDIPCONST WCHAR *desc, GpMetafile **metafile)
|
|
|
|
{
|
|
|
|
FIXME("%s %p %d %p %d %s %p stub!\n", debugstr_w(fileName), hdc, type, pFrameRect,
|
|
|
|
frameUnit, debugstr_w(desc), metafile);
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
2008-11-24 10:23:03 +01:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipImageForceValidation(GpImage *image)
|
|
|
|
{
|
|
|
|
FIXME("%p\n", image);
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
2009-05-05 22:02:25 +02:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* GdipGetImageThumbnail [GDIPLUS.@]
|
|
|
|
*/
|
|
|
|
GpStatus WINGDIPAPI GdipGetImageThumbnail(GpImage *image, UINT width, UINT height,
|
|
|
|
GpImage **ret_image, GetThumbnailImageAbort cb,
|
|
|
|
VOID * cb_data)
|
|
|
|
{
|
|
|
|
FIXME("(%p %u %u %p %p %p) stub\n",
|
|
|
|
image, width, height, ret_image, cb, cb_data);
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
2009-05-08 07:31:15 +02:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* GdipImageRotateFlip [GDIPLUS.@]
|
|
|
|
*/
|
|
|
|
GpStatus WINGDIPAPI GdipImageRotateFlip(GpImage *image, RotateFlipType type)
|
|
|
|
{
|
|
|
|
FIXME("(%p %u) stub\n", image, type);
|
|
|
|
return NotImplemented;
|
|
|
|
}
|