/*[]=====================================================================[]*/ /*[] LEADTOOLS for Windows - []*/ /*[] []*/ /*[] []*/ /*[] Copyright (c) 1991-2000 LEAD Technologies, Inc. []*/ /*[] All Rights Reserved. []*/ /*[]=====================================================================[]*/ #ifndef UNREFERENCED_PARAMETER #define UNREFERENCED_PARAMETER(P) \ { \ (P) = (P); \ } #endif /* maximum path name length */ #define MAXFILENAME _MAX_PATH /* maximum number of points in a freehand region */ #define MAXPOINTS 32767 #define SCROLL_RATIO 10 #ifdef WIN32 #define HWNDCTL(w, l) ((HWND) (l)) #define NOTIFYCODE(w, l) HIWORD(w) #define CTLID(w, l) LOWORD(w) #define SCROLLPOS(w, l) ((L_INT16) HIWORD(w)) #define SCROLLCODE(w, l) LOWORD(w) #else #define HWNDCTL(w, l) ((HWND) HIWORD(l)) #define NOTIFYCODE(w, l) HIWORD(l) #define CTLID(w, l) (w) #define SCROLLPOS(w, l) ((L_INT16) LOWORD(l)) #define SCROLLCODE(w, l) (w) #endif typedef struct tagDATA { HPALETTE hPalette; /* Logical Palette used for painting. */ FILEINFO FileInfo; /* FILEINFO structure. */ BITMAPHANDLE Bitmap; /* BITMAP HANDLE to hold the image. */ RECT rcView; /* the portion of the image visible on the screen */ L_UINT uRegionMask; /* used to create the region brush */ L_INT cxClient; L_INT cyClient; L_INT nHScrollStep; L_INT nVScrollStep; L_INT nHScrollMax; L_INT nVScrollMax; L_INT nHScrollPos; L_INT nVScrollPos; } DATA; typedef struct _ROTATEPARM { L_INT32 nAngleMax; L_INT32 nAngle; L_BOOL fOption; LPSTR pszTitle; LPSTR pszOption; } ROTATEPARM, L_FAR * LPROTATEPARM; typedef struct _RESIZEPARM { L_INT nWidth; L_INT nHeight; LPSTR pszTitle; } RESIZEPARM, L_FAR * LPRESIZEPARM; typedef struct _RANGEPARM { L_CHAR szTitle[32]; L_CHAR szLabel[32]; L_INT nValue; L_INT nMin; L_INT nMax; L_INT nStep; L_INT nPage; } RANGEPARM, FAR * LPRANGEPARM; #define IDI_MAIN 99 #define IDM_OPEN 100 #define IDM_SAVE 101 #define IDM_EXIT 102 #define IDM_POINT 200 #define IDM_LINE 201 #define IDM_RECTANGLE 202 #define IDM_ELLIPSE 203 #define IDM_TEXT 204 /* offset into the Draw menu. If some items are added to the Draw menu above the Region popup, alter this value accordingly! */ #define MENU_DRAW_MOVEREGION 6 #define IDM_TOOLRECT 210 #define IDM_TOOLELLIPSE 211 #define IDM_TOOLRNDRECT 212 #define IDM_TOOLFREEHAND 213 #define IDM_TOOLCOLOR 214 /* offset into the Draw menu. If some items are added to the Draw menu above the Region popup, alter this value accordingly! */ #define MENU_DRAW_REGION 7 #define IDM_ROTATEREGION 220 #define IDM_FLIPREGION 221 #define IDM_REVERSEREGION 222 #define IDM_RESIZEREGION 223 #define IDM_RESAMPLEREGION 224 #define IDM_BRIGHTNESSREGION 225 #define IDM_CONTRASTREGION 226 #define IDM_SIZE1 300 #define IDM_SIZE2 301 #define IDM_SIZE3 302 #define IDM_SIZE4 303 #define IDM_SIZE5 304 #define IDM_SIZE6 305 #define IDM_SIZE7 306 #define IDM_SIZE8 307 #define IDM_SIZE9 308 #define IDM_NORMAL 400 #define IDM_SOLID 401 #define IDM_DASH 402 #define IDM_DOT 403 #define IDM_BLACK 500 #define IDM_WHITE 501 #define IDM_RED 502 #define IDM_GREEN 503 #define IDM_BLUE 504 #define IDC_STATIC -1 #define IDC_EDIT1 600 #define IDD_RESIZE 700 #define IDD_ROTATE 701 #define IDD_RANGE 702 #define IDC_ROTATEEDIT 710 #define IDC_ROTATESCROLL 711 #define IDC_ROTATEOPTION 712 #define IDC_RESIZEWIDTHEDIT 720 #define IDC_RESIZEWIDTHSCROLL 721 #define IDC_RESIZEHEIGHTEDIT 722 #define IDC_RESIZEHEIGHTSCROLL 723 #define IDC_RESIZEASPECT 724 #define IDC_RANGEEDIT 730 #define IDC_RANGESCROLL 731 #define IDC_RANGELABEL 732 #define IDC_HAND 800 #define IDC_EYEDROP 801 #define REGIONEVENTDELAY 250 #define ID_REGIONEVENT 1245 /* Demo Definitions */ #define ENABLEMENUITEM(hMenu, wID, fFlag) EnableMenuItem(hMenu,\ (UINT)wID, (UINT)MF_BYCOMMAND | ((fFlag) ? MF_ENABLED : (MF_DISABLED | MF_GRAYED))) #define ENABLEMENUPOS(hMenu, wID, fFlag) EnableMenuItem(hMenu,\ (UINT)wID, (UINT)MF_BYPOSITION | ((fFlag) ? MF_ENABLED : (MF_DISABLED | MF_GRAYED))) #define CHECKMENUITEM(hMenu, wID, fFlag) CheckMenuItem(hMenu,\ (UINT)wID, (UINT)MF_BYCOMMAND | ((fFlag) ? MF_CHECKED : MF_UNCHECKED)) #define CHECKMENUPOS(hMenu, wID, fFlag) CheckMenuItem(hMenu,\ (UINT)wID, (UINT)MF_BYPOSITION | ((fFlag) ? MF_CHECKED : MF_UNCHECKED)) DATA Data; OFSTRUCT openbuff; BOOL bline = TRUE; BOOL bellipse = FALSE; BOOL bpoint = FALSE; BOOL btext = FALSE; BOOL brectangle = FALSE; BOOL bmarkregion = FALSE; BOOL bmoveregion = FALSE; BOOL bDraw = FALSE; L_TCHAR szImageDir[MAXFILENAME]; L_INT xAnchor = -1; L_INT yAnchor = -1; L_INT xEnd = -1; L_INT yEnd = -1; L_INT xold = -1; L_INT yold = -1; L_INT xPrev = -1; L_INT yPrev = -1; POINT point; HMENU hMenu; HBITMAP hbmSave = NULL, hbmFloater = NULL; HRGN hrgnRegion; RGNXFORM XForm; L_INT xMoveSrc, yMoveSrc; L_INT xMoveDest, yMoveDest; L_INT nMoveWidth, nMoveHeight; BITMAPHANDLE bmFloater, bmSave; L_INT nRegionTool; L_INT nNextPt; LPPOINT pptRegion; L_INT nLinecolor = 1; L_INT nLinestyle = 0; L_INT nLinesize = 1; L_TCHAR szText[50]; HINSTANCE hInstApp; L_INT nOpenTypeIdx = 1; /* Default file type index */ L_INT nSaveTypeIdx = 1; L_INT nSrcTypeIdx = 1; L_INT nTrgTypeIdx = 1; L_INT nQFactor = 2; /* quality factor (2 - 225) */ L_BOOL fInScroll; HCURSOR hcrHand; HCURSOR hcrEyeDrop; enum { MENU_FILE_POS, MENU_DRAW_POS, MENU_MODE_POS, }; /* useful rectangle macros */ #define RECTWIDTH(lpRect) (((LPRECT) lpRect)->right - ((LPRECT) lpRect)->left) #define RECTHEIGHT(lpRect) (((LPRECT) lpRect)->bottom - ((LPRECT) lpRect)->top) int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow); L_BOOL InitApplication (HANDLE hInstance); L_BOOL InitInstance (HANDLE hInstance, L_INT nCmdShow); L_INT32 EXT_FUNCTION MainWndProc (HWND hWnd, L_UINT Message, WPARAM wParam, LPARAM lParam); VOID Window_OnInitMenuPopup (HWND hWnd, HMENU hMenu, L_INT item, BOOL fSystemMenu); VOID Window_OnLButtonDown (HWND hWnd, BOOL fDoubleClick, L_INT x, L_INT y, UINT keyFlags); VOID Window_OnLButtonUp (HWND hwnd, L_INT x, L_INT y, UINT keyFlags); VOID Window_OnMouseMove (HWND hWnd, L_INT x, L_INT y, UINT keyFlags); VOID Window_OnPaletteChanged (HWND hWnd, HWND hWndPaletteChange); BOOL Window_OnQueryNewPalette (HWND hWnd); VOID Window_OnActivate(HWND hwnd, UINT state, HWND hwndActDeact, BOOL fMinimized); VOID Window_OnPaletteChanging(HWND hWnd, HWND hWndPaletteChange); VOID Window_SysColorChange(HWND hwnd); VOID Window_OnPaint (HWND hWnd); VOID Window_OnCommand (HWND hWnd, L_INT id, HWND hwndCtl, UINT codeNotify); VOID Window_OnDestroy (HWND hWnd); VOID Window_OnSetFocus(HWND hwnd, HWND hwndOldFocus); VOID Window_OnKillFocus(HWND hwnd, HWND hwndNewFocus); L_VOID Window_OnTimer(HWND hWnd, UINT id); BOOL Window_OnSetCursor(HWND hWnd, HWND wParam, UINT nHittest, UINT wMouseMsg); VOID Window_ProcessSize (HWND hWnd, UINT nState, L_INT nCx, L_INT nCy); VOID Window_OnSize (HWND hWnd, UINT nState, L_INT nCx, L_INT nCy); VOID Window_OnHScroll (HWND hWnd, HWND hWndCtl, UINT nCode, L_INT nPos); VOID Window_OnVScroll (HWND hWnd, HWND hWndCtl, UINT nCode, L_INT nPos); L_VOID Reset_Draw (HWND hWnd); L_BOOL SaveBitmapFile (HWND hWnd, pBITMAPHANDLE pBitmapHandle); COLORREF Color (L_INT ncolor); L_BOOL CALLBACK L_EXPORT TextDialogProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); L_BOOL GetOpenBitmapFile (HWND hWnd, LPTSTR pFilename); L_BOOL ImageLoad (HWND hWnd, LPTSTR lpFileName); VOID FreeBitmaps (); L_INT ChangeRegion( HWND hWnd, L_INT id ); L_VOID OutlineBitmapRgn(HWND hWnd, HDC hdc); L_VOID HiliteMark(HWND hWnd, L_BOOL fUpdate); L_INT CreateRegionBitmaps( HWND hWnd ); L_BOOL GetResizeParm(HWND hWnd, LPRESIZEPARM pParm); L_BOOL GetRotateParm(HWND hWnd, LPROTATEPARM pParm); L_INT GetPercentage (HWND hWnd, LPSTR pszTitle); L_INT DoDialogBoxParam(L_INT nDialog, HWND hWnd, DLGPROC pfnDialog, LPARAM lParam); L_BOOL CALLBACK L_EXPORT RotateDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); L_BOOL CALLBACK L_EXPORT ResizeDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); L_BOOL CALLBACK L_EXPORT RangeDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);