-
大小: 1.87MB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2023-08-30
- 語言: 其他
- 標簽:
資源簡介
C實現(xiàn)的JPEG編碼源代碼,決定真實,里面我已經(jīng)做了詳細的注釋了,大家結(jié)合網(wǎng)上的一些文章,看懂源代碼是沒問題的

代碼片段和文件信息
#include?
#include?
#include?
#include?“BMP.h“
//創(chuàng)建一個設備無關(guān)位圖結(jié)構(gòu)
void?CreateDIB(DIB_Type?*DIB?BMP_Header?*image)
{
WORD?n;
DIB->width?=?image->infoHeader.biWidth;
DIB->height?=?image->infoHeader.biHeight;
DIB->bitCount?=?image->infoHeader.biBitCount; //每個像素所需的位數(shù)
n?=?DIB->width*DIB->bitCount;
if?(n%32?==?0)
DIB->bpl?=?n/8;
else???????????????????????????//DIB->bpl=提取出文件中每行的字節(jié)數(shù)
?? DIB->bpl?=?n/8+(4-(n/8)%4);//Windows規(guī)定一個掃描行所占的字節(jié)數(shù)必須是?4的倍數(shù)(即以long為單位)不足的以0填充。
if?(DIB->bitCount?<=?8)
DIB->palCount?=?1<<(DIB->bitCount); //判斷是否有調(diào)色板,并得出調(diào)色板數(shù)據(jù)的總數(shù)
else
DIB->palCount?=?0;
DIB->picSize?=?DIB->bpl*DIB->height; //得出BMP里存儲的位圖總數(shù)據(jù),單位字節(jié)
DIB->offSet?=?image->fileHeader.bfOffBits-14;
? DIB->lpbmi?=?(LPBITMAPINFO)malloc(40+sizeof(RGBQUAD)*DIB->palCount+DIB->picSize);
? DIB->lpvbits?=?(BYTE?*)DIB->lpbmi+DIB->offSet;
? DIB->lpvbits?=?(BYTE?*)DIB->lpbmi+DIB->offSet;
?
? memcpy(DIB->lpbmi?&image->infoHeader?40);
? if?(DIB->palCount?>?0)
? {
? fseek(image->fp?14+40?SEEK_SET);
? fread((BYTE?*)DIB->lpbmi+40?sizeof(RGBQUAD)?DIB->palCount?image->fp);
}
? fseek(image->fp?14+DIB->offSet?SEEK_SET);
? fread(DIB->lpvbits?sizeof(BYTE)?DIB->picSize?image->fp);//DIB->lpvbits存儲的是位圖的所有數(shù)據(jù)
}
//刪除位圖結(jié)構(gòu)
void?DeleteDIB(DIB_Type?*DIB)
{
free(DIB->lpbmi);
DIB->hDIB?=?NULL;
}
//讀入BMP文件
int?LoadBMPHeader(BMP_Header?*image?char?*fileName)
{
image->fp?=?fopen(fileName?“rb“);
if?(image->fp?==?NULL)
return?-1;//ERR_FILE_CANT_OPEN;
fseek(image->fp?0?SEEK_SET);
fread(&(image->fileHeader)?sizeof(BITMAPFILEHEADER)?1?image->fp);
fread(&(image->infoHeader)?sizeof(BITMAPINFOHEADER)?1?image->fp);
if?(strncmp((char?*)&(image->fileHeader.bfType)?“BM“?2)?!=?0)
{
fclose(image->fp);
return?-1;//ERR_FMT_NOT_BMP
}
if?(image->infoHeader.biCompression)
{
fclose(image->fp);
return?-1;//ERR_FMT_COMPRESSION
}
return?0;
}
//關(guān)閉BMP文件
void?CloseBMPHeader(BMP_Header?*image)
{
fclose(image->fp);
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????5169??2010-04-07?14:23??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\020876LvWentao.dsp
?????文件????????536??2005-06-05?16:53??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\020876LvWentao.dsw
?????文件?????173056??2010-04-10?11:54??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\020876LvWentao.ncb
?????文件??????87040??2010-04-10?11:54??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\020876LvWentao.opt
?????文件???????1822??2010-04-10?01:22??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\020876LvWentao.plg
?????文件???????2159??2010-04-07?23:06??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\BMP.cpp
?????文件????????750??2005-06-05?17:48??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\BMP.h
?????文件???????8062??2010-04-09?23:52??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Coding.cpp
?????文件????????759??2010-04-08?00:05??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Coding.h
?????文件???????2225??2010-04-08?22:22??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\ColorSpace.cpp
?????文件????????739??2005-06-05?17:46??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\ColorSpace.h
?????文件???????4494??2005-06-05?18:26??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\DCT.cpp
?????文件???????1007??2005-06-05?18:11??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\DCT.h
?????文件????3138560??2010-04-10?01:22??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Debug\020876LvWentao.bsc
?????文件?????237721??2010-04-10?01:22??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Debug\020876LvWentao.exe
?????文件?????244568??2010-04-10?01:22??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Debug\020876LvWentao.ilk
?????文件?????205436??2010-04-10?00:47??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Debug\020876LvWentao.pch
?????文件?????566272??2010-04-10?01:22??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Debug\020876LvWentao.pdb
?????文件????1197654??2010-04-07?20:35??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Debug\1.bmp
?????文件????1197654??2010-04-09?23:03??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Debug\111.bmp
?????文件??????14948??2010-04-08?00:23??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Debug\BMP.obj
?????文件??????????0??2010-04-08?00:23??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Debug\BMP.sbr
?????文件??????22828??2010-04-10?00:47??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Debug\Coding.obj
?????文件??????????0??2010-04-10?00:47??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Debug\Coding.sbr
?????文件??????16930??2010-04-08?22:29??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Debug\ColorSpace.obj
?????文件??????????0??2010-04-08?22:29??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Debug\ColorSpace.sbr
?????文件??????13223??2010-04-07?20:36??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Debug\DCT.obj
?????文件??????????0??2010-04-07?20:36??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Debug\DCT.sbr
?????文件???????8304??2010-04-10?00:47??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Debug\Huffman.obj
?????文件??????????0??2010-04-10?00:47??C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\C實現(xiàn)的完全有用的jpeg編碼\020876LvWentao\Debug\Huffman.sbr
............此處省略23個文件信息
評論
共有 條評論