資源簡(jiǎn)介
Tiff圖像壓縮。TIFF格式,全稱(chēng)Tagged Image File Format(標(biāo)簽圖像文件格式),文件擴(kuò)展名為tif或tiff,是一種比較靈活的圖像格式。TIFF格式支持256色、24位真彩色、32位色、48位色等多種色彩位,在此同時(shí)支持RGB、CMYK以及YCBCR等多種色彩模式,支持多平臺(tái)等。它可以顯示上百萬(wàn)的顏色(盡管灰度圖像僅局限于 256 色或底紋),通常用于比GIF或JPEG格式更大的圖像文件。

代碼片段和文件信息
//?Image.cpp:?implementation?of?the?CImage?class.
//
//////////////////////////////////////////////////////////////////////
#include?“stdafx.h“
?
CImage::CImage()
{
hBitmap=NULL;
hMemDC=NULL;
}
CImage::~CImage()
{
Destroy();
}
void?CImage::Create(int?Dxint?Dyint?BitsDWORD?dwFlags)
{
???BITMAPINFOHEADER?BIH?=?{400010000000??}?;
???LPBITMAPINFO ????lpBmi;
????
???nWidth?=?Dx;
???nHeight?=?Dy;
???nBitCount=?Bits;
???nBytesPerLine?=?(nWidth*nBitCount+31)/32*4;
???nBytesPerPixel?=?nBitCount/8;
???if?(nBitCount>8)?nNumColors=0;
???else??nNumColors=1< ???nSize=nBytesPerLine*nHeight;
???BIH.biWidth=nWidth;????
???BIH.biHeight=nHeight; ??????
???BIH.biBitCount=nBitCount;
???
???lpBmi=(LPBITMAPINFO)?malloc(40+4*nNumColors);
???memcpy(lpBmi&BIH40);
?
???hBitmap=CreateDIBSection(NULLlpBmiDIB_RGB_COLORS
?????????????????????????(VOID**)?&lpBitsNULL0);
???free(lpBmi);
}
BOOL??CImage::IsNull()
{
if?(hBitmap==NULL)
return(TRUE);
else
return(FALSE);
}
BOOL??CImage::Load(const?CString?csFileName)
{
BOOL?bFlag;
char?drive[_MAX_DRIVE];???
char?dir[_MAX_DIR];
char?fname[_MAX_FNAME];???
char?ext[_MAX_EXT];
?
_splitpath(csFileName?drive?dir?fname?ext);???
??if?(!?stricmp(ext?“.bmp“))?
bFlag=LoadBMP(csFileName);
??else?if?(!?stricmp(ext?“.tif“))?
bFlag=LoadTIF(csFileName);
??? return(bFlag);
}
BOOL??CImage::Save(const?CString?csFileName)
{
BOOL bFlag;
char drive[_MAX_DRIVE];???
char dir[_MAX_DIR];
char fname[_MAX_FNAME];???
char ext[_MAX_EXT];
???????
_splitpath(csFileName?drive?dir?fname?ext);???
??if?(!?stricmp(ext?“.tif“))?
bFlag=SaveTIF(csFileName);
??? return(bFlag);
}
void??CImage::Destroy()
{
????if?(hBitmap!=NULL)?{
Deleteobject(hBitmap);
??? hBitmap=NULL;
}
}
BYTE*?CImage::GetPixelAddress(int?xint?y)
{
return(lpBits+(nHeight-1-y)*nBytesPerLine+x*nBytesPerPixel);
}
COLORREF?CImage::GetPixel(int?xint?y)
{
LPBYTE lpBuf;
DWORD dwValue=0;
RGBQUAD ColorTab;
lpBuf=(LPBYTE)lpBits+(nHeight-1-y)*nBytesPerLine+x*nBytesPerPixel;
memcpy(&dwValuelpBufnBytesPerPixel);
if?(nBitCount<=8)?{
GetColorTable(dwValue1&ColorTab);
dwValue=RGB(ColorTab.rgbRed
????ColorTab.rgbGreenColorTab.rgbBlue);
}
else?{
dwValue=RGB((dwValue&0xff0000)>>16
????(dwValue&0xff00)>>8dwValue&0xff);
}
return(dwValue);
}
int???CImage::GetWidth()
{
return(nWidth);
}
int???CImage::GetHeight()
{
return(nHeight);
}
int???CImage::GetBPP()
{
return(nBitCount);
}
int ??CImage::GetPitch()
{
return(GetPixelAddress(01)-GetPixelAddress(00));
}?
int ??CImage::GetMaxColorTableEntries()
{
if?(nNumColors>256)?return(256);
return(nNumColors);
}
void??CImage::GetColorTable(int?m?int?n?RGBQUAD*?ColorTab)
{
HDC hMemDC;
????hMemDC?=CreateCompatibleDC(NULL);?
????Selectobject(hMemDChBitmap);
? GetDIBColorTable(hMemDCmnColorTab);
????Delete
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件??????28672??2012-11-13?22:22??程序\111\111.aps
?????文件???????2311??2012-11-13?22:22??程序\111\111.clw
?????文件???????4183??2012-11-13?22:22??程序\111\111.cpp
?????文件???????5389??2012-11-13?22:22??程序\111\111.dsp
?????文件????????512??2012-11-13?22:22??程序\111\111.dsw
?????文件???????1333??2012-11-13?22:22??程序\111\111.h
?????文件?????123904??2012-11-13?22:22??程序\111\111.ncb
?????文件??????54784??2012-11-13?22:22??程序\111\111.opt
?????文件????????240??2012-11-13?22:22??程序\111\111.plg
?????文件??????11756??2012-11-13?22:22??程序\111\111.rc
?????文件???????3169??2012-11-13?22:22??程序\111\111Doc.cpp
?????文件???????1382??2012-11-13?22:22??程序\111\111Doc.h
?????文件???????3002??2012-11-13?22:22??程序\111\111View.cpp
?????文件???????1865??2012-11-13?22:22??程序\111\111View.h
?????文件?????139301??2012-11-13?22:22??程序\111\Debug\111.exe
?????文件?????357420??2012-11-13?22:22??程序\111\Debug\111.ilk
?????文件??????22582??2012-11-13?22:22??程序\111\Debug\111.obj
?????文件????5505112??2012-11-13?22:26??程序\111\Debug\111.pch
?????文件?????369664??2012-11-13?22:22??程序\111\Debug\111.pdb
?????文件???????7236??2012-11-13?22:22??程序\111\Debug\111.res
?????文件??????29454??2012-11-13?22:22??程序\111\Debug\111Doc.obj
?????文件??????20121??2012-11-13?22:22??程序\111\Debug\111View.obj
?????文件??????20897??2012-11-13?22:22??程序\111\Debug\Image.obj
?????文件??????13832??2012-11-13?22:22??程序\111\Debug\ImageFile.obj
?????文件??????11436??2012-11-13?22:22??程序\111\Debug\ImageTypeTransfer.obj
?????文件??????19630??2012-11-13?22:22??程序\111\Debug\MainFrm.obj
?????文件?????105417??2012-11-13?22:22??程序\111\Debug\StdAfx.obj
?????文件?????205824??2012-11-13?22:22??程序\111\Debug\vc60.idb
?????文件?????364544??2012-11-13?22:22??程序\111\Debug\vc60.pdb
?????文件???????4206??2012-11-13?22:22??程序\111\Image.cpp
............此處省略43個(gè)文件信息
評(píng)論
共有 條評(píng)論