資源簡介
1、jpeg-test-arm目錄下是測試修改后的動態庫程序
2、libjpeg目錄下是修改后的libjpeg源碼
3、libjpeg.so.62.0.0是交叉編譯修改libjpeg源碼生成的動態庫,arm平臺下的。
4、具體修改步驟參考如下地址
http://www.cnblogs.com/pang1567/p/3683601.html

代碼片段和文件信息
#include?
#include?
#include?“jpeglib.h“
#include?“li_bitmap.h“
#include?
#include
//void?bmp2jpeg(const?char?*strSourceFileName?const?char?strDestFileName)?;
void
bmp2jpeg(const?char?*strSourceFileName?const?char?*strDestFileName)
{
????BITMAPFILEHEADER?bfh?;??//位圖文件頭
????BITMAPINFOHEADER?bih?;??//位圖頭信息
????RGBQUAD?rq[256]?;????//調色板
????int?nAdjust; //?用于字節對齊
????//char?outdata[2000000]?;?//用戶緩存,存放將要壓縮的jpeg文件
????char?*?outdata?=?(char?*)malloc(2000000)?;
????int?nSize; //?用于存放壓縮完后圖像數據的大小
BYTE?*data=?NULL;//new?BYTE[bih.biWidth*bih.biHeight];//?這個data用于存放未壓縮前的圖像數據
int?nComponent?=?0;
????FILE?*f?=?fopen(strSourceFileName“rb“);?//打開要壓縮的源bmp文件
if?(f==NULL)
{
perror(“Open?bmpsrc?file?error!“);
return;
}
//?讀取文件頭
fread(&bfhsizeof(bfh)1f);
//?讀取圖像信息
fread(&bihsizeof(bih)1f);
switch?(bih.biBitCount)
{
case?8:
if?(bfh.bfOffBits-1024<54)?//表示文件頭(14)和信息頭(40)的字節數不夠,顯然不是位圖文件
{
fclose(f);
return;
}
//?8位字節對齊
nAdjust?=?bih.biWidth%4;
if?(nAdjust)?nAdjust?=?4-nAdjust;
//data=?new?BYTE[(bih.biWidth+nAdjust)*bih.biHeight];
????????data?=?(BYTE?*)?malloc((bih.biWidth+nAdjust)*bih.biHeight)?;
//?定位調色板,并讀取調色板,調色板字節數1024個字節
fseek(fbfh.bfOffBits-1024SEEK_SET);
fread(rqsizeof(RGBQUAD)256f);
//?讀取位圖
fread(data(bih.biWidth+nAdjust)*bih.biHeight1f);
fclose(f);
nComponent?=?1;
break;
case?24:
{
//?8位字節對齊
nAdjust?=?bih.biWidth*3%4;
if?(nAdjust)?nAdjust?=?4-nAdjust;
//data=?new?BYTE[(bih.biWidth*3+nAdjust)*bih.biHeight];
data?=?(BYTE?*)?malloc((bih.biWidth*3+nAdjust)*bih.biHeight)?;
fseek(fbfh.bfOffBitsSEEK_SET);
fread(data(bih.biWidth*3+nAdjust)*bih.biHeight1f);
fclose(f);
int?i?=?0?j?=?0?;
for?(j=0;j for?(i?=?0;i {
BYTE?red?=?data[j*(bih.biWidth*3+nAdjust)+i*3];
data[j*(bih.biWidth*3+nAdjust)+i*3]?=?data[j*(bih.biWidth*3+nAdjust)+i*3+2];
data[j*(bih.biWidth*3+nAdjust)+i*3+2]?=?red;
}
}
nComponent?=?3;
break;
}
default:
fclose(f);
return;
}
printf(“bmp?file?is?%d?byte?\n“?bfh.bfSize)?;
struct?jpeg_compress_struct?jcs;??//位圖壓縮結構體
struct?jpeg_error_mgr?jem;??//出錯處理結構體
jcs.err?=?jpeg_std_error(&jem);
????????/*開始計時*/
????clock_t?start?finish;
????double?duration;
????start?=?clock()?;??//start?count?the??time
jpeg_create_compress(&jcs);
jpeg_stdio_dest(&jcs?outdata&nSize);
//jpeg_stdio_dest(&jcsf1);
jcs.image_width?=?bih.biWidth;? //?位圖的寬和高,單位為像素
jcs.image_height?=?bih.biHeight;
jcs.input_components?=?nComponent; //?1表示灰度圖,?如果是彩色位圖,則為3
if?(nComponent==1)
jcs.in_color_space?=?JCS_GRAYSCALE;?//JCS_GRAYSCALE表示灰度圖,JCS_RGB表示彩色圖像
else
jcs.in_color_space?=?JCS_RGB;
jpeg_set_defaults(&jcs);
jpeg_set_quality?(&jcs?99?true);
jpeg_start_compress(&jcs?TRUE);
JSAMPROW?row_pointer[1]; //?一行位圖
int?row_stride; //?每一行的字節數
row_stride?=?jcs.image_width*nComponent; //?如果不是索引圖此處需要乘以3
//?對每一行進行壓縮
while?(jcs.next_scanline?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????24296??2014-09-21?01:23??libjpeg-mem\jpeg-test-arm\.objs\main.o
?????文件???????1253??2014-09-21?01:23??libjpeg-mem\jpeg-test-arm\jconfig.h
?????文件??????12458??2014-09-21?01:23??libjpeg-mem\jpeg-test-arm\jmorecfg.h
?????文件??????46358??2014-09-21?01:23??libjpeg-mem\jpeg-test-arm\jpeglib.h
?????文件?????156761??2014-09-21?01:23??libjpeg-mem\jpeg-test-arm\libjpeg.so.62.0.0
?????文件????????894??2014-09-21?01:23??libjpeg-mem\jpeg-test-arm\li_bitmap.h
?????文件??????19612??2014-09-21?01:23??libjpeg-mem\jpeg-test-arm\main
?????文件???????9134??2014-09-21?01:23??libjpeg-mem\jpeg-test-arm\main.c
?????文件???????1392??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\cdjpeg.o
?????文件??????33510??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\cjpeg
?????文件??????12252??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\cjpeg.o
?????文件??????28991??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\djpeg
?????文件??????13264??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\djpeg.o
?????文件???????2876??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\jcapimin.o
?????文件???????1924??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\jcapistd.o
?????文件???????4120??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\jccoefct.o
?????文件???????3456??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\jccolor.o
?????文件???????3888??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\jcdctmgr.o
?????文件???????8048??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\jchuff.o
?????文件???????1576??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\jcinit.o
?????文件???????1708??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\jcmainct.o
?????文件???????4248??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\jcmarker.o
?????文件???????5596??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\jcmaster.o
?????文件???????1216??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\jcomapi.o
?????文件???????6268??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\jcparam.o
?????文件???????9452??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\jcphuff.o
?????文件???????3164??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\jcprepct.o
?????文件???????4604??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\jcsample.o
?????文件???????3768??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\jctrans.o
?????文件???????3228??2014-09-21?02:08??libjpeg-mem\libjpeg\jpeg-6b\.libs\jdapimin.o
............此處省略789個文件信息
評論
共有 條評論