summaryrefslogtreecommitdiffstats
path: root/win/tkWinImage.c
diff options
context:
space:
mode:
Diffstat (limited to 'win/tkWinImage.c')
-rw-r--r--win/tkWinImage.c68
1 files changed, 33 insertions, 35 deletions
diff --git a/win/tkWinImage.c b/win/tkWinImage.c
index 37e4351..01b5976 100644
--- a/win/tkWinImage.c
+++ b/win/tkWinImage.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinImage.c,v 1.11 2007/01/12 10:41:23 dkf Exp $
+ * RCS: @(#) $Id: tkWinImage.c,v 1.14 2010/12/17 15:14:22 nijtmans Exp $
*/
#include "tkWinInt.h"
@@ -41,9 +41,9 @@ DestroyImage(
{
if (imagePtr) {
if (imagePtr->data) {
- ckfree((char*)imagePtr->data);
+ ckfree(imagePtr->data);
}
- ckfree((char*)imagePtr);
+ ckfree(imagePtr);
}
return 0;
}
@@ -70,7 +70,7 @@ ImageGetPixel(
int x, int y)
{
unsigned long pixel = 0;
- unsigned char *srcPtr = &(image->data[(y * image->bytes_per_line)
+ unsigned char *srcPtr = (unsigned char *) &(image->data[(y * image->bytes_per_line)
+ ((x * image->bits_per_pixel) / NBBY)]);
switch (image->bits_per_pixel) {
@@ -118,7 +118,7 @@ PutPixel(
int x, int y,
unsigned long pixel)
{
- unsigned char *destPtr = &(image->data[(y * image->bytes_per_line)
+ unsigned char *destPtr = (unsigned char *) &(image->data[(y * image->bytes_per_line)
+ ((x * image->bits_per_pixel) / NBBY)]);
switch (image->bits_per_pixel) {
@@ -213,7 +213,7 @@ XCreateImage(
int bitmap_pad,
int bytes_per_line)
{
- XImage* imagePtr = (XImage *) ckalloc(sizeof(XImage));
+ XImage* imagePtr = ckalloc(sizeof(XImage));
imagePtr->width = width;
imagePtr->height = height;
imagePtr->xoffset = offset;
@@ -303,8 +303,7 @@ XGetImageZPixmap(
BOOL ret;
if (format != ZPixmap) {
- TkpDisplayWarning(
- "XGetImageZPixmap: only ZPixmap types are implemented",
+ TkpDisplayWarning("Only ZPixmap types are implemented",
"XGetImageZPixmap Failure");
return NULL;
}
@@ -352,7 +351,7 @@ XGetImageZPixmap(
if (depth <= 8) {
size += sizeof(unsigned short) * (1 << depth);
}
- bmInfo = (BITMAPINFO *) ckalloc((unsigned)size);
+ bmInfo = ckalloc(size);
bmInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmInfo->bmiHeader.biWidth = width;
@@ -376,7 +375,7 @@ XGetImageZPixmap(
ret_image = NULL;
goto cleanup;
}
- ret_image = XCreateImage(display, NULL, depth, ZPixmap, 0, data,
+ ret_image = XCreateImage(display, NULL, depth, ZPixmap, 0, (char *) data,
width, height, 32, (int) ((width + 31) >> 3) & ~1);
if (ret_image == NULL) {
ckfree(data);
@@ -389,8 +388,8 @@ XGetImageZPixmap(
if (GetDIBits(hdcMem, hbmp, 0, height, data, bmInfo,
DIB_PAL_COLORS) == 0) {
- ckfree((char *) ret_image->data);
- ckfree((char *) ret_image);
+ ckfree(ret_image->data);
+ ckfree(ret_image);
ret_image = NULL;
goto cleanup;
}
@@ -412,10 +411,10 @@ XGetImageZPixmap(
ret_image = NULL;
goto cleanup;
}
- ret_image = XCreateImage(display, NULL, 8, ZPixmap, 0, data,
+ ret_image = XCreateImage(display, NULL, 8, ZPixmap, 0, (char *) data,
width, height, 8, (int) width);
if (ret_image == NULL) {
- ckfree((char *) data);
+ ckfree(data);
goto cleanup;
}
@@ -425,8 +424,8 @@ XGetImageZPixmap(
if (GetDIBits(hdcMem, hbmp, 0, height, data, bmInfo,
DIB_PAL_COLORS) == 0) {
- ckfree((char *) ret_image->data);
- ckfree((char *) ret_image);
+ ckfree(ret_image->data);
+ ckfree(ret_image);
ret_image = NULL;
goto cleanup;
}
@@ -443,10 +442,10 @@ XGetImageZPixmap(
ret_image = NULL;
goto cleanup;
}
- ret_image = XCreateImage(display, NULL, 16, ZPixmap, 0, data,
+ ret_image = XCreateImage(display, NULL, 16, ZPixmap, 0, (char *) data,
width, height, 16, 0 /* will be calc'ed from bitmap_pad */);
if (ret_image == NULL) {
- ckfree((char *) data);
+ ckfree(data);
goto cleanup;
}
@@ -456,8 +455,8 @@ XGetImageZPixmap(
if (GetDIBits(hdcMem, hbmp, 0, height, ret_image->data, bmInfo,
DIB_RGB_COLORS) == 0) {
- ckfree((char *) ret_image->data);
- ckfree((char *) ret_image);
+ ckfree(ret_image->data);
+ ckfree(ret_image);
ret_image = NULL;
goto cleanup;
}
@@ -469,10 +468,10 @@ XGetImageZPixmap(
ret_image = NULL;
goto cleanup;
}
- ret_image = XCreateImage(display, NULL, 32, ZPixmap, 0, data,
+ ret_image = XCreateImage(display, NULL, 32, ZPixmap, 0, (char *) data,
width, height, 0, (int) width * 4);
if (ret_image == NULL) {
- ckfree((char *) data);
+ ckfree(data);
goto cleanup;
}
@@ -488,8 +487,8 @@ XGetImageZPixmap(
byte_width = ((width * 3 + 3) & ~(unsigned)3);
smallBitBase = ckalloc(byte_width * height);
if (!smallBitBase) {
- ckfree((char *) ret_image->data);
- ckfree((char *) ret_image);
+ ckfree(ret_image->data);
+ ckfree(ret_image);
ret_image = NULL;
goto cleanup;
}
@@ -501,9 +500,9 @@ XGetImageZPixmap(
if (GetDIBits(hdcMem, hbmp, 0, height, smallBitData, bmInfo,
DIB_RGB_COLORS) == 0) {
- ckfree((char *) ret_image->data);
- ckfree((char *) ret_image);
- ckfree((char *) smallBitBase);
+ ckfree(ret_image->data);
+ ckfree(ret_image);
+ ckfree(smallBitBase);
ret_image = NULL;
goto cleanup;
}
@@ -513,7 +512,7 @@ XGetImageZPixmap(
*/
for (h = 0; h < height; h++) {
- bigBitData = ret_image->data + h * ret_image->bytes_per_line;
+ bigBitData = (unsigned char *) ret_image->data + h * ret_image->bytes_per_line;
smallBitData = smallBitBase + h * byte_width;
for (w = 0; w < width; w++) {
@@ -528,7 +527,7 @@ XGetImageZPixmap(
* Free the Device contexts, and the Bitmap.
*/
- ckfree((char *) smallBitBase);
+ ckfree(smallBitBase);
} else {
/*
* Get the BITMAP info directly into the Image.
@@ -536,8 +535,8 @@ XGetImageZPixmap(
if (GetDIBits(hdcMem, hbmp, 0, height, ret_image->data, bmInfo,
DIB_RGB_COLORS) == 0) {
- ckfree((char *) ret_image->data);
- ckfree((char *) ret_image);
+ ckfree(ret_image->data);
+ ckfree(ret_image);
ret_image = NULL;
goto cleanup;
}
@@ -546,7 +545,7 @@ XGetImageZPixmap(
cleanup:
if (bmInfo) {
- ckfree((char *) bmInfo);
+ ckfree(bmInfo);
}
if (hPal) {
SelectPalette(hdcMem, hPalPrev1, FALSE);
@@ -641,7 +640,7 @@ XGetImage(
imagePtr = XGetImageZPixmap(display, d, x, y,
width, height, plane_mask, format);
} else {
- char *errMsg = NULL;
+ const char *errMsg = NULL;
char infoBuf[sizeof(BITMAPINFO) + sizeof(RGBQUAD)];
BITMAPINFO *infoPtr = (BITMAPINFO*)infoBuf;
@@ -663,8 +662,7 @@ XGetImage(
imagePtr = XCreateImage(display, NULL, 1, XYBitmap, 0, NULL,
width, height, 32, 0);
- imagePtr->data =
- ckalloc((unsigned) imagePtr->bytes_per_line*imagePtr->height);
+ imagePtr->data = ckalloc(imagePtr->bytes_per_line * imagePtr->height);
dc = GetDC(NULL);