Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University
22004/03/29FreeImage Outline Introduction Add to Your Project Load a JPEG file Image Preparation
32004/03/29FreeImage Introduction FreeImage an Open Source library project an Open Source library project support popular graphics image formats support popular graphics image formats PNG, BMP, JPEG, TIFF and others two versions are available two versions are available a binary distribution a source distribution Website
42004/03/29FreeImage Introduction Features Ease of use. Ease of use. The library has been designed to be extremely simple in use. Our motto is: make difficult things simple instead of simple things difficult. Supports many formats Supports many formats BMP, JPEG, TIFF, PNG Etc… Etc…
52004/03/29FreeImage Introduction Latest version May 7th 2005 : FreeImage released May 7th 2005 : FreeImage released
62004/03/29FreeImage Adding to Your Project FreeImage FreeImage.h FreeImage.h Add to your project FreeImage.lib FreeImage.lib Add to your project FreeImage.dll FreeImage.dll Under the same directory with your executable file Under the system directory C:\Windows\System32 C:\Windows\System32
72004/03/29FreeImage Load a JPEG file C***Doc #include “FreeImage.h” #include “FreeImage.h” Override BOOL C***Doc::OnOpenDocument (LPCTSTR lpszPathName) Override BOOL C***Doc::OnOpenDocument (LPCTSTR lpszPathName)
82004/03/29FreeImage Load a JPEG file Load and UnLoad FIBITMAP * dib = FreeImage_Load(FIF_JPEG, lpszPathName, JPEG_ACCURATE); FIBITMAP * dib = FreeImage_Load(FIF_JPEG, lpszPathName, JPEG_ACCURATE); FreeImage_Unload(dib); FreeImage_Unload(dib);
92004/03/29FreeImage Load a JPEG file Get Image Information Width WidthFreeImage_GetWidth(dib); Height HeightFreeImage_GetHeight(dib); Size of one pixel in bits Size of one pixel in bitsFreeImage_GetBPP(dib);
102004/03/29FreeImage Load a JPEG file Access pixels unsigned char * pScanLine = FreeImage_GetScanLine(dib, nLine); unsigned char * pScanLine = FreeImage_GetScanLine(dib, nLine);
112004/03/29FreeImage Load a JPEG file for (int iLoop=0; iLoop<m_nHeight; iLoop++){ unsigned char * pScanLine = FreeImage_GetScanLine(dib, (m_nHeight-1) - iLoop); for (int jLoop=0; jLoop<m_nWidth; jLoop++){ *(m_pBImage+iLoop*m_nWidth+jLoop) = *(pScanLine+jLoop*3); *(m_pGImage+iLoop*m_nWidth+jLoop) = *(pScanLine+jLoop*3+1); *(m_pRImage+iLoop*m_nWidth+jLoop) = *(pScanLine+jLoop*3+2); }}
122004/03/29FreeImage Preparation Image Format: JPG Format: JPG Size: 600*300 Size: 600*300 Content: Plate Content: Plate