Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

234 lines
8.2 KiB

  1. #ifndef __IMGSUPRT_H__
  2. #define __IMGSUPRT_H__
  3. #define MAX_PALETTE_COLORS 256
  4. #define WM_CANCEL WM_USER + 0
  5. // Brush Shapes
  6. #define roundBrush 0
  7. #define squareBrush 1
  8. #define slantedLeftBrush 2
  9. #define slantedRightBrush 3
  10. // Combine Modes
  11. #define combineColor 0
  12. #define combineMatte 1
  13. #define combineReplace 2
  14. // Non-standard Raster Ops
  15. #define DSx 0x00660046L
  16. #define DSa 0x008800C6L
  17. #define DSna 0x00220326L
  18. #define DSPao 0x00ea02e9L
  19. #define DSo 0x00ee0086L
  20. #define DSno 0x00bb0226L
  21. #define DSPDxax 0x00e20746L
  22. #define SPxn 0x00c3006aL
  23. // Indices of the screen and inverse colors in color table.
  24. #define IDScreen -1
  25. #define IDInvScreen -2
  26. // NOTE: These structures mirror the LOGPALETTE structure in WINDOWS.H
  27. struct LOGPALETTE16
  28. {
  29. WORD palVersion;
  30. WORD palNumEntries;
  31. PALETTEENTRY palPalEntry[16];
  32. };
  33. struct LOGPALETTE256
  34. {
  35. WORD palVersion;
  36. WORD palNumEntries;
  37. PALETTEENTRY palPalEntry[MAX_PALETTE_COLORS];
  38. };
  39. // Note: this bogus structure is not my fault! It's stolen from
  40. // the old Windows SDK ImagEdit program...
  41. #pragma pack(1)
  42. struct COLORFILEHEADER
  43. {
  44. char tag; // this is a 'C'
  45. short colors;
  46. char reserved[47]; // fill with 0
  47. // DWORD rgrgb [colors];
  48. };
  49. #pragma pack()
  50. /*************************************************************************/
  51. //extern int FileTypeFromExtension( const TCHAR FAR* lpcExt );
  52. void InitCustomData(); // see customiz.cpp
  53. void CustomExit();
  54. class CImgWnd;
  55. // IMGSUPRT.CPP
  56. extern IMG* CreateImg (int cxWidth, int cyHeight,
  57. int cPlanes, int cBitCount,
  58. int cXPelsPerMeter, int cYPelsPerMeter,
  59. BOOL bPalette = TRUE );
  60. extern void SelectImg (IMG* pImg);
  61. extern BOOL ClearImg (IMG* pImg);
  62. extern void FreeImg (IMG* pImg);
  63. extern void DirtyImg (IMG* pImg);
  64. extern void AddImgWnd (IMG* pImg, CImgWnd* pImgWnd);
  65. extern BOOL UpdateCurIcoImg (IMG* pImg);
  66. extern BOOL ChangeICBackground (IMG* pImg, COLORREF rgbNewScr);
  67. extern BOOL SetImgSize (IMG* pImg, CSize newSize, BOOL bStretch);
  68. extern void GetImgSize (IMG* pImg, CSize& size);
  69. extern BOOL ReplaceImgPalette (IMG* pImg, LPLOGPALETTE lpLogPal);
  70. extern int AddNewColor (IMG* pImg, COLORREF crNew );
  71. // IMGED.CPP
  72. extern void Draw3dRect (HDC hDC, RECT* prc);
  73. // DRAW.CPP
  74. extern void InvalImgRect (IMG* pImg, CRect* prc);
  75. extern void CommitImgRect (IMG* pImg, CRect* prc);
  76. extern void FixRect (RECT* prc);
  77. extern void StandardiseCoords (CPoint* s, CPoint* e);
  78. extern void DrawBrush (IMG* pImg, CPoint pt, BOOL bDraw);
  79. extern void HideBrush ();
  80. extern void SetCombineMode (int wNewCombineMode);
  81. extern BOOL SetupRubber (IMG* pImg);
  82. extern void PolyTo (CDC* pDC, CPoint fromPt,
  83. CPoint toPt, CSize size);
  84. extern BOOL GetTanPt (CSize size, CPoint delta, CRect& tan);
  85. extern void SetDrawColor (COLORREF cr);
  86. extern void SetEraseColor (COLORREF cr);
  87. extern void SetTransColor (COLORREF cr);
  88. extern void SetDrawColor (int iColor);
  89. extern void SetEraseColor (int iColor);
  90. extern void SetTransColor (int iColor);
  91. extern void InvalColorWnd ();
  92. extern BOOL SetUndo (IMG* pImg);
  93. extern void SetLeftColor (int nColor);
  94. extern void SetRightColor (int nColor);
  95. extern void CommitSelection (BOOL bSetUndo);
  96. extern void PickupSelection ();
  97. extern BOOL EnsureUndoSize (IMG* pimg);
  98. extern void CleanupImages ();
  99. extern void CleanupImgRubber();
  100. extern void CleanupImgUndo ();
  101. extern IMG* pImgCur;
  102. #define TRANS_COLOR_NONE 0x87654321 // undefined
  103. extern BOOL fDraggingBrush;
  104. extern BOOL g_bCustomBrush;
  105. extern BOOL g_bDriverCanStretch;
  106. extern BOOL g_bUseTrans;
  107. extern int theLeft;
  108. extern int theRight;
  109. extern int theTrans;
  110. extern COLORREF crLeft;
  111. extern COLORREF crRight;
  112. extern COLORREF crTrans;
  113. extern int wCombineMode;
  114. struct DINFO
  115. {
  116. TCHAR* m_szDesc;
  117. UINT m_nColors;
  118. SIZE m_size;
  119. };
  120. extern COLORREF std2Colors[];
  121. extern CPalette* GetStd256Palette();
  122. extern CPalette* GetStd16Palette();
  123. extern CPalette* GetStd2Palette();
  124. extern CPalette* PaletteFromDS(HDC hdc);
  125. #define IS_WIN30_DIB(lpbi) ((*(LPDWORD)(lpbi)) >= sizeof (BITMAPINFOHEADER))
  126. extern WORD DIBNumColors ( LPSTR lpbi, BOOL bJustUsed=TRUE );
  127. extern DWORD DIBWidth ( LPSTR lpDIB );
  128. extern DWORD DIBHeight ( LPSTR lpDIB );
  129. extern CPalette* CreateDIBPalette ( LPSTR lpbi );
  130. extern HBITMAP DIBToBitmap ( LPSTR lpDIBHdr, CPalette* pPal, HDC hdc = NULL );
  131. extern HBITMAP DIBToDS ( LPSTR lpDIBHdr, DWORD dwOffBits, HDC hdc );
  132. extern HGLOBAL DibFromBitmap ( HBITMAP hBitmap, DWORD dwStyle, WORD wBits,
  133. CPalette* pPal, HBITMAP hMaskBitmap, DWORD& dwSize,
  134. LONG cXPelsPerMeter, LONG cYPelsPerMeter );
  135. extern LPSTR FindDIBBits ( LPSTR lpbi, DWORD dwOffBits = 0 );
  136. extern WORD PaletteSize ( LPSTR lpbi );
  137. extern void FreeDib ( HGLOBAL hDib );
  138. extern CPalette* CreatePalette ( const COLORREF* colors, int nColors );
  139. extern CPalette* MergePalettes ( CPalette *pPal1, CPalette *pPal2, int& iAdds );
  140. extern void AdjustPointForGrid( CPoint *ptPointLocation );
  141. // drawing support functions
  142. extern void StretchCopy (HDC, int, int, int, int, HDC, int, int, int, int);
  143. extern void FillImgRect (HDC hDC, CRect * prc, COLORREF cr );
  144. extern void BrushLine (CDC* pDC, CPoint fromPt, CPoint toPt,
  145. int nWidth, int nShape);
  146. extern void DrawDCLine (HDC hDC, CPoint pt1, CPoint pt2,
  147. COLORREF color, int nWidth, int nShape,
  148. CRect& rc);
  149. extern void DrawImgLine (IMG* pimg, CPoint pt1, CPoint pt2,
  150. COLORREF color, int nWidth, int nShape,
  151. BOOL bCommit);
  152. extern void Mylipse (HDC hDC, int x1, int y1, int x2, int y2, BOOL bFilled);
  153. // PATSTENCIL:
  154. // This is a ternary raster operation, listed in the SDK ref as "PSDPxax",
  155. // but I prefer to think of it as "DSaPSnao". More practically, this rop
  156. // is useful to apply the color of the current brush to only those pixels
  157. // where the source bitmap is zero (black). That is, a binary bitmap as the
  158. // source will be drawn onto the destination in the color of the current
  159. // brush.
  160. //
  161. #define PATSTENCIL 0xB8074AL
  162. // DrawBitmap:
  163. // This draws a bitmap on a display context with a given raster operation.
  164. // CDC* dc The target display context.
  165. // CBitmap* bmSrc The bitmap to be drawn.
  166. // CRect* rc A position rectangle.
  167. // If NULL, bitmap drawn with the upper-left at 0, 0.
  168. // Otherwise, bitmap drawn centered in this rectangle.
  169. // Result is not clipped to the rectangle.
  170. // DWORD dwROP Raster operation. See table 11.3 of the Win30 SDK ref.
  171. // CDC* memdc A memory context for the BitBlt process to use.
  172. // If NULL, DrawBitmap creates and destroys its own.
  173. //
  174. void DrawBitmap(CDC* dc, CBitmap* bmSrc, CRect* rc,
  175. DWORD dwROP = SRCCOPY, CDC* memdc = NULL);
  176. extern HDC hRubberDC;
  177. extern HBITMAP hRubberBM;
  178. extern HBITMAP g_hUndoImgBitmap;
  179. extern HPALETTE g_hUndoPalette;
  180. extern int cxRubberWidth;
  181. extern int cyRubberHeight;
  182. extern IMG* pRubberImg;
  183. extern WORD gwClipboardFormat;
  184. extern CBrush g_brSelectHorz;
  185. extern CBrush g_brSelectVert;
  186. CPalette *PBSelectPalette(CDC *pDC, CPalette *pPalette, BOOL bForceBk);
  187. class CTempBitmap : public CBitmap
  188. {
  189. public:
  190. ~CTempBitmap() { DeleteObject(); } // DeleteObject checks for NULL
  191. } ;
  192. #endif // __IMGSUPRT_H__