2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
32 // Original ColorPicker/DIB source by Rajiv Ramachandran <rrajivram@hotmail.com>
33 // included with permission from the author
42 CDIB( HANDLE hDib = NULL,int nBits = 8 );
45 CDIB & operator=( CDIB& dib );
46 BOOL IsValid() { return ( m_pVoid && Width() && Height() ); }
47 void UseGamma( float fg, BOOL bUse = TRUE );
48 BOOL CreateFromHandle( HANDLE hDib, int nBits );
49 BOOL Create( int width, int height, int bits = 24 );
50 BOOL Create( BITMAPINFOHEADER& bmInfo );
51 BOOL CopyDIB( CDIB& dib );
52 BOOL OpenDIB( CString &fileName );
53 BOOL SaveDIB( CString &fileName, BitmapType type );
54 void ReplaceColor(unsigned char oldColor,unsigned char newColor);
55 HANDLE GetDIBits(int nStartX=-1,int nStartY=-1,int nCx=-1,int nCy=-1);
56 CBitmap * GetBitmap(CDC& dc);
57 CBitmap * GetTempBitmap(CDC& dc);
59 int GetPaletteSize(BITMAPINFOHEADER& bmInfo);
62 int EnumColors(BYTE *colors);
63 void InitDIB(COLORREF color);
64 void CopyLine(int source,int dest);
66 void SetPalette(unsigned char *palette);
67 void SetPalette(RGBQUAD *pRGB);
68 COLORREF PaletteColor(int index);
69 void SetPixel(int x,int y,COLORREF color);
70 void SetPixel8(int x,int y,unsigned char color);
71 COLORREF GetPixel(int x,int y);
72 void GetPixel(UINT x,UINT y,int& pixel);
73 void BitBlt(HDC hDest,int nXDest,int nYDest,int nWidth,int nHeight,int xSrc,int ySrc);
74 void BitBlt(int nXDest,int nYDest,int nWidth,int nHeight,CDIB& dibSrc,int nSrcX,int nSrcY,BYTE *colors=NULL);
75 void StretchBlt(HDC hDest,int nXDest,int nYDest,int nDWidth,int nDHeight,int xSrc,int ySrc,int nSWidth,int nSHeight);
76 void StretchBlt(int nXDest,int nYDest,int nDWidth,int nDHeight,CDIB& dibSrc,int xSrc,int ySrc,int nSWidth,int nSHeight);
77 void ExpandBlt(int nXDest,int nYDest,int xRatio,int yRatio,CDIB& dibSrc,int xSrc,int ySrc,int nSWidth,int nSHeight);
78 void SetFlags(int flag) { m_nFlags = flag; }
79 int Height() { return height ; }
80 int Width() { return width ; }
81 unsigned char *GetLinePtr(int line);
82 inline int GetBitCount() { return m_pInfo->bmiHeader.biBitCount; }
83 BOOL Make8Bit( CDIB &dib );
84 BOOL SwitchFromOne( CDIB &dib );
85 BOOL SwitchFromFour( CDIB &dib );
86 BOOL SwitchFrom24( CDIB &dib );
87 BOOL SwitchPalette( CDIB &dib );
88 int ClosestColor(RGBQUAD *pRgb );
89 LPBITMAPINFO GetBitmapInfo() { return m_pInfo; }
90 static unsigned int Distance( RGBQUAD& rgb1, RGBQUAD& rgb2 );
94 BOOL OpenBMP( CString &csFileName );
95 BOOL OpenGIF( CString &csFileName );
96 BOOL OpenTIFF( CString &csFileName );
97 BOOL SaveBMP( CString &csFileName );
98 BOOL SaveGIF( CString &csFileName );
99 BOOL SaveTIFF( CString &csFileName );
100 void CreateGammaCurve();
101 void Expand( int nXDest, int nYDest, int xRatio, int yRatio, CDIB &dibSrc, int xSrc, int ySrc, int nSWidth, int nSHeight );
103 unsigned char * m_pBits;
116 unsigned char Gamma[256];
117 RGBQUAD CacheQuad[256];
121 #endif /* !__CDIB__ */