Presentation is loading. Please wait.

Presentation is loading. Please wait.

Image Buffer Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.

Similar presentations


Presentation on theme: "Image Buffer Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University."— Presentation transcript:

1 Image Buffer Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University

2 22004/03/15Image Buffer Outline Tools library DocumentView

3 32004/03/15Image Buffer Logically Logically 2 dimensional array Physically (in memory) Physically (in memory) Usually 1 dimensional array

4 42004/03/15Image Buffer A 512 * 512 image (logically) 2-byte per pixel 2-byte per pixel Max gray level = 4095 Max gray level = 4095 W = 512 H = 512

5 52004/03/15Image Buffer A 512 * 512 image (physically) 2-byte per pixel 2-byte per pixel Create (allocate) short * pImage = (short *) malloc(512*512*sizeof(short)); short * pImage = (short *) malloc(512*512*sizeof(short)); Use (access) *(pImage+y*512+x) = 4095 *(pImage+y*512+x) = 4095 Destroy (free) free(pImage) free(pImage)

6 62004/03/15Image 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); void ShowImage_2B(CDC * pDC, short * pImage, int nWidth, int nHeight); Consisting of tools.lib tools.lib tools.h tools.h Adding these two files into your project.

7 72004/03/15Image Buffer Document C***Document : public CDocument Add data Image buffer Image buffer short * m_pImage; int m_nWidth; int m_nHeight; Add core functions short * GetImageBuffer() short * GetImageBuffer() int GetImageWidth() int GetImageWidth() int GetImageHeight() int GetImageHeight() Constructor (C***Document) Initialization Destructor (~C***Document) Release resources

8 82004/03/15Image Buffer View C***View : public CView Process WM_PAINT message #include “tools.h” #include “tools.h” C***View::OnDraw(CDC * pDC) { ShowImage_2B( pDC, pDoc->GetImageBuffer(), pDoc->GetImageWidth(), pDoc->GetImageHeight() ); } C***View::OnDraw(CDC * pDC) { ShowImage_2B( pDC, pDoc->GetImageBuffer(), pDoc->GetImageWidth(), pDoc->GetImageHeight() ); }

9 92004/03/15Image Buffer Result

10 102004/03/15Image Buffer Result


Download ppt "Image Buffer Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University."

Similar presentations


Ads by Google