[MSPAINT]

- Fix MSVC warnings

svn path=/trunk/; revision=52455
This commit is contained in:
Rafal Harabien 2011-06-25 14:34:52 +00:00
parent b55c5995a4
commit fa74282a41
7 changed files with 65 additions and 64 deletions

View file

@ -13,7 +13,7 @@
/* FUNCTIONS ********************************************************/ /* FUNCTIONS ********************************************************/
void void
Line(HDC hdc, short x1, short y1, short x2, short y2, int color, int thickness) Line(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, int thickness)
{ {
HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, color)); HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, color));
MoveToEx(hdc, x1, y1, NULL); MoveToEx(hdc, x1, y1, NULL);
@ -22,7 +22,7 @@ Line(HDC hdc, short x1, short y1, short x2, short y2, int color, int thickness)
} }
void void
Rect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style) Rect(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, int thickness, int style)
{ {
HBRUSH oldBrush; HBRUSH oldBrush;
LOGBRUSH logbrush; LOGBRUSH logbrush;
@ -37,7 +37,7 @@ Rect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickn
} }
void void
Ellp(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style) Ellp(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, int thickness, int style)
{ {
HBRUSH oldBrush; HBRUSH oldBrush;
LOGBRUSH logbrush; LOGBRUSH logbrush;
@ -52,7 +52,7 @@ Ellp(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickn
} }
void void
RRect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style) RRect(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, int thickness, int style)
{ {
LOGBRUSH logbrush; LOGBRUSH logbrush;
HBRUSH oldBrush; HBRUSH oldBrush;
@ -67,7 +67,7 @@ RRect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thick
} }
void void
Poly(HDC hdc, POINT * lpPoints, int nCount, int fg, int bg, int thickness, int style, BOOL closed) Poly(HDC hdc, POINT * lpPoints, int nCount, COLORREF fg, COLORREF bg, int thickness, int style, BOOL closed)
{ {
LOGBRUSH logbrush; LOGBRUSH logbrush;
HBRUSH oldBrush; HBRUSH oldBrush;
@ -85,7 +85,7 @@ Poly(HDC hdc, POINT * lpPoints, int nCount, int fg, int bg, int thickness, int s
} }
void void
Bezier(HDC hdc, POINT p1, POINT p2, POINT p3, POINT p4, int color, int thickness) Bezier(HDC hdc, POINT p1, POINT p2, POINT p3, POINT p4, COLORREF color, int thickness)
{ {
HPEN oldPen; HPEN oldPen;
POINT fourPoints[4]; POINT fourPoints[4];
@ -99,7 +99,7 @@ Bezier(HDC hdc, POINT p1, POINT p2, POINT p3, POINT p4, int color, int thickness
} }
void void
Fill(HDC hdc, int x, int y, int color) Fill(HDC hdc, LONG x, LONG y, COLORREF color)
{ {
HBRUSH oldBrush = SelectObject(hdc, CreateSolidBrush(color)); HBRUSH oldBrush = SelectObject(hdc, CreateSolidBrush(color));
ExtFloodFill(hdc, x, y, GetPixel(hdc, x, y), FLOODFILLSURFACE); ExtFloodFill(hdc, x, y, GetPixel(hdc, x, y), FLOODFILLSURFACE);
@ -107,7 +107,7 @@ Fill(HDC hdc, int x, int y, int color)
} }
void void
Erase(HDC hdc, short x1, short y1, short x2, short y2, int color, int radius) Erase(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG radius)
{ {
short a; short a;
HPEN oldPen; HPEN oldPen;
@ -122,9 +122,10 @@ Erase(HDC hdc, short x1, short y1, short x2, short y2, int color, int radius)
} }
void void
Replace(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int radius) Replace(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LONG radius)
{ {
short a, x, y; LONG a, x, y;
for(a = 0; a <= 100; a++) for(a = 0; a <= 100; a++)
for(y = (y1 * (100 - a) + y2 * a) / 100 - radius + 1; for(y = (y1 * (100 - a) + y2 * a) / 100 - radius + 1;
y < (y1 * (100 - a) + y2 * a) / 100 + radius + 1; y++) y < (y1 * (100 - a) + y2 * a) / 100 + radius + 1; y++)
@ -135,10 +136,10 @@ Replace(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int rad
} }
void void
Airbrush(HDC hdc, short x, short y, int color, int r) Airbrush(HDC hdc, LONG x, LONG y, COLORREF color, LONG r)
{ {
short a; LONG a, b;
short b;
for(b = -r; b <= r; b++) for(b = -r; b <= r; b++)
for(a = -r; a <= r; a++) for(a = -r; a <= r; a++)
if ((a * a + b * b <= r * r) && (rand() % 4 == 0)) if ((a * a + b * b <= r * r) && (rand() % 4 == 0))
@ -146,7 +147,7 @@ Airbrush(HDC hdc, short x, short y, int color, int r)
} }
void void
Brush(HDC hdc, short x1, short y1, short x2, short y2, int color, int style) Brush(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, COLORREF style)
{ {
HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 1, color)); HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 1, color));
HBRUSH oldBrush = SelectObject(hdc, CreateSolidBrush(color)); HBRUSH oldBrush = SelectObject(hdc, CreateSolidBrush(color));
@ -231,7 +232,7 @@ Brush(HDC hdc, short x1, short y1, short x2, short y2, int color, int style)
} }
void void
RectSel(HDC hdc, short x1, short y1, short x2, short y2) RectSel(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2)
{ {
HBRUSH oldBrush; HBRUSH oldBrush;
LOGBRUSH logbrush; LOGBRUSH logbrush;
@ -246,7 +247,7 @@ RectSel(HDC hdc, short x1, short y1, short x2, short y2)
} }
void void
SelectionFrame(HDC hdc, int x1, int y1, int x2, int y2) SelectionFrame(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2)
{ {
HBRUSH oldBrush; HBRUSH oldBrush;
LOGBRUSH logbrush; LOGBRUSH logbrush;

View file

@ -6,28 +6,28 @@
* PROGRAMMERS: Benedikt Freisen * PROGRAMMERS: Benedikt Freisen
*/ */
void Line(HDC hdc, short x1, short y1, short x2, short y2, int color, int thickness); void Line(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, int thickness);
void Rect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style); void Rect(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, int thickness, int style);
void Ellp(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style); void Ellp(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, int thickness, int style);
void RRect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style); void RRect(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, int thickness, int style);
void Poly(HDC hdc, POINT *lpPoints, int nCount, int fg, int bg, int thickness, int style, BOOL closed); void Poly(HDC hdc, POINT *lpPoints, int nCount, COLORREF fg, COLORREF bg, int thickness, int style, BOOL closed);
void Bezier(HDC hdc, POINT p1, POINT p2, POINT p3, POINT p4, int color, int thickness); void Bezier(HDC hdc, POINT p1, POINT p2, POINT p3, POINT p4, COLORREF color, int thickness);
void Fill(HDC hdc, int x, int y, int color); void Fill(HDC hdc, LONG x, LONG y, COLORREF color);
void Erase(HDC hdc, short x1, short y1, short x2, short y2, int color, int radius); void Erase(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG radius);
void Replace(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int radius); void Replace(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LONG radius);
void Airbrush(HDC hdc, short x, short y, int color, int r); void Airbrush(HDC hdc, LONG x, LONG y, COLORREF color, LONG r);
void Brush(HDC hdc, short x1, short y1, short x2, short y2, int color, int style); void Brush(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, int style);
void RectSel(HDC hdc, short x1, short y1, short x2, short y2); void RectSel(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2);
void SelectionFrame(HDC hdc, int x1, int y1, int x2, int y2); void SelectionFrame(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2);

View file

@ -26,10 +26,10 @@ extern int undoSteps;
extern int redoSteps; extern int redoSteps;
extern BOOL imageSaved; extern BOOL imageSaved;
extern short startX; extern LONG startX;
extern short startY; extern LONG startY;
extern short lastX; extern LONG lastX;
extern short lastY; extern LONG lastY;
extern int lineWidth; extern int lineWidth;
extern int shapeStyle; extern int shapeStyle;
extern int brushStyle; extern int brushStyle;

View file

@ -43,10 +43,10 @@ int undoSteps = 0;
int redoSteps = 0; int redoSteps = 0;
BOOL imageSaved = TRUE; BOOL imageSaved = TRUE;
short startX; LONG startX;
short startY; LONG startY;
short lastX; LONG lastX;
short lastY; LONG lastY;
int lineWidth = 1; int lineWidth = 1;
int shapeStyle = 0; int shapeStyle = 0;
int brushStyle = 0; int brushStyle = 0;

View file

@ -26,7 +26,7 @@ placeSelWin()
} }
void void
regularize(short x0, short y0, short *x1, short *y1) regularize(LONG x0, LONG y0, LONG *x1, LONG *y1)
{ {
if (abs(*x1 - x0) >= abs(*y1 - y0)) if (abs(*x1 - x0) >= abs(*y1 - y0))
*y1 = y0 + (*y1 > y0 ? abs(*x1 - x0) : -abs(*x1 - x0)); *y1 = y0 + (*y1 > y0 ? abs(*x1 - x0) : -abs(*x1 - x0));
@ -35,7 +35,7 @@ regularize(short x0, short y0, short *x1, short *y1)
} }
void void
roundTo8Directions(short x0, short y0, short *x1, short *y1) roundTo8Directions(LONG x0, LONG y0, LONG *x1, LONG *y1)
{ {
if (abs(*x1 - x0) >= abs(*y1 - y0)) if (abs(*x1 - x0) >= abs(*y1 - y0))
{ {
@ -59,7 +59,7 @@ POINT *ptStack = NULL;
int ptSP = 0; int ptSP = 0;
void void
startPaintingL(HDC hdc, short x, short y, int fg, int bg) startPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{ {
startX = x; startX = x;
startY = y; startY = y;
@ -132,7 +132,7 @@ startPaintingL(HDC hdc, short x, short y, int fg, int bg)
} }
void void
whilePaintingL(HDC hdc, short x, short y, int fg, int bg) whilePaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{ {
switch (activeTool) switch (activeTool)
{ {
@ -149,8 +149,8 @@ whilePaintingL(HDC hdc, short x, short y, int fg, int bg)
break; break;
case TOOL_RECTSEL: case TOOL_RECTSEL:
{ {
short tempX; int tempX;
short tempY; int tempY;
resetToU1(); resetToU1();
tempX = max(0, min(x, imgXRes)); tempX = max(0, min(x, imgXRes));
tempY = max(0, min(y, imgYRes)); tempY = max(0, min(y, imgYRes));
@ -209,7 +209,7 @@ whilePaintingL(HDC hdc, short x, short y, int fg, int bg)
pointStack[pointSP].y = y; pointStack[pointSP].y = y;
if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0)) if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0))
roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y, roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
(short *)&pointStack[pointSP].x, (short *)&pointStack[pointSP].y); &pointStack[pointSP].x, &pointStack[pointSP].y);
if (pointSP + 1 >= 2) if (pointSP + 1 >= 2)
Poly(hdc, pointStack, pointSP + 1, fg, bg, lineWidth, shapeStyle, FALSE); Poly(hdc, pointStack, pointSP + 1, fg, bg, lineWidth, shapeStyle, FALSE);
break; break;
@ -232,7 +232,7 @@ whilePaintingL(HDC hdc, short x, short y, int fg, int bg)
} }
void void
endPaintingL(HDC hdc, short x, short y, int fg, int bg) endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{ {
switch (activeTool) switch (activeTool)
{ {
@ -350,7 +350,7 @@ endPaintingL(HDC hdc, short x, short y, int fg, int bg)
pointStack[pointSP].y = y; pointStack[pointSP].y = y;
if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0)) if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0))
roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y, roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
(short *)&pointStack[pointSP].x, (short *)&pointStack[pointSP].y); &pointStack[pointSP].x, &pointStack[pointSP].y);
pointSP++; pointSP++;
if (pointSP >= 2) if (pointSP >= 2)
{ {
@ -384,7 +384,7 @@ endPaintingL(HDC hdc, short x, short y, int fg, int bg)
} }
void void
startPaintingR(HDC hdc, short x, short y, int fg, int bg) startPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{ {
startX = x; startX = x;
startY = y; startY = y;
@ -444,7 +444,7 @@ startPaintingR(HDC hdc, short x, short y, int fg, int bg)
} }
void void
whilePaintingR(HDC hdc, short x, short y, int fg, int bg) whilePaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{ {
switch (activeTool) switch (activeTool)
{ {
@ -496,7 +496,7 @@ whilePaintingR(HDC hdc, short x, short y, int fg, int bg)
pointStack[pointSP].y = y; pointStack[pointSP].y = y;
if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0)) if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0))
roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y, roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
(short *)&pointStack[pointSP].x, (short *)&pointStack[pointSP].y); &pointStack[pointSP].x, &pointStack[pointSP].y);
if (pointSP + 1 >= 2) if (pointSP + 1 >= 2)
Poly(hdc, pointStack, pointSP + 1, bg, fg, lineWidth, shapeStyle, FALSE); Poly(hdc, pointStack, pointSP + 1, bg, fg, lineWidth, shapeStyle, FALSE);
break; break;
@ -519,7 +519,7 @@ whilePaintingR(HDC hdc, short x, short y, int fg, int bg)
} }
void void
endPaintingR(HDC hdc, short x, short y, int fg, int bg) endPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{ {
switch (activeTool) switch (activeTool)
{ {
@ -553,7 +553,7 @@ endPaintingR(HDC hdc, short x, short y, int fg, int bg)
pointStack[pointSP].y = y; pointStack[pointSP].y = y;
if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0)) if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0))
roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y, roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
(short *)&pointStack[pointSP].x, (short *)&pointStack[pointSP].y); &pointStack[pointSP].x, &pointStack[pointSP].y);
pointSP++; pointSP++;
if (pointSP >= 2) if (pointSP >= 2)
{ {

View file

@ -8,14 +8,14 @@
void placeSelWin(void); void placeSelWin(void);
void startPaintingL(HDC hdc, short x, short y, int fg, int bg); void startPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg);
void whilePaintingL(HDC hdc, short x, short y, int fg, int bg); void whilePaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg);
void endPaintingL(HDC hdc, short x, short y, int fg, int bg); void endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg);
void startPaintingR(HDC hdc, short x, short y, int fg, int bg); void startPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg);
void whilePaintingR(HDC hdc, short x, short y, int fg, int bg); void whilePaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg);
void endPaintingR(HDC hdc, short x, short y, int fg, int bg); void endPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg);

View file

@ -503,7 +503,7 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
SendMessage(hImageArea, WM_PAINT, 0, 0); SendMessage(hImageArea, WM_PAINT, 0, 0);
if ((activeTool == TOOL_ZOOM) && (zoom < 8000)) if ((activeTool == TOOL_ZOOM) && (zoom < 8000))
zoomTo(zoom * 2, (short)LOWORD(lParam), (short)HIWORD(lParam)); zoomTo(zoom * 2, LOWORD(lParam), HIWORD(lParam));
} }
break; break;
@ -524,7 +524,7 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
SendMessage(hImageArea, WM_PAINT, 0, 0); SendMessage(hImageArea, WM_PAINT, 0, 0);
if ((activeTool == TOOL_ZOOM) && (zoom > 125)) if ((activeTool == TOOL_ZOOM) && (zoom > 125))
zoomTo(zoom / 2, (short)LOWORD(lParam), (short)HIWORD(lParam)); zoomTo(zoom / 2, LOWORD(lParam), HIWORD(lParam));
} }
break; break;
@ -589,8 +589,8 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
if (hwnd == hImageArea) if (hwnd == hImageArea)
{ {
short xNow = (short)LOWORD(lParam) * 1000 / zoom; LONG xNow = LOWORD(lParam) * 1000 / zoom;
short yNow = (short)HIWORD(lParam) * 1000 / zoom; LONG yNow = HIWORD(lParam) * 1000 / zoom;
if ((!drawing) || (activeTool <= TOOL_AIRBRUSH)) if ((!drawing) || (activeTool <= TOOL_AIRBRUSH))
{ {
TRACKMOUSEEVENT tme; TRACKMOUSEEVENT tme;
@ -598,7 +598,7 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
if (activeTool == TOOL_ZOOM) if (activeTool == TOOL_ZOOM)
{ {
SendMessage(hImageArea, WM_PAINT, 0, 0); SendMessage(hImageArea, WM_PAINT, 0, 0);
drawZoomFrame((short)LOWORD(lParam), (short)HIWORD(lParam)); drawZoomFrame(LOWORD(lParam), HIWORD(lParam));
} }
tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.cbSize = sizeof(TRACKMOUSEEVENT);
@ -617,8 +617,8 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
if (drawing) if (drawing)
{ {
/* values displayed in statusbar */ /* values displayed in statusbar */
short xRel = xNow - startX; LONG xRel = xNow - startX;
short yRel = yNow - startY; LONG yRel = yNow - startY;
/* freesel, rectsel and text tools always show numbers limited to fit into image area */ /* freesel, rectsel and text tools always show numbers limited to fit into image area */
if ((activeTool == TOOL_FREESEL) || (activeTool == TOOL_RECTSEL) || (activeTool == TOOL_TEXT)) if ((activeTool == TOOL_FREESEL) || (activeTool == TOOL_RECTSEL) || (activeTool == TOOL_TEXT))
{ {