|
|
1.1 ! root 1: #include <stdio.h> ! 2: /**************************************************************************** ! 3: * * ! 4: * FILE : SHOWDIB.H * ! 5: * * ! 6: * DESCRIPTION : Header/include file for ShowDIB example. * ! 7: * * ! 8: ****************************************************************************/ ! 9: ! 10: typedef int HFILE ; ! 11: typedef POINTS MPOINT ; ! 12: ! 13: #ifdef WIN32 ! 14: #define GET_WM_ACTIVATE_STATE(wp, lp) LOWORD(wp) ! 15: #define GET_WM_VSCROLL_CODE(wp, lp) LOWORD(wp) ! 16: #define GET_WM_VSCROLL_POS(wp, lp) HIWORD(wp) ! 17: #define GET_WM_HSCROLL_CODE(wp, lp) LOWORD(wp) ! 18: #define GET_WM_HSCROLL_POS(wp, lp) HIWORD(wp) ! 19: #define GET_EM_SETSEL_MPS(iStart, iEnd) (UINT)(iStart), (LONG)(iEnd) ! 20: #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp) ! 21: #define MAKEMPOINT(l) (*((MPOINT *)&(l))) ! 22: #define HUGE_T ! 23: #else ! 24: #define GET_WM_ACTIVATE_STATE(wp, lp) (wp) ! 25: #define GET_WM_HSCROLL_CODE(wp, lp) (wp) ! 26: #define GET_WM_HSCROLL_POS(wp, lp) LOWORD(lp) ! 27: #define GET_WM_VSCROLL_CODE(wp, lp) (wp) ! 28: #define GET_WM_VSCROLL_POS(wp, lp) LOWORD(lp) ! 29: #define GET_EM_SETSEL_MPS(iStart, iEnd) 0, MAKELONG(iStart, iEnd) ! 30: #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(lp) ! 31: #define MAKEMPOINT(l) (*((MPOINT FAR *)&(l))) ! 32: #define HUGE_T huge ! 33: #endif ! 34: ! 35: /* Macro to restrict a given value to an upper or lower boundary value */ ! 36: #define BOUND(x,min,max) ((x) < (min) ? (min) : ((x) > (max) ? (max) : (x))) ! 37: ! 38: /* Macro to swap two values */ ! 39: #define SWAP(x,y) ((x)^=(y)^=(x)^=(y)) ! 40: ! 41: /* Macro to find the minimum of two values */ ! 42: #define MIN(x,y) (((x) <= (y)) : x ? y) ! 43: ! 44: /* Macros to display/remove hourglass cursor for lengthy operations */ ! 45: #define StartWait() hcurSave = SetCursor(LoadCursor(NULL,IDC_WAIT)) ! 46: #define EndWait() SetCursor(hcurSave) ! 47: ! 48: /* WinFlags, __WinFlags is a ABS external, thus the need for the & */ ! 49: #define WinFlags ((WORD)(&_WinFlags)) ! 50: ! 51: #define MINBAND 50 /* Minimum band size used by the program */ ! 52: #define BANDINCREMENT 20 /* Decrement for band size while trying */ ! 53: /* to determine optimum band size. */ ! 54: ! 55: /* Bit values for the DIB attributes flag (fFileOptions). Also used as control ! 56: * IDs for the radiobuttons for DIB bitcount in the File/Open dialog ! 57: */ ! 58: #define F_1BPP DLGOPEN_1BPP ! 59: #define F_4BPP DLGOPEN_4BPP ! 60: #define F_8BPP DLGOPEN_8BPP ! 61: #define F_24BPP DLGOPEN_24BPP ! 62: ! 63: /* Bit values for the DIB attributes flag (fFileOptions), also used as control ! 64: * IDs for the radiobuttons for DIB compression type in the File/Open dialog ! 65: */ ! 66: #define F_RLE4 DLGOPEN_RLE4 ! 67: #define F_RLE8 DLGOPEN_RLE8 ! 68: #define F_RGB DLGOPEN_RGB ! 69: ! 70: #ifdef NOT_IN_STDIO ! 71: /* flags for _lseek */ ! 72: #define SEEK_CUR 1 ! 73: #define SEEK_END 2 ! 74: #define SEEK_SET 0 ! 75: #endif ! 76: ! 77: /* struct to be passed in for the SETDIBSCALING printer escape */ ! 78: typedef struct { ! 79: SHORT ScaleMode; ! 80: SHORT dx, dy; ! 81: } DIBPARAMS; ! 82: ! 83: /* Menu IDs */ ! 84: ! 85: #define IDM_UPDATECOL 1000 ! 86: #define IDM_ANIMATE0 1001 ! 87: #define IDM_ANIMATE5 5 ! 88: #define IDM_ANIMATE20 20 ! 89: #define IDM_ANIMATE50 50 ! 90: #define IDM_ANIMATE100 100 ! 91: #define IDM_ANIMATE200 200 ! 92: #define IDM_ANIMATE201 32000 ! 93: ! 94: #define IDM_OPEN 1002 ! 95: #define IDM_EXIT 1003 ! 96: #define IDM_ABOUT 1004 ! 97: #define IDM_DIBSCREEN 1005 ! 98: #define IDM_NOUGLY 1006 ! 99: #define IDM_STEALCOL 1009 ! 100: #define IDM_PRINT 1010 ! 101: #define IDM_COPY 1012 ! 102: #define IDM_MEMORYDIB 1014 ! 103: #define IDM_SAVE 1015 ! 104: #define IDM_TRANSPARENT 1016 ! 105: ! 106: #define IDM_PASTEDIB 1020 ! 107: #define IDM_PASTEDDB 1021 ! 108: #define IDM_PASTEPAL 1022 ! 109: ! 110: #define IDI_APP 2000 ! 111: ! 112: #define ABOUTBOX 100 ! 113: ! 114: extern HWND hWndApp; /* The handle to the app. window */ ! 115: ! 116: #define MAXREAD 32768 /* Number of bytes to be read during */ ! 117: /* each read operation. */ ! 118: ! 119: /* Header signatutes for various resources */ ! 120: #define BFT_ICON 0x4349 /* 'IC' */ ! 121: #define BFT_BITMAP 0x4d42 /* 'BM' */ ! 122: #define BFT_CURSOR 0x5450 /* 'PT' */ ! 123: ! 124: /* macro to determine if resource is a DIB */ ! 125: #define ISDIB(bft) ((bft) == BFT_BITMAP) ! 126: ! 127: /* Macro to align given value to the closest DWORD (unsigned long ) */ ! 128: #define ALIGNULONG(i) ((i+3)/4*4) ! 129: ! 130: /* Macro to determine to round off the given value to the closest byte */ ! 131: #define WIDTHBYTES(i) ((i+31)/32*4) ! 132: ! 133: #define PALVERSION 0x300 ! 134: #define MAXPALETTE 256 /* max. # supported palette entries */ ! 135: ! 136: /********** THE FOLLOWING ARE USED IN DLGOPEN.C ************************/ ! 137: ! 138: /* IDs for controls in the DlgOpen dialog */ ! 139: #define DLGOPEN_EDIT 101 ! 140: #define DLGOPEN_FILE_LISTBOX 102 ! 141: #define DLGOPEN_DIR_LISTBOX 103 ! 142: #define DLGOPEN_PATH 104 ! 143: #define DLGOPEN_TEXT 105 ! 144: #define DLGOPEN_FOLDOUT 106 ! 145: #define DLGOPEN_BIG 107 ! 146: #define DLGOPEN_SMALL 108 ! 147: ! 148: #define DLGOPEN_OPTION 0xF000 ! 149: #define DLGOPEN_1BPP 0x0001 ! 150: #define DLGOPEN_4BPP 0x0002 ! 151: #define DLGOPEN_8BPP 0x0004 ! 152: #define DLGOPEN_24BPP 0x0008 ! 153: #define DLGOPEN_RLE4 0x0010 ! 154: #define DLGOPEN_RLE8 0x0020 ! 155: #define DLGOPEN_RGB 0x0040 ! 156: ! 157: #define DLGOPEN_OPTION8 0x0080 ! 158: ! 159: /* flags: ! 160: * The LOWORD is the standard FileOpen() flags (OF_*) ! 161: * the HIWORD can be any of the following: ! 162: */ ! 163: #define OF_MUSTEXIST 0x00010000 /* file must exist if the user hits Ok */ ! 164: #define OF_NOSHOWSPEC 0x00020000 /* DO NOT Show search spec in the edit box*/ ! 165: #define OF_SHOWSPEC 0x00000000 /* Show the search spec in the edit box */ ! 166: #define OF_SAVE 0x00040000 /* Ok button will say "Save" */ ! 167: #define OF_OPEN 0x00080000 /* Ok button will say "Open" */ ! 168: #define OF_NOOPTIONS 0x00100000 /* Disable the options fold out */ ! 169: ! 170: /* Attributes for DlgDirLst() */ ! 171: #define ATTRFILELIST 0x0000 /* include files only */ ! 172: #define ATTRDIRLIST 0xC010 /* directories and drives ONLY */ ! 173: #define CBEXTMAX 6 /* Number of bytes in "\*.txt" */ ! 174: ! 175: ! 176: #define IDF(id) ((id) & ~DLGOPEN_OPTION) /* extracts flag from control ID */ ! 177: #define FID(f) ((f) | DLGOPEN_OPTION) /* extracts control ID from flag */ ! 178: ! 179: /***************** GLOBAL VARIABLES *************************/ ! 180: ! 181: extern CHAR achFileName[128]; /* File pathname */ ! 182: extern DWORD dwOffset; /* Current position if DIB file pointer */ ! 183: extern RECT rcClip; /* Current clip rectangle. */ ! 184: extern BOOL fPalColors; /* TRUE if the current DIB's color table */ ! 185: /* contains palette indexes not rgb values */ ! 186: extern BOOL bDIBToDevice; /* Use SetDIBitsToDevice() to BLT data. */ ! 187: extern BOOL bLegitDraw; /* We have a valid bitmap to draw */ ! 188: extern WORD wTransparent; /* Mode of DC */ ! 189: extern CHAR szAppName[]; /* App. name */ ! 190: extern HPALETTE hpalCurrent; /* Handle to current palette */ ! 191: extern HANDLE hdibCurrent; /* Handle to current memory DIB */ ! 192: extern HBITMAP hbmCurrent; /* Handle to current memory BITMAP */ ! 193: extern HANDLE hbiCurrent; /* Handle to current bitmap info struct */ ! 194: extern DWORD dwStyle; /* Style bits of the App. window */ ! 195: ! 196: /***************** FUNCTION DECLARATIONS *******************/ ! 197: ! 198: DWORD PASCAL lread(INT fh, VOID FAR *pv, DWORD ul); ! 199: DWORD PASCAL lwrite(INT fh, VOID FAR *pv, DWORD ul); ! 200: ! 201: /***********************************************************/ ! 202: /* Declarations of functions used in showdib.c module */ ! 203: /***********************************************************/ ! 204: ! 205: LONG APIENTRY WndProc (HWND, UINT, UINT, LONG) ; ! 206: BOOL MenuCommand (HWND hWnd, UINT wParam); ! 207: INT InitDIB (HWND); ! 208: VOID FreeDib (VOID); ! 209: ! 210: /***********************************************************/ ! 211: /* Declarations of functions used in dib.c module */ ! 212: /***********************************************************/ ! 213: ! 214: HANDLE OpenDIB (LPSTR szFile); ! 215: BOOL WriteDIB (LPSTR szFile,HANDLE hdib); ! 216: WORD PaletteSize (VOID FAR * pv); ! 217: WORD DibNumColors (VOID FAR * pv); ! 218: HPALETTE CreateDibPalette (HANDLE hdib); ! 219: HPALETTE CreateBIPalette (LPBITMAPINFOHEADER lpbi); ! 220: HANDLE DibFromBitmap (HBITMAP hbm, DWORD biStyle, WORD biBits, HPALETTE hpal); ! 221: HANDLE BitmapFromDib (HANDLE hdib, HPALETTE hpal); ! 222: BOOL DibBlt (HDC hdc, INT x0, INT y0, INT dx, INT dy, HANDLE hdib, INT x1, INT y1, LONG rop); ! 223: BOOL StretchDibBlt (HDC hdc, INT x0, INT y0, INT dx, INT dy, HANDLE hdib, INT x1, INT y1, INT dx1, INT dy1, LONG rop); ! 224: BOOL DibInfo (HANDLE hdib,LPBITMAPINFOHEADER lpbi); ! 225: HANDLE ReadDibBitmapInfo (INT fh); ! 226: BOOL DrawBitmap (HDC hdc, INT x, INT y, HBITMAP hbm, DWORD rop); ! 227: VOID ReadBitMapFileHeaderandConvertToDwordAlign(HFILE fh, LPBITMAPFILEHEADER pbf, LPDWORD lpdwoff); ! 228: VOID WriteMapFileHeaderandConvertFromDwordAlignToPacked(HFILE fh, LPBITMAPFILEHEADER pbf); ! 229: ! 230: /***********************************************************/ ! 231: /* Declarations of functions used in drawdib. c module */ ! 232: /***********************************************************/ ! 233: ! 234: VOID PrintDIB (HWND hWnd, HDC hDC, INT x, INT y, INT dx, INT dy); ! 235: VOID AppPaint (HWND hWnd, HDC hDC, INT x, INT y); ! 236: INT ErrMsg (PSTR sz,...); ! 237: BOOL fDialog (INT id, HWND hwnd, FARPROC fpfn); ! 238: VOID BandDIB (HWND hWnd, HDC hDC, INT x, INT y); ! 239: BOOL APIENTRY AppAbout (HWND, UINT, UINT, LONG) ; ! 240: HANDLE CopyHandle (HANDLE h); ! 241: VOID SizeWindow (HWND hWnd); ! 242: VOID GetRealClientRect (HWND hwnd, PRECT lprc); ! 243: VOID SetScrollRanges (HWND hwnd); ! 244: VOID DrawSelect (HDC hdc, BOOL fDraw); ! 245: VOID PASCAL NormalizeRect (RECT *prc); ! 246: VOID TrackMouse (HWND hwnd, MPOINT pt); ! 247: HBITMAP CopyBitmap (HBITMAP hbm); ! 248: HPALETTE CopyPalette (HPALETTE hpal); ! 249: HBITMAP CropBitmap (HBITMAP hbm, PRECT prc); ! 250: HANDLE RenderFormat (INT cf); ! 251: HANDLE RealizeDibFormat (DWORD biStyle, WORD biBits); ! 252: ! 253: /***********************************************************/ ! 254: /* Declarations of functions used in the print.c module */ ! 255: /***********************************************************/ ! 256: ! 257: BOOL PASCAL InitPrinting (HDC hDC, HWND hWnd, HANDLE hInst, LPSTR msg); ! 258: VOID PASCAL TermPrinting (HDC hDC); ! 259: HDC PASCAL GetPrinterDC (VOID); ! 260: ! 261: /***********************************************************/ ! 262: /* Declarations of functions used in the dlgopen.c module */ ! 263: /***********************************************************/ ! 264: ! 265: LONG APIENTRY DlgfnOpen( ! 266: HWND hwnd, ! 267: UINT msg, ! 268: UINT wParam, ! 269: LONG lParam ! 270: ); ! 271: HFILE APIENTRY DlgOpenFile ( ! 272: HWND hwndParent, ! 273: CHAR *szTitleIn, ! 274: DWORD flags, ! 275: CHAR *szExtIn, ! 276: CHAR *szFileNameIn, ! 277: WORD *pfOpt ! 278: ); ! 279: ! 280: /*****************************************************/ ! 281: /* make new sizeof structs to cover dword alignment */ ! 282: /*****************************************************/ ! 283: ! 284: #define SIZEOF_BITMAPFILEHEADER_PACKED ( \ ! 285: sizeof(WORD) + /* bfType */ \ ! 286: sizeof(DWORD) + /* bfSize */ \ ! 287: sizeof(WORD) + /* bfReserved1 */ \ ! 288: sizeof(WORD) + /* bfReserved2 */ \ ! 289: sizeof(DWORD)) /* bfOffBits */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.