image buffer ku-yaw chang [email protected] assistant professor, department of computer...

10
Image Buffer Image Buffer Ku-Yaw Chang Ku-Yaw Chang [email protected] [email protected] Assistant Professor, Department of Assistant Professor, Department of Computer Science and Information Engineering Computer Science and Information Engineering Da-Yeh University Da-Yeh University

Upload: kristian-moore

Post on 27-Dec-2015

214 views

Category:

Documents


1 download

TRANSCRIPT

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

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

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

222004/03/152004/03/15 Image BufferImage Buffer

OutlineOutline

Image BufferImage Buffer

Tools libraryTools library

DocumentDocument

ViewView

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

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

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

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

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

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)

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

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.

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

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

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

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() );}}

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

992004/03/152004/03/15 Image BufferImage Buffer

ResultResult

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

10102004/03/152004/03/15 Image BufferImage Buffer

ResultResult