dibsect.h
上传用户:lbr_007
上传日期:2019-05-31
资源大小:282k
文件大小:3k
- #ifndef __DIB_SECTION_CLASS_NCLUDE_H__
- #define __DIB_SECTION_CLASS_NCLUDE_H__
- class GEORef {
- void initGeoRef(void)
- {
- }
- public:
- enum Projections {
- UnknownPrj,
- UTM
- };
- enum Ellipsoids { // some common ellipsoids
- UnknownEllipsoid,
- Clarke1866,
- GRS80,
- IAU76,
- AIRY,
- WGS72,
- WGS84,
- Sphere
- };
- double m_tieX;
- double m_tieY;
- double m_resX;
- double m_resY;
- UINT32 m_rows;
- UINT32 m_cols;
- INT32 m_zone;
- Projections m_proj;
- Ellipsoids m_ellipse;
- GEORef(void)
- {
- m_tieX = m_tieY = m_resX = m_resY = 0.0;
- m_zone = 0;
- m_proj = UnknownPrj;
- m_ellipse = UnknownEllipsoid;
- }
- GEORef(const GEORef& gr)
- {
- m_tieX = m_tieY = m_resX = m_resY = 0.0;
- m_zone = 0;
- m_proj = UnknownPrj;
- m_ellipse = UnknownEllipsoid;
- Copy(gr);
- }
- ~GEORef(void){}
- void Copy(const GEORef& gr)
- {
- m_tieX = gr.m_tieX;
- m_tieY = gr.m_tieY;
- m_resX = gr.m_resX;
- m_resY = gr.m_resY;
- m_zone = gr.m_zone;
- m_proj = gr.m_proj;
- m_ellipse = gr.m_ellipse;
- m_rows = gr.m_rows;
- m_cols = gr.m_cols;
- }
- GEORef& operator = (const GEORef& gr)
- {
- Copy(gr);
- return *this;
- }
- };
- //
- // DIBSection -
- //
- // Encapsulates a DIB section and a DC.
- //
- class DIBSection
- {
- void InitObject(void);
- protected:
- HBITMAP m_hbmp;
- HBITMAP m_hbmOld;
- void* m_pBits;
- CSize m_size;
- CDC* m_pdc;
- int m_total_width;
- BITMAPINFOHEADER m_bih;
- unsigned long m_bitcount;
- bool m_geoFlag;
- GEORef m_geoRef;
- public:
- DIBSection();
- DIBSection(const DIBSection& dib);
- virtual ~DIBSection();
- void Copy(const DIBSection& dib);
- DIBSection& operator=(const DIBSection& dib);
- void Close(void);
- int IsCreated(void)const{ return (m_pBits?1:0);}
- // Create a DIBSection
- void Create(int cx, int cy, int nbits );
- // Draw method
- void Draw(CDC* pdcDest, int x, int y);
- // Resize method
- void ResizeImage(DIBSection& dst_dib, int w, int h);
- // patblt method
- void PatBlt(DWORD pattern);
- CDC* GetDC() {return m_pdc;}
- HBITMAP GetHandle() {return m_hbmp;}
- unsigned long Width(void)const{ return m_size.cx;}
- unsigned long Height(void)const{ return m_size.cy;}
- unsigned long GetTotalWidth(void)const{ return m_total_width;}
- void * GetBits(void){ return m_pBits;}
- void * GetConstBits(void)const{ return m_pBits;}
- BITMAPINFOHEADER& GetBIH(void){ return m_bih;}
- unsigned long GetBitCount(void)const{ return m_bitcount;}
- void SetPixel(UINT32 x, UINT32 y, COLORREF cr);
- void GetPixel(UINT32 x, UINT32 y, COLORREF& cr);
- void HistogramEqualization(DIBSection& dib);
- void Greyscale(DIBSection& dib);
- void Lighten(INT32 amt);
- bool IsGeoImage(void)const{ return m_geoFlag;}
- void SetGeoReference(GEORef& r){ m_geoRef = r; m_geoFlag = true;}
- GEORef& GetGeoReference(void){ return m_geoRef;}
- GEORef GetConstGeoReference(void)const{ return m_geoRef;}
- };
- #endif