11,706,142 members (61,827 online)
alternative version

# A C++ implementation of Douglas-Peucker Line Approximation Algorithm

, 3 Mar 2003 634.6K 11.3K 120
DP Line approximation algorithm is a well-known method to approximate 2D lines. It is quite fast, O(nlog_2(n)) for a n-points line and can drastically compress a data curve. Here, a fully OOP implementation is given.
 dphull_demo.zip DPAprrox.dsw douglas douglas.dsp GLDouglas Debug GLDouglas.res GLDouglas.clw Release GLDouglas.res GLDouglas.dsp res GLDouglas.ico GLDouglasDoc.ico Toolbar.bmp shrink.bmp lib Jpegmt.lib OGLToolsd.lib OGLTools.lib include dphull_doc.zip index.chm dphull_exe.zip GLDouglas.exe dphull_src.zip ``` #ifndef _CRGBSURFACE_H_ #define _CRGBSURFACE_H_ // Make integer i divideable by integer a #define ALIGN(i, a) (((i) + ((a) - 1))/(a)*(a)) // Convert from COLORREF to DIB's BGRA inline DWORD COLORREFtoBGRA(COLORREF cr, BYTE bAlpha = 255) { return ((DWORD(bAlpha)) << 24) + RGB(GetBValue(cr), GetGValue(cr), GetRValue(cr)); } inline DWORD ReverseRGB(COLORREF cr, BYTE bAlpha = 255) { return COLORREFtoBGRA(cr, bAlpha); } #define RGBA(b,g,r,a) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16))|(((DWORD)(BYTE)(a))<<24)) // 24 and 32 bit DIB's pixelformat #define BGR(b,g,r) ((COLORREF)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16))) #define BGRA(b,g,r,a) ((COLORREF)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16))|(((DWORD)(BYTE)(a))<<24)) /*! \brief A wraper to a 24 bit or 32 bit RGB DIB section GDI object. \ingroup OGLToolsGroup CRGBSurface is a wraper to a 24 bit or 32 bit RGB DIB section GDI object. After creating a RGB surface with one of its Create() methods, use GetDC() to access a surface thrugh it's DC or GetPixels() to directly access the surface RGB pixels. Use Draw() for easy drawing of RGB DIB section and CopyToClipboard() for copying or seting RGB DIB section to clipboard. Call DeleteDC() if you no longer need the surface's DC (Draw() and Blt() functions don't need it). With CRGBSurface you can:
1. Create an empty 24 or 32 bit RGB DIB section.
2. Convert a device dependent bitmap, passed as HBITMAP or CBitmap, to 24 or 32 RGB DIB section.
3. Create a 24 or 32 RGB DIB section from a DIB or JPEG file on disk.
4. Save a DIB section to disk in bitmap or JPEG format.
5. Draw() and Blt() a DIB section to a DC.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

A list of licenses authors might use can be found here