资源简介
算法将BMP格式的图片转换为JPG格式的图片。。
代码片段和文件信息
#include “stdio.h“
#include “windows.h“
//宏定义
#define SBYTE signed char
#define SWORD signed short int
#define WORD unsigned short int
#define DWORD unsigned long int
#define SDWORD signed long int
#define Y(RGB) ((BYTE)( (YRtab[(R)]+YGtab[(G)]+YBtab[(B)])>>16 ) - 128)
#define Cb(RGB) ((BYTE)( (CbRtab[(R)]+CbGtab[(G)]+CbBtab[(B)])>>16 ) )
#define Cr(RGB) ((BYTE)( (CrRtab[(R)]+CrGtab[(G)]+CrBtab[(B)])>>16 ) )
#define writebyte(b) fputc((b)fp_jpeg_stream)
#define writeword(w) writebyte((w)/256);writebyte((w)%256);
//定义解码时用到的一些结构体
static struct APP0infotype {
WORD marker;
WORD length;
BYTE JFIFsignature[5];
BYTE versionhi;
BYTE versionlo;
BYTE xyunits;
WORD xdensity;
WORD ydensity;
BYTE thumbnwidth;
BYTE thumbnheight;
} APP0info={0xFFE016‘J‘‘F‘‘I‘‘F‘01101100};
static struct SOF0infotype {
WORD marker;
WORD length;
BYTE precision ;
WORD height ;
WORD width;
BYTE nrofcomponents;
BYTE IdY;
BYTE HVY;
BYTE QTY;
BYTE IdCb;
BYTE HVCb;
BYTE QTCb;
BYTE IdCr;
BYTE HVCr;
BYTE QTCr;
} SOF0info = { 0xFFC017800310x11020x11130x111};
static struct DQTinfotype {
WORD marker;
WORD length;
BYTE QTYinfo;
BYTE Ytable[64];
BYTE QTCbinfo;
BYTE Cbtable[64];
} DQTinfo;
static struct DHTinfotype {
WORD marker;
WORD length;
BYTE HTYDCinfo;
BYTE YDC_nrcodes[16];
BYTE YDC_values[12];
BYTE HTYACinfo;
BYTE YAC_nrcodes[16];
BYTE YAC_values[162];
BYTE HTCbDCinfo;
BYTE CbDC_nrcodes[16];
BYTE CbDC_values[12];
BYTE HTCbACinfo;
BYTE CbAC_nrcodes[16];
BYTE CbAC_values[162];
} DHTinfo;
static struct SOSinfotype {
WORD marker;
WORD length;
BYTE nrofcomponents;
BYTE IdY;
BYTE HTY;
BYTE IdCb;
BYTE HTCb;
BYTE IdCr;
BYTE HTCr;
BYTE SsSeBf;
} SOSinfo={0xFFDA1231020x1130x1100x3F0};
typedef struct { BYTE BGR; } colorRGB;
typedef struct { BYTE length;WORD value;} bitstring;
//定义解码时经常用到的常量
static BYTE zigzag[64]={ 0 1 5 614152728
2 4 71316262942
3 8121725304143
911182431404453
1019233239455254
2022333846515560
2134374750565961
3536484957586263 };
static BYTE std_luminance_qt[64] = {
16 11 10 16 24 40 51 61
12 12 14 19 26 58 60 55
14 13 16 24 40 57 69 56
14 17 22 29 51 87 80 62
18 22 37 56 68 109 103 77
24 35 55
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 23320 2013-05-02 23:18 bmp2jpg.c
----------- --------- ---------- ----- ----
23320 1
评论
共有 条评论