100 likes | 283 Views
Image Buffer. Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University. Outline. Image Buffer Tools library Document View. Image Buffer. Image Buffer Logically 2 dimensional array Physically (in memory)
E N D
Image Buffer Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University
Outline • Image Buffer • Tools library • Document • View Image Buffer
Image Buffer • Image Buffer • Logically • 2 dimensional array • Physically (in memory) • Usually 1 dimensional array Image Buffer
Image Buffer • A 512 * 512 image (logically) • 2-byte per pixel • Max gray level = 4095 W = 512 H = 512 Image Buffer
Image Buffer • A 512 * 512 image (physically) • 2-byte per pixel • Create (allocate) • short * pImage = (short *) malloc(512*512*sizeof(short)); • Use (access) • *(pImage+y*512+x) = 4095 • Destroy (free) • free(pImage) Image Buffer
Tools Library • Providing a function to display a 2-byte image buffer on the screen • void ShowImage_2B(CDC * pDC, short * pImage, int nWidth, int nHeight); • Consisting of • tools.lib • tools.h • Adding these two files into your project. Image Buffer
C***Document : public CDocument Add data Image buffer short * m_pImage; int m_nWidth; int m_nHeight; Add core functions short * GetImageBuffer() int GetImageWidth() int GetImageHeight() Constructor (C***Document) Initialization Destructor (~C***Document) Release resources Document Image Buffer
View • C***View : public CView • Process WM_PAINT message • #include “tools.h” • C***View::OnDraw(CDC * pDC){ ShowImage_2B( pDC, pDoc->GetImageBuffer(), pDoc->GetImageWidth(), pDoc->GetImageHeight() );} Image Buffer
Result Image Buffer
Result Image Buffer