|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
//<2F>ļ<EFBFBD> ImageBase.h
|
|
|
|
|
|
//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>:
|
|
|
|
|
|
//
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д: 2005-12-07
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
#include "CxImage\CxImage\ximage.h"
|
|
|
|
|
|
|
|
|
|
|
|
//ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD>ʽ֧<CABD><D6A7>
|
|
|
|
|
|
#define IMAGE_SERIALIZE_BITAMP 1 //<2F><><EFBFBD>л<EFBFBD>Ϊλͼ<CEBB><CDBC>ʽ
|
|
|
|
|
|
#define IMAGE_SERIALIZE_JPEG 2
|
|
|
|
|
|
#define IMAGE_SERIALIZE_PNG 3
|
|
|
|
|
|
#define IMAGE_SERIALIZE_ICO 4
|
|
|
|
|
|
#define IMAGE_SERIALIZE_TIFF 5
|
|
|
|
|
|
#define IMAGE_SERIALIZE_GIF 6
|
|
|
|
|
|
|
|
|
|
|
|
namespace NImage
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
class AFX_EXT_CLASS CImageBase : public CxImage
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
CImageBase(void);
|
|
|
|
|
|
virtual ~CImageBase();
|
|
|
|
|
|
|
|
|
|
|
|
BOOL Create(int nWidth, int nHeight, int nBPP, DWORD imagetype=CXIMAGE_FORMAT_BMP);
|
|
|
|
|
|
void Destroy(void);
|
|
|
|
|
|
|
|
|
|
|
|
HBITMAP Detach();
|
|
|
|
|
|
void Attach( HBITMAP hBitmap);
|
|
|
|
|
|
|
|
|
|
|
|
BOOL PastFromClipboard(void); //<2F>Ӽ<EFBFBD><D3BC>а<EFBFBD><D0B0><EFBFBD>ճ<EFBFBD><D5B3>ͼ<EFBFBD><CDBC>
|
|
|
|
|
|
BOOL CopyToClipboard(HWND hWnd=NULL);
|
|
|
|
|
|
|
|
|
|
|
|
BOOL Draw(CDC& hDestDC, CRect8& rectScreenDest, CRect* clientRect);
|
|
|
|
|
|
long Draw(HDC hDestDC, const RECT& rectDest, const RECT& rectSrc, DWORD dwRop = SRCCOPY); //<2F><>ʾͼ<CABE><CDBC><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><CDB8><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
|
long Draw(HDC hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight,
|
|
|
|
|
|
int xSrc, int ySrc, int nSrcWidth, int nSrcHeight, DWORD dwRop = SRCCOPY);
|
|
|
|
|
|
void Erase(COLORREF pColor);
|
|
|
|
|
|
|
|
|
|
|
|
void operator = (const CImageBase& isrc);
|
|
|
|
|
|
|
|
|
|
|
|
HBITMAP MakeBitmap32(HDC hdc = NULL);
|
|
|
|
|
|
|
|
|
|
|
|
bool GetColorTable( RGBQUAD** pprgbColors );
|
|
|
|
|
|
void SetColorTable( RGBQUAD* prgbColors );
|
|
|
|
|
|
int GetMaxColorTableEntries(void);
|
|
|
|
|
|
|
|
|
|
|
|
BYTE* GetPixelAddress(long x, long y);
|
|
|
|
|
|
COLORREF GetPixel(long x, long y);
|
|
|
|
|
|
void SetPixel(long x, long y, COLORREF color);
|
|
|
|
|
|
int GetType(void);
|
|
|
|
|
|
int GetBpp(void);
|
|
|
|
|
|
|
|
|
|
|
|
int GetSerializeType(CString strFileExt);
|
|
|
|
|
|
|
|
|
|
|
|
BOOL LoadImage(LPCTSTR lpszImageName);
|
|
|
|
|
|
BOOL LoadImage(CFile& fr);
|
|
|
|
|
|
BOOL SaveAs(LPCTSTR lpszImageName, CRect8* pRect=NULL);
|
|
|
|
|
|
BOOL SaveAs(CFile& fw);
|
|
|
|
|
|
bool Serialize(CArchive& ar, const short &ver);
|
|
|
|
|
|
|
|
|
|
|
|
INT_PTR FileDialog( BOOL bOpenFileDialog, CString& fileName, CString strTitle=_T(""), DWORD lFlags=OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT );
|
|
|
|
|
|
CString GetImageFilter(BOOL bOpenFileDialog);
|
|
|
|
|
|
|
|
|
|
|
|
//CImage
|
|
|
|
|
|
bool ReadBitmap(CArchive& ar, CImage* pImage);
|
|
|
|
|
|
bool WriteBitmap(CArchive& ar, CImage* pImage);
|
|
|
|
|
|
HBITMAP CreateBitmapIndirect(HBITMAP hScrBitmap);
|
|
|
|
|
|
HBITMAP CreateBitmapIndirect(LPBITMAPINFO lpBitmapInfo, const void* lpSrcBits);
|
|
|
|
|
|
|
|
|
|
|
|
bool Gamma(double gamma);//0.1<EFBFBD><EFBFBD>5
|
|
|
|
|
|
bool Light(long brightness, long contrast=0);
|
|
|
|
|
|
void MirrorX(void);
|
|
|
|
|
|
void MirrorY(void);
|
|
|
|
|
|
void TowColor(int NoBegin, int NoEnd);
|
|
|
|
|
|
long ReplaceColor(COLORREF oldColor, COLORREF newColor);
|
|
|
|
|
|
|
|
|
|
|
|
static int GetImageType(LPCTSTR lpszImageName);
|
|
|
|
|
|
static void* GetSupportImageType(int* pOutCount); //<2F><><EFBFBD><EFBFBD>֧<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
void DrawCurve(void* pCurve, void *pZoom, COLORREF col);//CCurve* pCurve, CGrid* pZoom
|
|
|
|
|
|
void LineTo(CPoint point, COLORREF col);
|
|
|
|
|
|
void MoveTo(CPoint point);
|
|
|
|
|
|
//<2F><>x0Ϊ<30>ᣬ//IsPositive=0<><30><EFBFBD><EFBFBD><EFBFBD>ᣬ=1<><31><EFBFBD><EFBFBD><EFBFBD>ᣬ=2<><32><EFBFBD>߶<EFBFBD><DFB6><EFBFBD>
|
|
|
|
|
|
void DrawSolid(int x0, int x1, int x2, int y1, int y2, COLORREF col, int IsPositive);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>ģʽ
|
|
|
|
|
|
* <EFBFBD><EFBFBD>ģʽͨ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬʱ<EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD>״̬
|
|
|
|
|
|
*
|
|
|
|
|
|
* \return <EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ״̬
|
|
|
|
|
|
*/
|
|
|
|
|
|
uint32_t GetTransparentMode();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
|
|
|
|
|
*
|
|
|
|
|
|
* \param transparentMode <EFBFBD><EFBFBD>ģʽ
|
|
|
|
|
|
*/
|
|
|
|
|
|
void SetTransparentMode(uint32_t transparentMode);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
|
|
|
|
|
*
|
|
|
|
|
|
* \param transparentMode <EFBFBD><EFBFBD>ģʽ
|
|
|
|
|
|
*/
|
|
|
|
|
|
void ClearTransparentMode(uint32_t transparentMode);
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
bool Lut(BYTE* pTable);
|
|
|
|
|
|
CPoint PointBegin; //for MoveTo, LineTo
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
uint32_t m_transparentMode = 0;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
using namespace NImage;
|