diff options
Diffstat (limited to 'src/win32')
-rw-r--r-- | src/win32/cdwclp.c | 35 | ||||
-rw-r--r-- | src/win32/cdwin.c | 32 | ||||
-rw-r--r-- | src/win32/cdwin.h | 4 | ||||
-rw-r--r-- | src/win32/wmf_emf.c | 84 |
4 files changed, 77 insertions, 78 deletions
diff --git a/src/win32/cdwclp.c b/src/win32/cdwclp.c index e39cb7f..a62e9e8 100644 --- a/src/win32/cdwclp.c +++ b/src/win32/cdwclp.c @@ -41,7 +41,8 @@ static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void HANDLE hFile; DWORD dwSize, nBytesWrite; int err; - char* buffer; + unsigned char* buffer; + (void)data; if (IsClipboardFormatAvailable(CF_TEXT)) { @@ -58,8 +59,8 @@ static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void return CD_ERROR; } - buffer = (char*)GlobalLock(Handle); - dwSize = (DWORD)strlen(buffer); + buffer = (unsigned char*)GlobalLock(Handle); + dwSize = (DWORD)GlobalSize(Handle); hFile = CreateFile(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); WriteFile(hFile, buffer, dwSize, &nBytesWrite, NULL); @@ -94,7 +95,7 @@ static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void dwSize = GetEnhMetaFileBits(Handle, 0, NULL); - buffer = (char*)malloc(dwSize); + buffer = (unsigned char*)malloc(dwSize); GetEnhMetaFileBits(Handle, dwSize, buffer); @@ -132,7 +133,7 @@ static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void lpMFP = (METAFILEPICT*) GlobalLock(Handle); dwSize = GetMetaFileBitsEx(lpMFP->hMF, 0, NULL); - buffer = (char*)malloc(dwSize); + buffer = (unsigned char*)malloc(dwSize); GetMetaFileBitsEx(lpMFP->hMF, dwSize, buffer); @@ -194,11 +195,11 @@ static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void if (dib.type == 0) { - char *r, *g, *b; + unsigned char *r, *g, *b; - r = (char*)malloc(size); - g = (char*)malloc(size); - b = (char*)malloc(size); + r = (unsigned char*)malloc(size); + g = (unsigned char*)malloc(size); + b = (unsigned char*)malloc(size); cdwDIBDecodeRGB(&dib, r, g, b); @@ -210,10 +211,10 @@ static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void } else { - char *index; + unsigned char *index; long *colors; - index = (char*)malloc(size); + index = (unsigned char*)malloc(size); colors = (long*)malloc(256*sizeof(long)); cdwDIBDecodeMap(&dib, index, colors); @@ -280,11 +281,11 @@ static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void if (dib.type == 0) { - char *r, *g, *b; + unsigned char *r, *g, *b; - r = (char*)malloc(size); - g = (char*)malloc(size); - b = (char*)malloc(size); + r = (unsigned char*)malloc(size); + g = (unsigned char*)malloc(size); + b = (unsigned char*)malloc(size); cdwDIBDecodeRGB(&dib, r, g, b); @@ -296,10 +297,10 @@ static int cdplay(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void } else { - char *index; + unsigned char *index; long *colors; - index = (char*)malloc(size); + index = (unsigned char*)malloc(size); colors = (long*)malloc(256*sizeof(long)); cdwDIBDecodeMap(&dib, index, colors); diff --git a/src/win32/cdwin.c b/src/win32/cdwin.c index ab8d63e..371bb6d 100644 --- a/src/win32/cdwin.c +++ b/src/win32/cdwin.c @@ -25,7 +25,7 @@ typedef BOOL (CALLBACK* AlphaBlendFunc)( HDC hdcDest, BLENDFUNCTION ftn); static AlphaBlendFunc cdwAlphaBlend = NULL; -static void cdgettextsize (cdCtxCanvas* ctxcanvas, const char *s, int *width, int *height); +static void cdgettextsize (cdCtxCanvas* ctxcanvas, const char *s, int len, int *width, int *height); /* %F Libera memoria e handles alocados pelo driver Windows. @@ -959,7 +959,7 @@ static void cdtransform(cdCtxCanvas *ctxcanvas, const double* matrix) } } -static void sTextOutBlt(cdCtxCanvas* ctxcanvas, int px, int py, const char* s, int n) +static void sTextOutBlt(cdCtxCanvas* ctxcanvas, int px, int py, const char* s, int len) { HDC hBitmapDC; HBITMAP hBitmap, hOldBitmap; @@ -969,7 +969,7 @@ static void sTextOutBlt(cdCtxCanvas* ctxcanvas, int px, int py, const char* s, i double cos_teta = cos(teta); double sin_teta = sin(teta); - cdgettextsize(ctxcanvas, s, &w, &h); + cdgettextsize(ctxcanvas, s, len, &w, &h); wt = w; ht = h; @@ -1133,7 +1133,7 @@ static void sTextOutBlt(cdCtxCanvas* ctxcanvas, int px, int py, const char* s, i SetTextAlign(hBitmapDC, TA_CENTER | TA_BASELINE); hOldFont = SelectObject(hBitmapDC, ctxcanvas->hFont); - TextOut(hBitmapDC, x, y, s, n); + TextOut(hBitmapDC, x, y, s, len); if (ctxcanvas->canvas->invert_yaxis) BitBlt(ctxcanvas->hDC, px, py, w, h, hBitmapDC, 0, 0, ctxcanvas->RopBlt); @@ -1147,11 +1147,11 @@ static void sTextOutBlt(cdCtxCanvas* ctxcanvas, int px, int py, const char* s, i DeleteDC(hBitmapDC); } -static void cdgettextsize (cdCtxCanvas* ctxcanvas, const char *s, int *width, int *height) +static void cdgettextsize (cdCtxCanvas* ctxcanvas, const char *s, int len, int *width, int *height) { SIZE size; - GetTextExtentPoint32(ctxcanvas->hDC, s, (int)strlen(s), &size); + GetTextExtentPoint32(ctxcanvas->hDC, s, len, &size); if (width) *width = size.cx; @@ -1160,12 +1160,12 @@ static void cdgettextsize (cdCtxCanvas* ctxcanvas, const char *s, int *width, in *height = size.cy; } -static void cdwCanvasGetTextHeight(cdCanvas* canvas, int x, int y, const char *s, int *hbox, int *hoff) +static void cdwCanvasGetTextHeight(cdCanvas* canvas, int x, int y, const char *s, int len, int *hbox, int *hoff) { int w, h, ascent, height, baseline; int xmin, xmax, ymin, ymax; - cdgettextsize(canvas->ctxcanvas, s, &w, &h); + cdgettextsize(canvas->ctxcanvas, s, len, &w, &h); cdCanvasGetFontDim(canvas, NULL, &height, &ascent, NULL); baseline = height - ascent; @@ -1202,12 +1202,12 @@ static void cdwCanvasGetTextHeight(cdCanvas* canvas, int x, int y, const char *s *hbox = ymax-ymin+1; } -static void cdwTextTransform(cdCtxCanvas* ctxcanvas, const char* s, int *x, int *y) +static void cdwTextTransform(cdCtxCanvas* ctxcanvas, const char* s, int len, int *x, int *y) { XFORM xForm; int hoff, h; - cdwCanvasGetTextHeight(ctxcanvas->canvas, *x, *y, s, &h, &hoff); + cdwCanvasGetTextHeight(ctxcanvas->canvas, *x, *y, s, len, &h, &hoff); /* move to (x,y) and remove a vertical offset since text reference point is top-left */ xForm.eM11 = (FLOAT)1; @@ -1231,10 +1231,8 @@ static void cdwTextTransform(cdCtxCanvas* ctxcanvas, const char* s, int *x, int *y = 0; } -static void cdtext(cdCtxCanvas* ctxcanvas, int x, int y, const char *s) +static void cdtext(cdCtxCanvas* ctxcanvas, int x, int y, const char *s, int len) { - int n = (int)strlen(s); - if (ctxcanvas->canvas->write_mode == CD_REPLACE || ctxcanvas->wtype == CDW_EMF || ctxcanvas->wtype == CDW_WMF || @@ -1249,7 +1247,7 @@ static void cdtext(cdCtxCanvas* ctxcanvas, int x, int y, const char *s) { /* compensa deficiencia do alinhamento no windows */ int off; - cdgettextsize(ctxcanvas, s, NULL, &h); + cdgettextsize(ctxcanvas, s, len, NULL, &h); off = h/2 - ctxcanvas->font.descent; if (ctxcanvas->canvas->text_orientation != 0) @@ -1268,9 +1266,9 @@ static void cdtext(cdCtxCanvas* ctxcanvas, int x, int y, const char *s) BeginPath(ctxcanvas->hDC); if (ctxcanvas->canvas->use_matrix) - cdwTextTransform(ctxcanvas, s, &x, &y); + cdwTextTransform(ctxcanvas, s, len, &x, &y); - TextOut(ctxcanvas->hDC, x, y+1, s, n); /* compensa erro de desenho com +1 */ + TextOut(ctxcanvas->hDC, x, y+1, s, len); /* compensa erro de desenho com +1 */ if (ctxcanvas->canvas->use_matrix) cdtransform(ctxcanvas, ctxcanvas->canvas->matrix); @@ -1288,7 +1286,7 @@ static void cdtext(cdCtxCanvas* ctxcanvas, int x, int y, const char *s) SetBkMode(ctxcanvas->hDC, OPAQUE); } else - sTextOutBlt(ctxcanvas, x, y+1, s, n); + sTextOutBlt(ctxcanvas, x, y+1, s, len); } static int cdtextalignment(cdCtxCanvas* ctxcanvas, int text_align) diff --git a/src/win32/cdwin.h b/src/win32/cdwin.h index 1f4434f..a8230e7 100644 --- a/src/win32/cdwin.h +++ b/src/win32/cdwin.h @@ -125,8 +125,8 @@ void cdwKillCanvas(cdCtxCanvas* canvas); /* implemented in the wmfmeta.c module */ -void wmfMakePlaceableMetafile(HMETAFILE hmf, char* filename, int w, int h); -void wmfWritePlacebleFile(HANDLE hFile, char* buffer, DWORD dwSize, LONG mm, LONG xExt, LONG yExt); +void wmfMakePlaceableMetafile(HMETAFILE hmf, const char* filename, int w, int h); +void wmfWritePlacebleFile(HANDLE hFile, unsigned char* buffer, DWORD dwSize, LONG mm, LONG xExt, LONG yExt); /* implemented in the wmf_emf.c module */ int cdplayWMF(cdCanvas* canvas, int xmin, int xmax, int ymin, int ymax, void *data); diff --git a/src/win32/wmf_emf.c b/src/win32/wmf_emf.c index 36aeed0..d876874 100644 --- a/src/win32/wmf_emf.c +++ b/src/win32/wmf_emf.c @@ -1083,11 +1083,11 @@ static int CALLBACK EMFEnumProc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETAREC if (dib.type == 0) { - char *r, *g, *b; + unsigned char *r, *g, *b; - r = (char*)malloc(size); - g = (char*)malloc(size); - b = (char*)malloc(size); + r = (unsigned char*)malloc(size); + g = (unsigned char*)malloc(size); + b = (unsigned char*)malloc(size); cdwDIBDecodeRGB(&dib, r, g, b); @@ -1099,10 +1099,10 @@ static int CALLBACK EMFEnumProc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETAREC } else { - char *index; + unsigned char *index; long *colors; - index = (char*)malloc(size); + index = (unsigned char*)malloc(size); colors = (long*)malloc(256*sizeof(long)); cdwDIBDecodeMap(&dib, index, colors); @@ -1137,11 +1137,11 @@ static int CALLBACK EMFEnumProc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETAREC if (dib.type == 0) { - char *r, *g, *b; + unsigned char *r, *g, *b; - r = (char*)malloc(size); - g = (char*)malloc(size); - b = (char*)malloc(size); + r = (unsigned char*)malloc(size); + g = (unsigned char*)malloc(size); + b = (unsigned char*)malloc(size); cdwDIBDecodeRGB(&dib, r, g, b); @@ -1153,10 +1153,10 @@ static int CALLBACK EMFEnumProc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETAREC } else { - char *index; + unsigned char *index; long *colors; - index = (char*)malloc(size); + index = (unsigned char*)malloc(size); colors = (long*)malloc(256*sizeof(long)); cdwDIBDecodeMap(&dib, index, colors); @@ -1191,11 +1191,11 @@ static int CALLBACK EMFEnumProc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETAREC if (dib.type == 0) { - char *r, *g, *b; + unsigned char *r, *g, *b; - r = (char*)malloc(size); - g = (char*)malloc(size); - b = (char*)malloc(size); + r = (unsigned char*)malloc(size); + g = (unsigned char*)malloc(size); + b = (unsigned char*)malloc(size); cdwDIBDecodeRGB(&dib, r, g, b); @@ -1207,10 +1207,10 @@ static int CALLBACK EMFEnumProc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETAREC } else { - char *index; + unsigned char *index; long *colors; - index = (char*)malloc(size); + index = (unsigned char*)malloc(size); colors = (long*)malloc(256*sizeof(long)); cdwDIBDecodeMap(&dib, index, colors); @@ -1239,11 +1239,11 @@ static int CALLBACK EMFEnumProc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETAREC if (dib.type == 0) { - char *r, *g, *b; + unsigned char *r, *g, *b; - r = (char*)malloc(size); - g = (char*)malloc(size); - b = (char*)malloc(size); + r = (unsigned char*)malloc(size); + g = (unsigned char*)malloc(size); + b = (unsigned char*)malloc(size); cdwDIBDecodeRGB(&dib, r, g, b); @@ -1255,10 +1255,10 @@ static int CALLBACK EMFEnumProc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETAREC } else { - char *index; + unsigned char *index; long *colors; - index = (char*)malloc(size); + index = (unsigned char*)malloc(size); colors = (long*)malloc(256*sizeof(long)); cdwDIBDecodeMap(&dib, index, colors); @@ -1285,11 +1285,11 @@ static int CALLBACK EMFEnumProc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETAREC if (dib.type == 0) { - char *r, *g, *b; + unsigned char *r, *g, *b; - r = (char*)malloc(size); - g = (char*)malloc(size); - b = (char*)malloc(size); + r = (unsigned char*)malloc(size); + g = (unsigned char*)malloc(size); + b = (unsigned char*)malloc(size); cdwDIBDecodeRGB(&dib, r, g, b); @@ -1301,10 +1301,10 @@ static int CALLBACK EMFEnumProc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETAREC } else { - char *index; + unsigned char *index; long *colors; - index = (char*)malloc(size); + index = (unsigned char*)malloc(size); colors = (long*)malloc(256*sizeof(long)); cdwDIBDecodeMap(&dib, index, colors); @@ -1549,11 +1549,11 @@ static int CALLBACK EMFEnumProc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETAREC if (dib.type == 0) { - char *r, *g, *b; + unsigned char *r, *g, *b; - r = (char*)malloc(size); - g = (char*)malloc(size); - b = (char*)malloc(size); + r = (unsigned char*)malloc(size); + g = (unsigned char*)malloc(size); + b = (unsigned char*)malloc(size); cdwDIBDecodeRGB(&dib, r, g, b); @@ -1623,11 +1623,11 @@ static int CALLBACK EMFEnumProc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETAREC if (dib.type == 0) { - char *r, *g, *b; + unsigned char *r, *g, *b; - r = (char*)malloc(size); - g = (char*)malloc(size); - b = (char*)malloc(size); + r = (unsigned char*)malloc(size); + g = (unsigned char*)malloc(size); + b = (unsigned char*)malloc(size); cdwDIBDecodeRGB(&dib, r, g, b); @@ -1640,10 +1640,10 @@ static int CALLBACK EMFEnumProc(HDC hDC, HANDLETABLE *lpHTable, const ENHMETAREC } else { - char *index; + unsigned char *index; long *colors; - index = (char*)malloc(size); + index = (unsigned char*)malloc(size); colors = (long*)malloc(256*sizeof(long)); cdwDIBDecodeMap(&dib, index, colors); @@ -2058,7 +2058,7 @@ Aldus placeable metafile format /* %F Cria um APM em arquivo a partir de um WMF em memoria. */ -void wmfMakePlaceableMetafile(HMETAFILE hmf, char* filename, int w, int h) +void wmfMakePlaceableMetafile(HMETAFILE hmf, const char* filename, int w, int h) { int fh, nSize; LPSTR lpData; @@ -2090,7 +2090,7 @@ void wmfMakePlaceableMetafile(HMETAFILE hmf, char* filename, int w, int h) close(fh); } -void wmfWritePlacebleFile(HANDLE hFile, char* buffer, DWORD dwSize, LONG mm, LONG xExt, LONG yExt) +void wmfWritePlacebleFile(HANDLE hFile, unsigned char* buffer, DWORD dwSize, LONG mm, LONG xExt, LONG yExt) { DWORD nBytesWrite; APMFILEHEADER APMHeader; |