2007-05-25 19:21:44 +02:00
|
|
|
/*
|
2007-06-08 22:46:27 +02:00
|
|
|
* Copyright (C) 2007 Google (Evan Stade)
|
2007-05-25 19:21:44 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2007-07-12 03:06:56 +02:00
|
|
|
#include <math.h>
|
2007-05-25 19:21:44 +02:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "wine/debug.h"
|
2007-08-01 04:15:29 +02:00
|
|
|
#include "wingdi.h"
|
|
|
|
|
2007-08-01 04:15:48 +02:00
|
|
|
#include "objbase.h"
|
|
|
|
|
2007-08-08 03:42:00 +02:00
|
|
|
#include "winreg.h"
|
|
|
|
#include "shlwapi.h"
|
|
|
|
|
2007-06-08 22:46:27 +02:00
|
|
|
#include "gdiplus.h"
|
2007-07-12 03:06:56 +02:00
|
|
|
#include "gdiplus_private.h"
|
2007-05-25 19:21:44 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
|
|
|
|
|
2012-07-16 07:56:30 +02:00
|
|
|
static const REAL mm_per_inch = 25.4;
|
2012-07-31 11:48:46 +02:00
|
|
|
static const REAL point_per_inch = 72.0;
|
2012-07-16 07:56:30 +02:00
|
|
|
|
2007-08-04 02:30:17 +02:00
|
|
|
static Status WINAPI NotificationHook(ULONG_PTR *token)
|
|
|
|
{
|
|
|
|
TRACE("%p\n", token);
|
|
|
|
if(!token)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI NotificationUnhook(ULONG_PTR token)
|
|
|
|
{
|
|
|
|
TRACE("%ld\n", token);
|
|
|
|
}
|
|
|
|
|
2007-05-25 19:21:44 +02:00
|
|
|
/*****************************************************
|
|
|
|
* DllMain
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %d, %p)\n", hinst, reason, reserved);
|
|
|
|
|
|
|
|
switch(reason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls( hinst );
|
|
|
|
break;
|
2009-04-28 01:56:56 +02:00
|
|
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
free_installed_fonts();
|
|
|
|
break;
|
2007-05-25 19:21:44 +02:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2007-06-08 22:46:27 +02:00
|
|
|
|
2007-06-12 17:51:53 +02:00
|
|
|
/*****************************************************
|
|
|
|
* GdiplusStartup [GDIPLUS.@]
|
|
|
|
*/
|
2007-06-08 22:46:27 +02:00
|
|
|
Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input,
|
|
|
|
struct GdiplusStartupOutput *output)
|
|
|
|
{
|
2007-08-04 02:30:17 +02:00
|
|
|
if(!token || !input)
|
2007-06-08 22:46:27 +02:00
|
|
|
return InvalidParameter;
|
|
|
|
|
2007-08-04 02:30:17 +02:00
|
|
|
TRACE("%p %p %p\n", token, input, output);
|
|
|
|
TRACE("GdiplusStartupInput %d %p %d %d\n", input->GdiplusVersion,
|
|
|
|
input->DebugEventCallback, input->SuppressBackgroundThread,
|
|
|
|
input->SuppressExternalCodecs);
|
|
|
|
|
2009-09-18 22:54:51 +02:00
|
|
|
if(input->GdiplusVersion < 1 || input->GdiplusVersion > 2)
|
2007-06-08 22:46:27 +02:00
|
|
|
return UnsupportedGdiplusVersion;
|
2007-08-04 02:30:17 +02:00
|
|
|
|
|
|
|
if(input->SuppressBackgroundThread){
|
|
|
|
if(!output)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
output->NotificationHook = NotificationHook;
|
|
|
|
output->NotificationUnhook = NotificationUnhook;
|
2007-06-08 22:46:27 +02:00
|
|
|
}
|
|
|
|
|
2008-11-13 14:00:12 +01:00
|
|
|
*token = 0xdeadbeef;
|
|
|
|
|
2007-08-04 02:30:17 +02:00
|
|
|
/* FIXME: DebugEventCallback ignored */
|
|
|
|
|
2007-06-08 22:46:27 +02:00
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2008-11-24 10:21:28 +01:00
|
|
|
GpStatus WINAPI GdiplusNotificationHook(ULONG_PTR *token)
|
|
|
|
{
|
|
|
|
FIXME("%p\n", token);
|
|
|
|
return NotificationHook(token);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WINAPI GdiplusNotificationUnhook(ULONG_PTR token)
|
|
|
|
{
|
|
|
|
FIXME("%ld\n", token);
|
2008-11-26 21:37:32 +01:00
|
|
|
NotificationUnhook(token);
|
2008-11-24 10:21:28 +01:00
|
|
|
}
|
|
|
|
|
2007-06-12 17:51:53 +02:00
|
|
|
/*****************************************************
|
|
|
|
* GdiplusShutdown [GDIPLUS.@]
|
|
|
|
*/
|
2010-09-30 20:02:22 +02:00
|
|
|
ULONG WINAPI GdiplusShutdown_wrapper(ULONG_PTR token)
|
|
|
|
{
|
2011-03-16 08:26:52 +01:00
|
|
|
/* Notice the slightly different prototype from the official
|
2011-05-09 09:03:40 +02:00
|
|
|
* signature which forces us to use the _wrapper suffix.
|
2011-03-16 08:26:52 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* FIXME: no object tracking */
|
2010-09-30 20:02:22 +02:00
|
|
|
|
2011-03-16 08:26:52 +01:00
|
|
|
/* "bricksntiles" expects a return value of 0, which native
|
|
|
|
* coincidentally gives.
|
|
|
|
*/
|
2010-09-30 20:02:22 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-06-12 17:51:53 +02:00
|
|
|
/*****************************************************
|
|
|
|
* GdipAlloc [GDIPLUS.@]
|
|
|
|
*/
|
2007-06-08 22:46:27 +02:00
|
|
|
void* WINGDIPAPI GdipAlloc(SIZE_T size)
|
|
|
|
{
|
|
|
|
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
|
|
|
|
}
|
|
|
|
|
2007-06-12 17:51:53 +02:00
|
|
|
/*****************************************************
|
|
|
|
* GdipFree [GDIPLUS.@]
|
|
|
|
*/
|
2007-06-08 22:46:27 +02:00
|
|
|
void WINGDIPAPI GdipFree(void* ptr)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, ptr);
|
|
|
|
}
|
2007-06-11 20:51:15 +02:00
|
|
|
|
2007-07-12 03:06:56 +02:00
|
|
|
/* Calculates the bezier points needed to fill in the arc portion starting at
|
|
|
|
* angle start and ending at end. These two angles should be no more than 90
|
|
|
|
* degrees from each other. x1, y1, x2, y2 describes the bounding box (upper
|
|
|
|
* left and width and height). Angles must be in radians. write_first indicates
|
|
|
|
* that the first bezier point should be written out (usually this is false).
|
|
|
|
* pt is the array of GpPointFs that gets written to.
|
|
|
|
**/
|
|
|
|
static void add_arc_part(GpPointF * pt, REAL x1, REAL y1, REAL x2, REAL y2,
|
|
|
|
REAL start, REAL end, BOOL write_first)
|
|
|
|
{
|
|
|
|
REAL center_x, center_y, rad_x, rad_y, cos_start, cos_end,
|
|
|
|
sin_start, sin_end, a, half;
|
|
|
|
INT i;
|
|
|
|
|
|
|
|
rad_x = x2 / 2.0;
|
|
|
|
rad_y = y2 / 2.0;
|
|
|
|
center_x = x1 + rad_x;
|
|
|
|
center_y = y1 + rad_y;
|
|
|
|
|
|
|
|
cos_start = cos(start);
|
|
|
|
cos_end = cos(end);
|
|
|
|
sin_start = sin(start);
|
|
|
|
sin_end = sin(end);
|
|
|
|
|
|
|
|
half = (end - start) / 2.0;
|
|
|
|
a = 4.0 / 3.0 * (1 - cos(half)) / sin(half);
|
|
|
|
|
|
|
|
if(write_first){
|
|
|
|
pt[0].X = cos_start;
|
|
|
|
pt[0].Y = sin_start;
|
|
|
|
}
|
|
|
|
pt[1].X = cos_start - a * sin_start;
|
|
|
|
pt[1].Y = sin_start + a * cos_start;
|
|
|
|
|
|
|
|
pt[3].X = cos_end;
|
|
|
|
pt[3].Y = sin_end;
|
|
|
|
pt[2].X = cos_end + a * sin_end;
|
|
|
|
pt[2].Y = sin_end - a * cos_end;
|
|
|
|
|
|
|
|
/* expand the points back from the unit circle to the ellipse */
|
|
|
|
for(i = (write_first ? 0 : 1); i < 4; i ++){
|
|
|
|
pt[i].X = pt[i].X * rad_x + center_x;
|
|
|
|
pt[i].Y = pt[i].Y * rad_y + center_y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We plot the curve as if it is on a circle then stretch the points. This
|
|
|
|
* adjusts the angles so that when we stretch the points they will end in the
|
|
|
|
* right place. This is only complicated because atan and atan2 do not behave
|
|
|
|
* conveniently. */
|
|
|
|
static void unstretch_angle(REAL * angle, REAL rad_x, REAL rad_y)
|
|
|
|
{
|
|
|
|
REAL stretched;
|
|
|
|
INT revs_off;
|
|
|
|
|
|
|
|
*angle = deg2rad(*angle);
|
|
|
|
|
2007-07-26 04:15:33 +02:00
|
|
|
if(fabs(cos(*angle)) < 0.00001 || fabs(sin(*angle)) < 0.00001)
|
2007-07-12 03:06:56 +02:00
|
|
|
return;
|
|
|
|
|
2007-07-26 04:15:33 +02:00
|
|
|
stretched = gdiplus_atan2(sin(*angle) / fabs(rad_y), cos(*angle) / fabs(rad_x));
|
2007-07-12 03:06:56 +02:00
|
|
|
revs_off = roundr(*angle / (2.0 * M_PI)) - roundr(stretched / (2.0 * M_PI));
|
|
|
|
stretched += ((REAL)revs_off) * M_PI * 2.0;
|
|
|
|
*angle = stretched;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Stores the bezier points that correspond to the arc in points. If points is
|
|
|
|
* null, just return the number of points needed to represent the arc. */
|
|
|
|
INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2,
|
|
|
|
REAL startAngle, REAL sweepAngle)
|
|
|
|
{
|
2009-09-04 23:14:32 +02:00
|
|
|
INT i;
|
2007-07-12 03:06:56 +02:00
|
|
|
REAL end_angle, start_angle, endAngle;
|
|
|
|
|
|
|
|
endAngle = startAngle + sweepAngle;
|
|
|
|
unstretch_angle(&startAngle, x2 / 2.0, y2 / 2.0);
|
|
|
|
unstretch_angle(&endAngle, x2 / 2.0, y2 / 2.0);
|
|
|
|
|
|
|
|
/* start_angle and end_angle are the iterative variables */
|
|
|
|
start_angle = startAngle;
|
|
|
|
|
2009-09-04 23:14:32 +02:00
|
|
|
for(i = 0; i < MAX_ARC_PTS - 1; i += 3){
|
2007-07-12 03:06:56 +02:00
|
|
|
/* check if we've overshot the end angle */
|
|
|
|
if( sweepAngle > 0.0 )
|
2009-09-04 23:14:32 +02:00
|
|
|
{
|
|
|
|
if (start_angle >= endAngle) break;
|
2007-07-12 03:06:56 +02:00
|
|
|
end_angle = min(start_angle + M_PI_2, endAngle);
|
2009-09-04 23:14:32 +02:00
|
|
|
}
|
2007-07-12 03:06:56 +02:00
|
|
|
else
|
2009-09-04 23:14:32 +02:00
|
|
|
{
|
|
|
|
if (start_angle <= endAngle) break;
|
2007-07-12 03:06:56 +02:00
|
|
|
end_angle = max(start_angle - M_PI_2, endAngle);
|
2009-09-04 23:14:32 +02:00
|
|
|
}
|
2007-07-12 03:06:56 +02:00
|
|
|
|
2009-09-04 23:14:32 +02:00
|
|
|
if (points)
|
|
|
|
add_arc_part(&points[i], x1, y1, x2, y2, start_angle, end_angle, i == 0);
|
2007-07-12 03:06:56 +02:00
|
|
|
|
|
|
|
start_angle += M_PI_2 * (sweepAngle < 0.0 ? -1.0 : 1.0);
|
|
|
|
}
|
|
|
|
|
2009-09-04 23:14:32 +02:00
|
|
|
if (i == 0) return 0;
|
|
|
|
else return i+1;
|
2007-07-12 03:06:56 +02:00
|
|
|
}
|
|
|
|
|
2007-06-11 20:51:15 +02:00
|
|
|
COLORREF ARGB2COLORREF(ARGB color)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Packing of these color structures:
|
|
|
|
COLORREF: 00bbggrr
|
|
|
|
ARGB: aarrggbb
|
|
|
|
FIXME:doesn't handle alpha channel
|
|
|
|
*/
|
2008-01-07 23:13:19 +01:00
|
|
|
return ((color & 0x0000ff) << 16) +
|
|
|
|
(color & 0x00ff00) +
|
|
|
|
((color & 0xff0000) >> 16);
|
2007-06-11 20:51:15 +02:00
|
|
|
}
|
2007-07-21 02:50:14 +02:00
|
|
|
|
2009-05-20 18:24:18 +02:00
|
|
|
HBITMAP ARGB2BMP(ARGB color)
|
|
|
|
{
|
|
|
|
BITMAPINFO bi;
|
|
|
|
HBITMAP result;
|
|
|
|
RGBQUAD *bits;
|
|
|
|
int alpha;
|
|
|
|
|
|
|
|
if ((color & 0xff000000) == 0xff000000) return 0;
|
|
|
|
|
|
|
|
bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
|
|
|
|
bi.bmiHeader.biWidth = 1;
|
|
|
|
bi.bmiHeader.biHeight = 1;
|
|
|
|
bi.bmiHeader.biPlanes = 1;
|
|
|
|
bi.bmiHeader.biBitCount = 32;
|
|
|
|
bi.bmiHeader.biCompression = BI_RGB;
|
|
|
|
bi.bmiHeader.biSizeImage = 0;
|
|
|
|
bi.bmiHeader.biXPelsPerMeter = 0;
|
|
|
|
bi.bmiHeader.biYPelsPerMeter = 0;
|
|
|
|
bi.bmiHeader.biClrUsed = 0;
|
|
|
|
bi.bmiHeader.biClrImportant = 0;
|
|
|
|
|
2012-05-02 12:02:17 +02:00
|
|
|
result = CreateDIBSection(0, &bi, DIB_RGB_COLORS, (void*)&bits, NULL, 0);
|
2009-05-20 18:24:18 +02:00
|
|
|
|
|
|
|
bits[0].rgbReserved = alpha = (color>>24)&0xff;
|
|
|
|
bits[0].rgbRed = ((color>>16)&0xff)*alpha/255;
|
|
|
|
bits[0].rgbGreen = ((color>>8)&0xff)*alpha/255;
|
|
|
|
bits[0].rgbBlue = (color&0xff)*alpha/255;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-07-21 02:50:14 +02:00
|
|
|
/* Like atan2, but puts angle in correct quadrant if dx is 0. */
|
2007-08-03 00:53:23 +02:00
|
|
|
REAL gdiplus_atan2(REAL dy, REAL dx)
|
2007-07-21 02:50:14 +02:00
|
|
|
{
|
|
|
|
if((dx == 0.0) && (dy != 0.0))
|
|
|
|
return dy > 0.0 ? M_PI_2 : -M_PI_2;
|
|
|
|
|
|
|
|
return atan2(dy, dx);
|
|
|
|
}
|
2007-08-08 03:42:00 +02:00
|
|
|
|
|
|
|
GpStatus hresult_to_status(HRESULT res)
|
|
|
|
{
|
|
|
|
switch(res){
|
|
|
|
case S_OK:
|
|
|
|
return Ok;
|
|
|
|
case E_OUTOFMEMORY:
|
|
|
|
return OutOfMemory;
|
|
|
|
case E_INVALIDARG:
|
|
|
|
return InvalidParameter;
|
|
|
|
default:
|
|
|
|
return GenericError;
|
|
|
|
}
|
|
|
|
}
|
2007-08-08 03:42:09 +02:00
|
|
|
|
2012-07-03 10:33:41 +02:00
|
|
|
/* converts a given unit to its value in inches */
|
2010-08-08 22:24:45 +02:00
|
|
|
REAL convert_unit(REAL logpixels, GpUnit unit)
|
2007-08-08 03:42:09 +02:00
|
|
|
{
|
|
|
|
switch(unit)
|
|
|
|
{
|
|
|
|
case UnitInch:
|
2010-08-08 22:24:45 +02:00
|
|
|
return logpixels;
|
2007-08-08 03:42:09 +02:00
|
|
|
case UnitPoint:
|
2010-08-08 22:24:45 +02:00
|
|
|
return logpixels / 72.0;
|
2007-08-08 03:42:09 +02:00
|
|
|
case UnitDocument:
|
2010-08-08 22:24:45 +02:00
|
|
|
return logpixels / 300.0;
|
2007-08-08 03:42:09 +02:00
|
|
|
case UnitMillimeter:
|
2010-08-08 22:24:45 +02:00
|
|
|
return logpixels / 25.4;
|
2007-08-08 03:42:09 +02:00
|
|
|
case UnitWorld:
|
|
|
|
ERR("cannot convert UnitWorld\n");
|
|
|
|
return 0.0;
|
|
|
|
case UnitPixel:
|
|
|
|
case UnitDisplay:
|
|
|
|
default:
|
|
|
|
return 1.0;
|
|
|
|
}
|
|
|
|
}
|
2008-08-03 00:44:57 +02:00
|
|
|
|
2012-07-16 07:56:30 +02:00
|
|
|
/* converts a given unit to its value in pixels */
|
|
|
|
REAL units_to_pixels(REAL units, GpUnit unit, REAL dpi)
|
|
|
|
{
|
|
|
|
switch (unit)
|
|
|
|
{
|
|
|
|
case UnitPixel:
|
|
|
|
case UnitWorld:
|
|
|
|
case UnitDisplay:
|
|
|
|
return units;
|
|
|
|
case UnitPoint:
|
2012-07-31 11:48:46 +02:00
|
|
|
return units * dpi / point_per_inch;
|
2012-07-16 07:56:30 +02:00
|
|
|
case UnitInch:
|
|
|
|
return units * dpi;
|
|
|
|
case UnitDocument:
|
|
|
|
return units * dpi / 300.0; /* Per MSDN */
|
|
|
|
case UnitMillimeter:
|
|
|
|
return units * dpi / mm_per_inch;
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled unit type: %d\n", unit);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-16 07:57:32 +02:00
|
|
|
/* converts value in pixels to a given unit */
|
|
|
|
REAL pixels_to_units(REAL pixels, GpUnit unit, REAL dpi)
|
|
|
|
{
|
|
|
|
switch (unit)
|
|
|
|
{
|
|
|
|
case UnitPixel:
|
|
|
|
case UnitWorld:
|
|
|
|
case UnitDisplay:
|
|
|
|
return pixels;
|
|
|
|
case UnitPoint:
|
2012-07-31 11:48:46 +02:00
|
|
|
return pixels * point_per_inch / dpi;
|
2012-07-16 07:57:32 +02:00
|
|
|
case UnitInch:
|
|
|
|
return pixels / dpi;
|
|
|
|
case UnitDocument:
|
|
|
|
return pixels * 300.0 / dpi;
|
|
|
|
case UnitMillimeter:
|
|
|
|
return pixels * mm_per_inch / dpi;
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled unit type: %d\n", unit);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-03 00:44:57 +02:00
|
|
|
/* Calculates Bezier points from cardinal spline points. */
|
|
|
|
void calc_curve_bezier(CONST GpPointF *pts, REAL tension, REAL *x1,
|
|
|
|
REAL *y1, REAL *x2, REAL *y2)
|
|
|
|
{
|
|
|
|
REAL xdiff, ydiff;
|
|
|
|
|
|
|
|
/* calculate tangent */
|
|
|
|
xdiff = pts[2].X - pts[0].X;
|
|
|
|
ydiff = pts[2].Y - pts[0].Y;
|
|
|
|
|
|
|
|
/* apply tangent to get control points */
|
|
|
|
*x1 = pts[1].X - tension * xdiff;
|
|
|
|
*y1 = pts[1].Y - tension * ydiff;
|
|
|
|
*x2 = pts[1].X + tension * xdiff;
|
|
|
|
*y2 = pts[1].Y + tension * ydiff;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculates Bezier points from cardinal spline endpoints. */
|
|
|
|
void calc_curve_bezier_endp(REAL xend, REAL yend, REAL xadj, REAL yadj,
|
|
|
|
REAL tension, REAL *x, REAL *y)
|
|
|
|
{
|
|
|
|
/* tangent at endpoints is the line from the endpoint to the adjacent point */
|
|
|
|
*x = roundr(tension * (xadj - xend) + xend);
|
|
|
|
*y = roundr(tension * (yadj - yend) + yend);
|
|
|
|
}
|
2008-08-05 18:56:30 +02:00
|
|
|
|
|
|
|
/* make sure path has enough space for len more points */
|
|
|
|
BOOL lengthen_path(GpPath *path, INT len)
|
|
|
|
{
|
|
|
|
/* initial allocation */
|
|
|
|
if(path->datalen == 0){
|
|
|
|
path->datalen = len * 2;
|
|
|
|
|
|
|
|
path->pathdata.Points = GdipAlloc(path->datalen * sizeof(PointF));
|
|
|
|
if(!path->pathdata.Points) return FALSE;
|
|
|
|
|
|
|
|
path->pathdata.Types = GdipAlloc(path->datalen);
|
|
|
|
if(!path->pathdata.Types){
|
|
|
|
GdipFree(path->pathdata.Points);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* reallocation, double size of arrays */
|
|
|
|
else if(path->datalen - path->pathdata.Count < len){
|
|
|
|
while(path->datalen - path->pathdata.Count < len)
|
|
|
|
path->datalen *= 2;
|
|
|
|
|
|
|
|
path->pathdata.Points = HeapReAlloc(GetProcessHeap(), 0,
|
|
|
|
path->pathdata.Points, path->datalen * sizeof(PointF));
|
|
|
|
if(!path->pathdata.Points) return FALSE;
|
|
|
|
|
|
|
|
path->pathdata.Types = HeapReAlloc(GetProcessHeap(), 0,
|
|
|
|
path->pathdata.Types, path->datalen);
|
|
|
|
if(!path->pathdata.Types) return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2008-08-27 00:03:27 +02:00
|
|
|
|
2009-08-29 00:21:10 +02:00
|
|
|
void convert_32bppARGB_to_32bppPARGB(UINT width, UINT height,
|
|
|
|
BYTE *dst_bits, INT dst_stride, const BYTE *src_bits, INT src_stride)
|
|
|
|
{
|
2011-10-04 21:11:06 +02:00
|
|
|
INT x, y;
|
2009-08-29 00:21:10 +02:00
|
|
|
for (y=0; y<height; y++)
|
|
|
|
{
|
|
|
|
const BYTE *src=src_bits+y*src_stride;
|
|
|
|
BYTE *dst=dst_bits+y*dst_stride;
|
|
|
|
for (x=0; x<width; x++)
|
|
|
|
{
|
|
|
|
BYTE alpha=src[3];
|
|
|
|
*dst++ = *src++ * alpha / 255;
|
|
|
|
*dst++ = *src++ * alpha / 255;
|
|
|
|
*dst++ = *src++ * alpha / 255;
|
|
|
|
*dst++ = *src++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-27 00:03:27 +02:00
|
|
|
/* recursive deletion of GpRegion nodes */
|
2009-10-19 11:44:39 +02:00
|
|
|
void delete_element(region_element* element)
|
2008-08-27 00:03:27 +02:00
|
|
|
{
|
|
|
|
switch(element->type)
|
|
|
|
{
|
|
|
|
case RegionDataRect:
|
|
|
|
break;
|
|
|
|
case RegionDataPath:
|
|
|
|
GdipDeletePath(element->elementdata.pathdata.path);
|
|
|
|
break;
|
|
|
|
case RegionDataEmptyRect:
|
|
|
|
case RegionDataInfiniteRect:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
delete_element(element->elementdata.combine.left);
|
|
|
|
delete_element(element->elementdata.combine.right);
|
|
|
|
GdipFree(element->elementdata.combine.left);
|
|
|
|
GdipFree(element->elementdata.combine.right);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-05-13 20:55:46 +02:00
|
|
|
|
|
|
|
const char *debugstr_rectf(CONST RectF* rc)
|
|
|
|
{
|
|
|
|
if (!rc) return "(null)";
|
|
|
|
return wine_dbg_sprintf("(%0.2f,%0.2f,%0.2f,%0.2f)", rc->X, rc->Y, rc->Width, rc->Height);
|
|
|
|
}
|
2009-12-18 22:45:02 +01:00
|
|
|
|
|
|
|
const char *debugstr_pointf(CONST PointF* pt)
|
|
|
|
{
|
|
|
|
if (!pt) return "(null)";
|
|
|
|
return wine_dbg_sprintf("(%0.2f,%0.2f)", pt->X, pt->Y);
|
|
|
|
}
|