18 const INT diameter = 2 * radius;
25 const INT crosshair1 = 6, crosshair2 = crosshair1 - 2;
26 const INT width = diameter + 2 * crosshair1,
height = diameter + 2 * crosshair1;
90 COLORREF color2 = (avg > 255 / 2) ?
RGB(0, 0, 0) :
RGB(255, 255, 255);
91 Erase(
hdcMem, hotX, hotY, hotX, hotY, color2, radius + 1);
146CCanvasWindow::CCanvasWindow()
149 , m_ptOrig { -1, -1 }
151 m_rcResizing.SetRectEmpty();
215 LONG cxView = rcView.
right * oldZoom / newZoom, cyView = rcView.
bottom * oldZoom / newZoom;
216 rcView.
SetRect(ptTarget.
x - cxView / 2, ptTarget.
y - cyView / 2,
217 ptTarget.
x + cxView / 2, ptTarget.
y + cyView / 2);
225 if (rcView.
top < rcImage.
top)
283 CRect rcImageDraw = rcCanvasDraw;
288 rcImageDraw.
right += 1;
303 hdcMem1, 0, 0, sizeImage.
cx, sizeImage.
cy,
SRCCOPY);
365 if (sizePage.
cx < sizeWhole.
cx || sizePage.
cy < sizeWhole.
cy)
374 si.nMax = sizeWhole.
cx;
375 si.nPage = sizePage.
cx;
378 si.nMax = sizeWhole.
cy;
379 si.nPage = sizePage.
cy;
613 cxImage =
max(1, cxImage);
614 cyImage =
max(1, cyImage);
620 strSize.
Format(
L"%d x %d", cxImage, cyImage);
624 CRect rcResizing = { 0, 0, cxImage, cyImage };
681 imageModel.
Crop(cxImage - cxDelta, cyImage - cyDelta, cxDelta, cyDelta);
687 imageModel.
Crop(cxImage + cxDelta, cyImage - cyDelta, 0, cyDelta);
696 imageModel.
Crop(cxImage - cxDelta, cyImage + cyDelta, cxDelta, 0);
848 static BOOL s_bShowedOutOfMemory =
FALSE;
855 s_bShowedOutOfMemory =
FALSE;
857 else if (!s_bShowedOutOfMemory)
860 s_bShowedOutOfMemory =
TRUE;
void ShowOutOfMemory(void)
SelectionModel selectionModel
CTextEditWindow textEditWindow
CCanvasWindow canvasWindow
void __cdecl Format(UINT nFormatID,...)
VOID OnHVScroll(WPARAM wParam, INT fnBar)
VOID OnEndDraw(BOOL bCancel)
LRESULT OnEraseBkgnd(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
CStyledCursor m_hRubberCursor
CStyledCursor m_hBrushCursor
LRESULT OnCaptureChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
HITTEST m_hitCanvasSizeBox
LRESULT OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
VOID ImageToCanvas(POINT &pt)
LRESULT OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnCancelMode(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
VOID CanvasToImage(POINT &pt)
VOID updateScrollPos(INT x=0, INT y=0)
HITTEST CanvasHitTest(POINT pt)
LRESULT OnButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnHScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
BOOL DoDraw(HDC hDC, RECT &rcClient, RECT &rcPaint)
VOID GetImageRect(RECT &rc)
LRESULT OnButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
VOID getNewZoomRect(CRect &rcView, INT newZoom, CPoint ptTarget)
LRESULT OnCtlColorEdit(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
VOID zoomTo(INT newZoom, LONG left=0, LONG top=0)
LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
void SetRectEmpty() noexcept
BOOL IntersectRect(LPCRECT lpRect1, LPCRECT lpRect2) noexcept
void InflateRect(int x, int y) noexcept
void OffsetRect(int x, int y) noexcept
BOOL PtInRect(POINT point) const noexcept
void SetRect(int x1, int y1, int x2, int y2) noexcept
int Width() const noexcept
int Height() const noexcept
BOOL IsRectEmpty() const noexcept
static HCURSOR CreateStyledCursor(BrushStyle style, INT radius, COLORREF color, BOOL is_rubber)
void SetStyle(BrushStyle style, INT radius, COLORREF color, BOOL is_rubber)
void NotifyImageChanged()
void Crop(int nWidth, int nHeight, int nOffsetX=0, int nOffsetY=0)
COLORREF GetBgColor() const
COLORREF GetFgColor() const
HITTEST hitTest(POINT ptCanvas)
HBITMAP CreateDIBWithProperties(int width, int height)
void DrawXorRect(HDC hdc, const RECT *prc)
void Erase(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG radius)
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Height *Stride) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Stride)
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
GLint GLint GLsizei GLsizei height
GLint GLint GLsizei width
GLdouble GLdouble GLdouble GLdouble top
PaletteModel paletteModel
BOOL setCursorOnSizeBox(HITTEST hit)
VOID drawSizeBoxes(HDC hdc, LPCRECT prcBase, BOOL bDrawFrame, LPCRECT prcPaint)
HITTEST getSizeBoxHitTest(POINT pt, LPCRECT prcBase)
HGDIOBJ WINAPI GetStockObject(_In_ int)
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
BOOL WINAPI DeleteDC(_In_ HDC)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
HWND WINAPI SetCapture(_In_ HWND hWnd)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HICON WINAPI CreateIconIndirect(_In_ PICONINFO)
BOOL WINAPI DestroyCursor(_In_ HCURSOR)
BOOL WINAPI ReleaseCapture(void)
struct tagSCROLLINFO SCROLLINFO
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
HWND WINAPI GetCapture(void)
BOOL WINAPI TrackMouseEvent(_Inout_ LPTRACKMOUSEEVENT)
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
int WINAPI SetScrollPos(_In_ HWND, _In_ int, _In_ int, _In_ BOOL)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define COLOR_APPWORKSPACE
HDC WINAPI GetDC(_In_opt_ HWND)
HWND WINAPI GetParent(_In_ HWND)
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
BOOL WINAPI ShowScrollBar(_In_ HWND, _In_ int, _In_ BOOL)
int WINAPI GetScrollPos(_In_ HWND, _In_ int)
#define MAKEINTRESOURCEW(i)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
BOOL WINAPI IsWindowVisible(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)