summaryrefslogtreecommitdiffstats
path: root/win/tkWinDraw.c
diff options
context:
space:
mode:
Diffstat (limited to 'win/tkWinDraw.c')
-rw-r--r--win/tkWinDraw.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c
index 35762d4..236d14b 100644
--- a/win/tkWinDraw.c
+++ b/win/tkWinDraw.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinDraw.c,v 1.20 2007/12/13 15:28:55 dgp Exp $
+ * RCS: @(#) $Id: tkWinDraw.c,v 1.25 2010/11/19 14:48:00 nijtmans Exp $
*/
#include "tkWinInt.h"
@@ -19,7 +19,6 @@
* These macros convert between X's bizarre angle units to radians.
*/
-#define PI 3.14159265358979
#define XAngleToRadians(a) ((double)(a) / 64 * PI / 180);
/*
@@ -103,7 +102,7 @@ int tkpWinBltModes[] = {
* The followng typedef is used to pass Windows GDI drawing functions.
*/
-typedef BOOL (CALLBACK *WinDrawFunc)(HDC dc, CONST POINT* points, int npoints);
+typedef BOOL (CALLBACK *WinDrawFunc)(HDC dc, const POINT *points, int npoints);
typedef struct ThreadSpecificData {
POINT *winPoints; /* Array of points that is reused. */
@@ -244,9 +243,9 @@ ConvertPoints(
if (npoints > tsdPtr->nWinPoints) {
if (tsdPtr->winPoints != NULL) {
- ckfree((char *) tsdPtr->winPoints);
+ ckfree(tsdPtr->winPoints);
}
- tsdPtr->winPoints = (POINT *) ckalloc(sizeof(POINT) * npoints);
+ tsdPtr->winPoints = ckalloc(sizeof(POINT) * npoints);
if (tsdPtr->winPoints == NULL) {
tsdPtr->nWinPoints = -1;
return NULL;
@@ -553,10 +552,10 @@ TkPutImage(
usePalette = (image->bits_per_pixel < 16);
if (usePalette) {
- infoPtr = (BITMAPINFO *) ckalloc(sizeof(BITMAPINFOHEADER)
+ infoPtr = ckalloc(sizeof(BITMAPINFOHEADER)
+ sizeof(RGBQUAD)*ncolors);
} else {
- infoPtr = (BITMAPINFO *) ckalloc(sizeof(BITMAPINFOHEADER));
+ infoPtr = ckalloc(sizeof(BITMAPINFOHEADER));
}
infoPtr->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
@@ -583,10 +582,10 @@ TkPutImage(
}
bitmap = CreateDIBitmap(dc, &infoPtr->bmiHeader, CBM_INIT,
image->data, infoPtr, DIB_RGB_COLORS);
- ckfree((char *) infoPtr);
+ ckfree(infoPtr);
}
if (!bitmap) {
- Tcl_Panic("Fail to allocate bitmap\n");
+ Tcl_Panic("Fail to allocate bitmap");
DeleteDC(dcMem);
TkWinReleaseDrawableDC(d, dc, &state);
return;
@@ -746,7 +745,7 @@ RenderObject(
HPEN pen,
WinDrawFunc func)
{
- RECT rect;
+ RECT rect = {0,0,0,0};
HPEN oldPen;
HBRUSH oldBrush;
POINT *winPoints = ConvertPoints(points, npoints, mode, &rect);
@@ -814,7 +813,7 @@ RenderObject(
SetPolyFillMode(dcMem, (gc->fill_rule == EvenOddRule) ? ALTERNATE
: WINDING);
oldMemBrush = SelectObject(dcMem, CreateSolidBrush(gc->foreground));
- (*func)(dcMem, winPoints, npoints);
+ func(dcMem, winPoints, npoints);
BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0, COPYFG);
/*
@@ -826,7 +825,7 @@ RenderObject(
if (gc->fill_style == FillOpaqueStippled) {
DeleteObject(SelectObject(dcMem,
CreateSolidBrush(gc->background)));
- (*func)(dcMem, winPoints, npoints);
+ func(dcMem, winPoints, npoints);
BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0,
COPYBG);
}
@@ -842,9 +841,7 @@ RenderObject(
SetPolyFillMode(dc, (gc->fill_rule == EvenOddRule) ? ALTERNATE
: WINDING);
-
- (*func)(dc, winPoints, npoints);
-
+ func(dc, winPoints, npoints);
SelectObject(dc, oldPen);
}
DeleteObject(SelectObject(dc, oldBrush));