资源简介
基于VS2012,用c撰写的解析JPEG图片头信息的简单程序。课程作业

代码片段和文件信息
/*
* File Name: jpegDe.c
* Author: 576632108@qq.com lucio
* Date: 2014.11.5
* Description: analyze the head info of jpeg
*/
#include
#include
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef long LONG;
int main(int argc char **argv){
FILE *fp;
WORD window;
WORD temp;
int i=0j=0k=0;
int found_count=0;
int mark_head=0xFF;
int mark_part[8]={0xD80xE00xDB0xDD0xC00xC40xDA0xD9};
char mark_str[8][10]={“SOI““APP0““DQT““DRI““SOF0““DHT““SOS““EOI“};
int headpart;
int temp_headtemp_part;
int done=0;
fp=fopen(“KD.jpg““rb“);
if(fp==0){
printf(“Can not open the file to read.\n“);
return -1;
}
while( 1 ){
fseek(fpiSEEK_SET);
if(fread(&window21fp)!=1){
printf(“Can not read the info of the info header.\n“);
fclose(fp);
return -1;
}
head=window-(window/0x100)*0x100;//靠前的部分是高位
part=window/0x100;//靠后的部分是低位
if( head==mark_head ){
for ( j=0;j<8;j++ ){
if( part==mark_part[j] ){
printf(“%s: %X-%X\n“mark_str[j]headpart);
if( j==1 ){//APP0
//此处不需要fseek,因为读的过程中指针移动
//Lp
if(fread(&temp21fp)!=1){
printf(“Can not read the info of the info header.\n“);
fclose(fp);
return -1;
}
temp_head=temp-(temp/0x100)*0x100;
temp_part=temp/0x100;
temp=temp_head+temp_part;
printf(“ Lp: %d\n“temp);
//Identifier
printf(“ Identifier: “);
for( k=0;k<3;k++ ){
if(fread(&temp21fp)!=1){
printf(“Can not read the info of the info header.\n“);
fclose(fp);
return -1;
}
temp_head=temp-(temp/0x100)*0x100;
temp_part=temp/0x100;
if( k!=2 ) printf(“%02X-%02X-“temp_headtemp_part);
else printf(“%02X“temp_head);
}
printf(“\n“);
//Version
fseek(fp-1SEEK_CUR);
if(fread(&temp21fp)!=1){
printf(“Can not read the info of the info header.\n“);
fclose(fp);
return -1;
}
temp_head=temp-(temp/0x100)*0x100;
temp_part=temp/0x100;
temp=temp_head+temp_part;
printf(“ Version: %02X-%02X\n“temp_headtemp_part);
//Units
if(fread(&temp11fp)!=1){
printf(“Can not read the info of the info header.\n“);
fclose(fp);
return -1;
}
printf(“ Units: %02X\n“temp);
//Xdensity
if(fread(&temp21fp)!=1){
printf(“Can not read the info of the info header.\n“);
fclose(fp);
return -1;
}
temp_head=temp-(temp/0x100)*0x100;
temp_part=temp/0x100;
temp=temp_head+temp_part;
printf(“ Xdensity: %d\n“temp);
//Ydensity
if(fread(&temp21fp)!=1){
printf(“Can not read the info of the info header.\n“);
fclose(fp);
return -1;
}
temp_head=temp-(temp/0x100)*0x100;
temp_part=temp/0x100;
temp=temp_head+temp_part;
pr
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-11-19 11:48 jpegDe\
目录 0 2014-11-02 19:07 jpegDe\Debug\
文件 34304 2014-11-05 10:43 jpegDe\Debug\jpegDe.exe
文件 496920 2014-11-05 10:43 jpegDe\Debug\jpegDe.ilk
文件 461824 2014-11-05 10:43 jpegDe\Debug\jpegDe.pdb
目录 0 2014-11-03 20:56 jpegDe\jpegDe\
文件 2228224 2014-11-19 11:48 jpegDe\jpegDe.sdf
文件 885 2014-11-02 19:04 jpegDe\jpegDe.sln
文件 22528 2014-11-19 11:48 jpegDe\jpegDe.v11.suo
目录 0 2014-11-05 10:43 jpegDe\jpegDe\Debug\
文件 534 2014-11-05 10:43 jpegDe\jpegDe\Debug\cl.command.1.tlog
文件 1060 2014-11-05 10:43 jpegDe\jpegDe\Debug\CL.read.1.tlog
文件 226 2014-11-05 10:43 jpegDe\jpegDe\Debug\CL.write.1.tlog
文件 48 2014-11-05 10:43 jpegDe\jpegDe\Debug\jpegDe.lastbuildstate
文件 1497 2014-11-05 10:43 jpegDe\jpegDe\Debug\jpegDe.log
文件 13912 2014-11-05 10:43 jpegDe\jpegDe\Debug\jpegDe.obj
文件 2 2014-11-05 10:43 jpegDe\jpegDe\Debug\li
文件 2 2014-11-05 10:43 jpegDe\jpegDe\Debug\li
文件 2 2014-11-05 10:43 jpegDe\jpegDe\Debug\li
文件 2 2014-11-05 10:43 jpegDe\jpegDe\Debug\li
文件 978 2014-11-05 10:43 jpegDe\jpegDe\Debug\li
文件 2134 2014-11-05 10:43 jpegDe\jpegDe\Debug\li
文件 282 2014-11-05 10:43 jpegDe\jpegDe\Debug\li
文件 27648 2014-11-05 10:43 jpegDe\jpegDe\Debug\vc110.idb
文件 77824 2014-11-05 10:43 jpegDe\jpegDe\Debug\vc110.pdb
文件 3587 2014-11-05 11:09 jpegDe\jpegDe\jpegDe.c
文件 4006 2014-11-02 19:06 jpegDe\jpegDe\jpegDe.vcxproj
文件 942 2014-11-02 19:06 jpegDe\jpegDe\jpegDe.vcxproj.filters
文件 16963 2013-11-09 16:12 jpegDe\jpegDe\KD.jpg
文件 481537 2014-11-03 20:55 jpegDe\jpegDe\tiger.jpg
- 上一篇:Qt5类继承关系图
- 下一篇:STM32+GPS程序
相关资源
- 用友NC开发API字典
- Navicat Premium 15汉化包.zip55438
- 登录注册界面.zip48872
- 条码字体barcode128
- Rational Rose Common破解文件
- res10_300x300_ssd_iter_140000.caffemodel与dep
- scratch 第1课 翻跟斗的小猫(入门)
- stm32f407上的两个can发送和接收例程
- Scrach 欢乐狙击手.sb2
- 04741计算机网络原理知识点整理.docx(
- Wolfram Mathematica 矩阵初等变换函数(
- pscad近海风电模型 Fortran语言
- 程序员专用字体YaHei.Consolas.1.11b42517
- scratch3.0 源程序(说相声)
- AutoCAD永久去教育版破解补丁
- 开源1A锂电池充电板TP4056原理图+PCB
- m1卡 ic卡可选择扇区初始化加密软件
- TSCC.exe
- 欧姆龙CP1系列单轴定位PLC程序.cxp
- 用Beckhoff(倍福)PLC读写巴鲁夫RFID
- CVSNT 完整覆盖版防TortoiseCVS中文乱码
- pfc 使用说明.doc
- Scratch 飞机大战.sb3
- STC8951系列单片机中方指南
- 《Visual Prolog 基础类》 中文参考.chm
- Omron ETN21模块进行modbustcp通讯
- 基于ACCESS的生产管理信息系统.mdb
- CANopen使用手册_埃斯顿
- Scratch 吃豆人追踪者.sb3
- Scratch 变脸(将人物图片变成各种各样
评论
共有 条评论