You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
4.8 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//////////////////////////////////////////////////////////////////////////////
//文件 ImageInsert.h
//主要功能:
//
//程序编写: 2005-12-07
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include ".\pointnamerect.h"
#include ".\curveex.h"
#include "..\DrawImage\ImageBase.h"
#define IMAGE_CALIBRATE2 0x00000010 //两点校正图像
#define IMAGE_CALIBRATE4 0x00000020 //四点校正图像
#define IMAGE_CALIBRATE_H 0x00000040 //水平直线校正图像
#define IMAGE_CALIBRATE_V 0x00000080 //垂直直线校正图像
//图像中的透明度同时仅能支持一种
#define IMAGE_TRANSPARENT_AND 0x00020000 //位图透明与,下面两个显示方式很早就存在了,这里透明与虽然不与下面两种的数字连续了,但是至少保证了对以前图件的兼容
#define IMAGE_TRANSPARENT_ALPHA 0x00004000 //位图透明显示可设置不同颜色的不同透明度为了保持与CMesh中的相同
#define IMAGE_TRANSPARENT_COLOR 0x00008000 //位图透明显示,可指定一个颜色完全透明
#define IMAGE_TRANSPARENT_ALL (IMAGE_TRANSPARENT_AND | IMAGE_TRANSPARENT_ALPHA | IMAGE_TRANSPARENT_COLOR)
class AFX_EXT_CLASS CImageInsert : public CPointNameRect
{
public:
CImageInsert(void);
virtual ~CImageInsert(void);
public:
BOOL BeforeWrite();
void ClearImage(void);
int ReadBitmap(CFile& fr);
void Serialize(CArchive& ar, const short &ver) override;
virtual int Read(CFile& fr, const short& ver);
int ReadOld(CFile& fr, const short& ver);
virtual void Write(CFile& fw, const short& ver);
virtual void Clear(void);
// type为校正类型,比如两点校位、四点校位、直线校位等;pValue为类对象指针如CCalibrate2、CCalibrate4等
virtual void Calibrate(int type, void* pValue);
virtual void ExchangeXY(void* pProjection); //转换到指定投影坐标,CPrljectio* pProjection
virtual void Rotate(double xs, double ys, double angle);
virtual void ScaleProperty(double sx, double sy);
void WriteElementDML(BYTE*& outBuffer, int& destLen);
virtual void WriteDML(CFile& fw, const short& ver, int nBaseTabNum);
virtual int ReadDML(CFile &fr, const short &ver);
virtual void WritePCG(CFile& fw, const short& ver, int nBaseTabNum);
virtual int ReadPCG(CFile &fr, const short &ver);
virtual int ReadPCG2(CFile &fr, const short &ver);
BOOL CutOut(CCurveEx* pCurve); //剪裁图片
BOOL CutIn(CCurveEx* pCurve,COLORREF bkColor=RGB(255,255,255)); //将指定区域内的像素清除为指定颜色
CImageInsert* GetImage(int i_left, int j_top, int i_right, int j_bottom); //从当前图片中切指定区域的图片
BOOL Draw(CDC& hDestDC, CRect8& rectDest, CRect* clientRect);
void operator=(CImageInsert& ii);
BOOL LoadImage(CString strImageName);
BOOL SaveAs(LPCTSTR lpszImageName);
BOOL PastFromClipboard(void); //从剪切板上粘贴图像
BOOL CopyToClipboard(HWND hWnd=NULL);
int BackupImage(void);
void RestoreImage(void);
int ProcessImageColor(int nColorType);
int ProcessImage(CImageBase* pi, int nColorType);
int GrayColor(void); //处理为灰度图像
int TowColor(int NoBegin, int NoEnd);
int PseudoColor(int nMode); //伪彩色处理,1=医学2,3=遥感
int RotateLeft90(void); //向左旋转90度
int RotateRight90(void); //向右旋转90度
bool IsBrightProcess(void); //包括Gamma和Light
bool Gamma(int gamma); //-100至+100,0为不变
bool Light(long brightness, long contrast=0); //亮度与对比度
CImageBase* GetImage(void);
void SetImage(CImageBase* pImage);
CPoint RealToImagePoint(double x, double y);
CPoint2D RealToImagePoint2D(double x, double y);
CPoint2D ImagePointToReal(int x, int y);
void RealToImagePoint(CPoint& pt, double x, double y);
void RealToImagePoint2D(CPoint2D& pt, double x, double y);
void ImagePointToReal(CPoint2D& pt, int x, int y);
DWORD GetCalibratedMode(void); //获得校正图像方式
void SetCalibratedMode(DWORD nMode); //设置校正图像方式
void SetFlags(DWORD dwFlags);
DWORD GetFlags(void);
BOOL IsTransparent(void); //是否透明显示
void SetTransparentMode(DWORD nMode); //设置透明模式
DWORD GetTransparentMode(void); //获得透明模式
void SetTransparentColor(COLORREF col);//设置透明色
COLORREF GetTransparentColor(void);
bool SetAlpha(BYTE level); //设置透明度0-255
void RemoveAlpha(void);
public:
//仅是为了对比度与亮度
long m_brightness;
long m_contrast;
CImageBase* m_pImage;
dfPoint Original4P[4], Real4P[4];
CRect8 Original2P;
CRect8 Real2P;
BOOL bSaveCalibrateBitmap;
BOOL bSaveFlag,bCancelRead;
protected:
int CalibrateOther(int type, void* pValue);
void CalibrateLine(int type, void* pValue);
BOOL LoadImageAuto(LPCTSTR strImageName); //读函数中调用的图像加载函数
protected:
DWORD m_nFlags;//校正位图方式,是否透明显示,....
COLORREF m_colTransparent; //透明色,缺省为白色
private:
CWinThread* m_pProcessImageThread;
int m_pImageBakType;
CImageBase* m_pBakImage;
public:
virtual int ReadPCG(void *pxp, const short &ver);
virtual int ReadPCG2(void *pxp, const short &ver);
};
AFX_INLINE CImageBase* CImageInsert::GetImage(void)
{
return m_pImage;
}