MoveWindow(hSelection, rectSel_dest[0] * zoom / 1000, rectSel_dest[1] * zoom / 1000,
rectSel_dest[2] * zoom / 1000 + 6, rectSel_dest[3] * zoom / 1000 + 6, TRUE);
BringWindowToTop(hSelection);
- SendMessage(hImageArea, WM_PAINT, 0, 0);
- //SendMessage(hSelection, WM_PAINT, 0, 0);
+ InvalidateRect(hImageArea, NULL, FALSE);
}
void
void
startPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{
- startX = x;
- startY = y;
- lastX = x;
- lastY = y;
+ start.x = x;
+ start.y = y;
+ last.x = x;
+ last.y = y;
switch (activeTool)
{
case TOOL_FREESEL:
break;
case TOOL_RECTSEL:
{
- int tempX;
- int tempY;
+ POINT temp;
resetToU1();
- tempX = max(0, min(x, imgXRes));
- tempY = max(0, min(y, imgYRes));
- rectSel_dest[0] = rectSel_src[0] = min(startX, tempX);
- rectSel_dest[1] = rectSel_src[1] = min(startY, tempY);
- rectSel_dest[2] = rectSel_src[2] = max(startX, tempX) - min(startX, tempX);
- rectSel_dest[3] = rectSel_src[3] = max(startY, tempY) - min(startY, tempY);
- RectSel(hdc, startX, startY, tempX, tempY);
+ temp.x = max(0, min(x, imgXRes));
+ temp.y = max(0, min(y, imgYRes));
+ rectSel_dest[0] = rectSel_src[0] = min(start.x, temp.x);
+ rectSel_dest[1] = rectSel_src[1] = min(start.y, temp.y);
+ rectSel_dest[2] = rectSel_src[2] = max(start.x, temp.x) - min(start.x, temp.x);
+ rectSel_dest[3] = rectSel_src[3] = max(start.y, temp.y) - min(start.y, temp.y);
+ RectSel(hdc, start.x, start.y, temp.x, temp.y);
break;
}
case TOOL_RUBBER:
- Erase(hdc, lastX, lastY, x, y, bg, rubberRadius);
+ Erase(hdc, last.x, last.y, x, y, bg, rubberRadius);
break;
case TOOL_PEN:
- Line(hdc, lastX, lastY, x, y, fg, 1);
+ Line(hdc, last.x, last.y, x, y, fg, 1);
break;
case TOOL_BRUSH:
- Brush(hdc, lastX, lastY, x, y, fg, brushStyle);
+ Brush(hdc, last.x, last.y, x, y, fg, brushStyle);
break;
case TOOL_AIRBRUSH:
Airbrush(hdc, x, y, fg, airBrushWidth);
case TOOL_LINE:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
- roundTo8Directions(startX, startY, &x, &y);
- Line(hdc, startX, startY, x, y, fg, lineWidth);
+ roundTo8Directions(start.x, start.y, &x, &y);
+ Line(hdc, start.x, start.y, x, y, fg, lineWidth);
break;
case TOOL_BEZIER:
resetToU1();
case TOOL_RECT:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
- regularize(startX, startY, &x, &y);
- Rect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
+ regularize(start.x, start.y, &x, &y);
+ Rect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
break;
case TOOL_SHAPE:
resetToU1();
case TOOL_ELLIPSE:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
- regularize(startX, startY, &x, &y);
- Ellp(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
+ regularize(start.x, start.y, &x, &y);
+ Ellp(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
break;
case TOOL_RRECT:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
- regularize(startX, startY, &x, &y);
- RRect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
+ regularize(start.x, start.y, &x, &y);
+ RRect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
break;
}
- lastX = x;
- lastY = y;
+ last.x = x;
+ last.y = y;
}
void
}
break;
case TOOL_RUBBER:
- Erase(hdc, lastX, lastY, x, y, bg, rubberRadius);
+ Erase(hdc, last.x, last.y, x, y, bg, rubberRadius);
break;
case TOOL_PEN:
- Line(hdc, lastX, lastY, x, y, fg, 1);
+ Line(hdc, last.x, last.y, x, y, fg, 1);
SetPixel(hdc, x, y, fg);
break;
case TOOL_LINE:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
- roundTo8Directions(startX, startY, &x, &y);
- Line(hdc, startX, startY, x, y, fg, lineWidth);
+ roundTo8Directions(start.x, start.y, &x, &y);
+ Line(hdc, start.x, start.y, x, y, fg, lineWidth);
break;
case TOOL_BEZIER:
pointSP++;
case TOOL_RECT:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
- regularize(startX, startY, &x, &y);
- Rect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
+ regularize(start.x, start.y, &x, &y);
+ Rect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
break;
case TOOL_SHAPE:
resetToU1();
case TOOL_ELLIPSE:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
- regularize(startX, startY, &x, &y);
- Ellp(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
+ regularize(start.x, start.y, &x, &y);
+ Ellp(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
break;
case TOOL_RRECT:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
- regularize(startX, startY, &x, &y);
- RRect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle);
+ regularize(start.x, start.y, &x, &y);
+ RRect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
break;
}
}
void
startPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{
- startX = x;
- startY = y;
- lastX = x;
- lastY = y;
+ start.x = x;
+ start.y = y;
+ last.x = x;
+ last.y = y;
switch (activeTool)
{
case TOOL_FREESEL:
switch (activeTool)
{
case TOOL_RUBBER:
- Replace(hdc, lastX, lastY, x, y, fg, bg, rubberRadius);
+ Replace(hdc, last.x, last.y, x, y, fg, bg, rubberRadius);
break;
case TOOL_PEN:
- Line(hdc, lastX, lastY, x, y, bg, 1);
+ Line(hdc, last.x, last.y, x, y, bg, 1);
break;
case TOOL_BRUSH:
- Brush(hdc, lastX, lastY, x, y, bg, brushStyle);
+ Brush(hdc, last.x, last.y, x, y, bg, brushStyle);
break;
case TOOL_AIRBRUSH:
Airbrush(hdc, x, y, bg, airBrushWidth);
case TOOL_LINE:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
- roundTo8Directions(startX, startY, &x, &y);
- Line(hdc, startX, startY, x, y, bg, lineWidth);
+ roundTo8Directions(start.x, start.y, &x, &y);
+ Line(hdc, start.x, start.y, x, y, bg, lineWidth);
break;
case TOOL_BEZIER:
resetToU1();
case TOOL_RECT:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
- regularize(startX, startY, &x, &y);
- Rect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
+ regularize(start.x, start.y, &x, &y);
+ Rect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
break;
case TOOL_SHAPE:
resetToU1();
case TOOL_ELLIPSE:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
- regularize(startX, startY, &x, &y);
- Ellp(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
+ regularize(start.x, start.y, &x, &y);
+ Ellp(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
break;
case TOOL_RRECT:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
- regularize(startX, startY, &x, &y);
- RRect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
+ regularize(start.x, start.y, &x, &y);
+ RRect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
break;
}
- lastX = x;
- lastY = y;
+ last.x = x;
+ last.y = y;
}
void
switch (activeTool)
{
case TOOL_RUBBER:
- Replace(hdc, lastX, lastY, x, y, fg, bg, rubberRadius);
+ Replace(hdc, last.x, last.y, x, y, fg, bg, rubberRadius);
break;
case TOOL_PEN:
- Line(hdc, lastX, lastY, x, y, bg, 1);
+ Line(hdc, last.x, last.y, x, y, bg, 1);
SetPixel(hdc, x, y, bg);
break;
case TOOL_LINE:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
- roundTo8Directions(startX, startY, &x, &y);
- Line(hdc, startX, startY, x, y, bg, lineWidth);
+ roundTo8Directions(start.x, start.y, &x, &y);
+ Line(hdc, start.x, start.y, x, y, bg, lineWidth);
break;
case TOOL_BEZIER:
pointSP++;
case TOOL_RECT:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
- regularize(startX, startY, &x, &y);
- Rect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
+ regularize(start.x, start.y, &x, &y);
+ Rect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
break;
case TOOL_SHAPE:
resetToU1();
case TOOL_ELLIPSE:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
- regularize(startX, startY, &x, &y);
- Ellp(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
+ regularize(start.x, start.y, &x, &y);
+ Ellp(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
break;
case TOOL_RRECT:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
- regularize(startX, startY, &x, &y);
- RRect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle);
+ regularize(start.x, start.y, &x, &y);
+ RRect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
break;
}
}