資源簡(jiǎn)介
jpeg jpg 解碼 C++源碼 主程序只有1個(gè)cpp文件,非常簡(jiǎn)結(jié)

代碼片段和文件信息
/*#ifdef?WIN32?//windows
???????#include?
#else??????????????//linux
???????#include?
???????#include?
#endif*/
///////////////////////////////////////////////////////////////////////////////
/*
/?1.?get?JPEG?image?data?and?decode?
/?2.?save?bufferdata?to?jpeg?file
/?the?original?code?come?from?internet?for?free?I?optimize?some?segments.
/?you?can?free?copy?this?code?except?useing?for??profit
/?Any?fault?in?this?code?is?not?the?responsibility?of?meit‘s?not?my?thing
/?by?:bot
/????:2010
*/
///////////////////////////////////////////////////////////////////////////////
#ifndef?__JPEGDEC_H__
#define?__JPEGDEC_H__?
#include?
#include?
#include?
#define?BYTE?unsigned?char
#define?WORD?unsigned?short?int
#define?DWORD?unsigned?int
#define?SDWORD?signed?int
#define?SBYTE?signed?char
#define?SWORD?signed?short?int
int??load_JPEG_header(FILE?*fp?DWORD?*X_image?DWORD?*Y_image);
void?decode_JPEG_image();
int??get_JPEG_buffer(WORD?X_image?WORD?Y_image?BYTE?**address_dest_buffer);
#endif
#include?
#include?
char?*FileName=“11.jpg“;
extern?char?error_string[90];
typedef?struct?s_BM_header?{
??WORD?BMP_id?;?//?‘B‘‘M‘
??DWORD?size;?//?size?in?bytes?of?the?BMP?file
??DWORD?zero_res;?//?0
??DWORD?offbits;?//?54
??DWORD?biSize;?//?0x28
??DWORD?Width;??//?X
??DWORD?Height;??//?Y
??WORD??biPlanes;?//?1
??WORD??biBitCount?;?//?24
??DWORD?biCompression;?//?0?=?BI_RGB
??DWORD?biSizeImage;?//?0
??DWORD?biXPelsPerMeter;?//?0xB40
??DWORD?biYPelsPerMeter;?//?0xB40
??DWORD?biClrUsed;?//0
??DWORD?biClrImportant;?//0
}?BM_header;
typedef?struct?s_RGB?{
?BYTE?B;
?????BYTE?G;
?????BYTE?R;
}?RGB;
void?exitmessage(char?*message)
{
?printf(“%s\n“message);exit(0);
}
void?write_buf_to_BMP(BYTE?*im_buffer?WORD?X_bitmap?WORD?Y_bitmap?char?*BMPname)
{
?SWORD?xy;
?RGB?*pixel;
?BM_header?BH;
?FILE?*fp_bitmap;
?DWORD?im_loc_bytes;
?BYTE?nr_fillingbytes?i;
?BYTE?zero_byte=0;
?fp_bitmap=fopen(BMPname“wb“);
?if?(fp_bitmap==NULL)?exitmessage(“File?cannot?be?created“);
?if?(X_bitmap%4!=0)?nr_fillingbytes=4-((X_bitmap*3L)%4);
??else?nr_fillingbytes=0;
?BH.BMP_id?=?‘M‘*256+‘B‘;?????fwrite(&BH.BMP_id21fp_bitmap);
?BH.size=54+Y_bitmap*(X_bitmap*3+nr_fillingbytes);fwrite(&BH.size41fp_bitmap);
?BH.zero_res?=?0;?????????????fwrite(&BH.zero_res41fp_bitmap);
?BH.offbits?=?54;?????????????fwrite(&BH.offbits41fp_bitmap);
?BH.biSize?=?0x28;????????????fwrite(&BH.biSize41fp_bitmap);
?BH.Width?=?X_bitmap; ??????fwrite(&BH.Width41fp_bitmap);
?BH.Height?=?Y_bitmap; ??????fwrite(&BH.Height41fp_bitmap);
?BH.biPlanes?=?1;?????????????fwrite(&BH.biPlanes21fp_bitmap);
?BH.biBitCount?=?24;??????????fwrite(&BH.biBitCount21fp_bitmap);
?BH.biCompression?=?0;????????fwrite(&BH.biCompression41fp_bitmap);
?BH.biSizeImage?=?
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件?????140739??2009-12-22?07:19??Work\1.jpg
?????文件?????138784??2009-12-22?07:19??Work\2.jpg
?????文件??????62102??2010-03-14?19:13??Work\Debug\JpegDecode.obj
?????文件??????23246??2010-03-14?15:21??Work\Debug\JpegDecode.sbr
?????文件??????50176??2010-03-28?15:08??Work\Debug\vc60.idb
?????文件??????61440??2010-03-14?19:13??Work\Debug\vc60.pdb
?????文件??????74752??2010-03-14?15:20??Work\Debug\Work.bsc
?????文件?????229426??2010-03-14?19:13??Work\Debug\Work.exe
?????文件?????385152??2010-03-14?19:13??Work\Debug\Work.ilk
?????文件?????227352??2010-03-14?16:31??Work\Debug\Work.pch
?????文件?????533504??2010-03-14?19:13??Work\Debug\Work.pdb
?????文件????4177974??2010-03-28?15:08??Work\image.bmp
?????文件??????34935??2010-03-14?19:13??Work\JpegDecode.cpp
?????文件???????4260??2010-03-14?16:35??Work\Work.dsp
?????文件????????533??2010-03-14?11:27??Work\Work.dsw
?????文件??????49664??2010-03-28?15:11??Work\Work.opt
?????文件???????1525??2010-03-14?19:13??Work\Work.plg
?????目錄??????????0??2010-03-14?19:13??Work\Debug
?????目錄??????????0??2010-03-28?15:11??Work
?????文件??????58368??2010-03-28?15:11??Work\Work.ncb
-----------?---------??----------?-----??----
??????????????6253932????????????????????20
評(píng)論
共有 條評(píng)論