Ku-Yaw Chang [email protected] Assistant Professor, Department of Computer Science and...
-
Upload
sharlene-barnett -
Category
Documents
-
view
216 -
download
3
Transcript of Ku-Yaw Chang [email protected] Assistant Professor, Department of Computer Science and...
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/292004/03/29 FreeImageFreeImage
OutlineOutline
IntroductionIntroduction
Add to Your ProjectAdd to Your Project
Load a JPEG fileLoad a JPEG file
Image PreparationImage Preparation
332004/03/292004/03/29 FreeImageFreeImage
IntroductionIntroduction
FreeImageFreeImage an Open Source library project an Open Source library project support popular graphics image formatssupport popular graphics image formats
PNG, BMP, JPEG, TIFF and others PNG, BMP, JPEG, TIFF and others two versions are availabletwo versions are available
a binary distribution a binary distribution
a source distributiona source distribution
WebsiteWebsite http://freeimage.sourceforge.net/http://freeimage.sourceforge.net/
442004/03/292004/03/29 FreeImageFreeImage
IntroductionIntroduction
FeaturesFeatures Ease of use.Ease of use.
The library has been designed to be extremely The library has been designed to be extremely simple in use. simple in use.
Our motto is: make difficult things simple instead of Our motto is: make difficult things simple instead of simple things difficult.simple things difficult.
Supports many formatsSupports many formatsBMP, JPEG, TIFF, PNG BMP, JPEG, TIFF, PNG
Etc…Etc…
552004/03/292004/03/29 FreeImageFreeImage
IntroductionIntroduction
Latest versionLatest version May 7th 2005 : FreeImage 3.7.0 releasedMay 7th 2005 : FreeImage 3.7.0 released
662004/03/292004/03/29 FreeImageFreeImage
Adding to Your ProjectAdding to Your Project
FreeImageFreeImage FreeImage.hFreeImage.h
Add to your projectAdd to your project FreeImage.libFreeImage.lib
Add to your projectAdd to your project FreeImage.dllFreeImage.dll
Under the same directory with your executable fileUnder the same directory with your executable file
Under the system directoryUnder the system directory C:\Windows\System32C:\Windows\System32
772004/03/292004/03/29 FreeImageFreeImage
Load a JPEG fileLoad a JPEG file
C***DocC***Doc #include “FreeImage.h”#include “FreeImage.h” OverrideOverride
BOOL C***Doc::OnOpenDocumentBOOL C***Doc::OnOpenDocument(LPCTSTR lpszPathName)(LPCTSTR lpszPathName)
882004/03/292004/03/29 FreeImageFreeImage
Load a JPEG fileLoad a JPEG file
Load and UnLoadLoad and UnLoad FIBITMAP * dib = FIBITMAP * dib =
FreeImage_Load(FIF_JPEG, lpszPathName, FreeImage_Load(FIF_JPEG, lpszPathName, JPEG_ACCURATE);JPEG_ACCURATE);
FreeImage_Unload(dib);FreeImage_Unload(dib);
992004/03/292004/03/29 FreeImageFreeImage
Load a JPEG fileLoad a JPEG file
Get Image InformationGet Image Information WidthWidth
FreeImage_GetWidth(dib);FreeImage_GetWidth(dib); HeightHeight
FreeImage_GetHeight(dib);FreeImage_GetHeight(dib); Size of one pixel in bitsSize of one pixel in bits
FreeImage_GetBPP(dib);FreeImage_GetBPP(dib);
10102004/03/292004/03/29 FreeImageFreeImage
Load a JPEG fileLoad a JPEG file
Access pixelsAccess pixels unsigned char * pScanLine = unsigned char * pScanLine =
FreeImage_GetScanLine(dib, nLine);FreeImage_GetScanLine(dib, nLine);
11112004/03/292004/03/29 FreeImageFreeImage
Load a JPEG fileLoad a JPEG file
for (int iLoop=0; iLoop<m_nHeight; iLoop++)for (int iLoop=0; iLoop<m_nHeight; iLoop++) {{
unsigned char * pScanLine = FreeImage_GetScanLine(dib, unsigned char * pScanLine = FreeImage_GetScanLine(dib,
(m_nHeight-1) - iLoop);(m_nHeight-1) - iLoop);
for (int jLoop=0; jLoop<m_nWidth; jLoop++)for (int jLoop=0; jLoop<m_nWidth; jLoop++) {{
*(m_pBImage+iLoop*m_nWidth+jLoop) = *(pScanLine+jLoop*3);*(m_pBImage+iLoop*m_nWidth+jLoop) = *(pScanLine+jLoop*3);
*(m_pGImage+iLoop*m_nWidth+jLoop) = *(pScanLine+jLoop*3+1);*(m_pGImage+iLoop*m_nWidth+jLoop) = *(pScanLine+jLoop*3+1);
*(m_pRImage+iLoop*m_nWidth+jLoop) = *(pScanLine+jLoop*3+2);*(m_pRImage+iLoop*m_nWidth+jLoop) = *(pScanLine+jLoop*3+2);
}}
}}
12122004/03/292004/03/29 FreeImageFreeImage
PreparationPreparation
ImageImage Format: JPGFormat: JPG Size: 600*300Size: 600*300 Content: PlateContent: Plate