Upload
kristian-moore
View
214
Download
1
Embed Size (px)
Citation preview
Image BufferImage Buffer
Ku-Yaw ChangKu-Yaw [email protected]@mail.dyu.edu.tw
Assistant Professor, Department of Assistant Professor, Department of Computer Science and Information EngineeringComputer Science and Information Engineering
Da-Yeh UniversityDa-Yeh University
222004/03/152004/03/15 Image BufferImage Buffer
OutlineOutline
Image BufferImage Buffer
Tools libraryTools library
DocumentDocument
ViewView
332004/03/152004/03/15 Image BufferImage Buffer
Image BufferImage Buffer
Image BufferImage Buffer LogicallyLogically
2 dimensional array2 dimensional array Physically (in memory)Physically (in memory)
Usually 1 dimensional arrayUsually 1 dimensional array
442004/03/152004/03/15 Image BufferImage Buffer
Image BufferImage Buffer
A 512 * 512 image (logically)A 512 * 512 image (logically) 2-byte per pixel2-byte per pixel Max gray level = 4095 Max gray level = 4095
W = 512
H = 512
552004/03/152004/03/15 Image BufferImage Buffer
Image BufferImage Buffer
A 512 * 512 image (physically)A 512 * 512 image (physically) 2-byte per pixel 2-byte per pixel
Create (allocate)Create (allocate) short * pImage = (short *)short * pImage = (short *)
malloc(512*512*sizeof(short)); malloc(512*512*sizeof(short));
Use (access)Use (access) *(pImage+y*512+x) = 4095*(pImage+y*512+x) = 4095
Destroy (free)Destroy (free) free(pImage)free(pImage)
662004/03/152004/03/15 Image BufferImage Buffer
Tools LibraryTools Library
Providing a function to display a 2-byte Providing a function to display a 2-byte image buffer on the screenimage buffer on the screen void ShowImage_2B(CDC * pDC, short * void ShowImage_2B(CDC * pDC, short *
pImage, int nWidth, int nHeight);pImage, int nWidth, int nHeight);
Consisting ofConsisting of tools.libtools.lib tools.htools.h
Adding these two files into your project.Adding these two files into your project.
772004/03/152004/03/15 Image BufferImage Buffer
DocumentDocument
C***Document : public CDocumentC***Document : public CDocument
Add dataAdd data Image bufferImage buffer
short * m_pImage;short * m_pImage;
int m_nWidth;int m_nWidth;
int m_nHeight;int m_nHeight;
Add core functionsAdd core functions short * GetImageBuffer()short * GetImageBuffer() int GetImageWidth()int GetImageWidth() int GetImageHeight()int GetImageHeight()
Constructor (C***Document)Constructor (C***Document)InitializationInitialization
Destructor (~C***Document)Destructor (~C***Document)Release resourcesRelease resources
882004/03/152004/03/15 Image BufferImage Buffer
ViewView
C***View : public CViewC***View : public CView
Process WM_PAINT messageProcess WM_PAINT message #include “tools.h”#include “tools.h” C***View::OnDraw(CDC * pDC)C***View::OnDraw(CDC * pDC)
{{ ShowImage_2B( ShowImage_2B( pDC, pDC, pDoc->GetImageBuffer(), pDoc->GetImageBuffer(), pDoc->GetImageWidth(), pDoc->GetImageWidth(), pDoc->GetImageHeight() ); pDoc->GetImageHeight() );}}
992004/03/152004/03/15 Image BufferImage Buffer
ResultResult
10102004/03/152004/03/15 Image BufferImage Buffer
ResultResult