http://www.ibm.com/developerworks/cn/linux/l-cn-linuxglb/

http://blog.csdn.net/wocjj/article/details/7867191

int read_JPEG_file (char * filename)
{
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
FILE * infile; /* source file */
FILE * outfile; /* source file */
JSAMPARRAY buffer; /* Output row buffer */
int row_stride; /* physical row width in output buffer */
//unsigned int nWidth = 1280;
//unsigned int nHeight = 720;
unsigned char* pcOutBuf = NULL;
char* pcRowBuf = NULL;

if ((infile = fopen(filename, "rb")) == NULL)
{
fprintf(stderr, "can't open %s\n", filename);
return 0;
}

cinfo.err = jpeg_std_error(&jerr);

jpeg_create_decompress(&cinfo);

jpeg_stdio_src(&cinfo, infile);

(void) jpeg_read_header(&cinfo, TRUE);
printf("width=%d, height=%d\n", cinfo.image_width, cinfo.image_height);
printf("color components:%d, jpeg color space:%d\n", cinfo.num_components, cinfo.jpeg_color_space);

printf("decompress--->color components:%d, jpeg color space:%d\n", cinfo.out_color_components, cinfo.out_color_space);
//printf("out_width=%d, out_height=%d\n", cinfo.output_width, cinfo.output_height);
//printf("component=%d\n", cinfo.output_components);

cinfo.out_color_space=JCS_GRAYSCALE;
cinfo.out_color_components = 1;
//jpeg_set_colorspace(&cinfo, JCS_GRAYSCALE);
//执行jpeg_start_decompress后才能获取到上面的打印信息
(void) jpeg_start_decompress(&cinfo);

printf("out_width=%d, out_height=%d\n", cinfo.output_width, cinfo.output_height);
printf("component=%d\n", cinfo.output_components);
printf("decompress--->color components:%d, jpeg color space:%d\n", cinfo.out_color_components, cinfo.out_color_space);

row_stride = cinfo.output_width * cinfo.output_components;
pcOutBuf = (unsigned char*)malloc(cinfo.output_width*cinfo.output_height*cinfo.output_components);
pcRowBuf = (char*)malloc(row_stride);

if ((outfile = fopen("xxx.gray", "wb")) == NULL)
{
fprintf(stderr, "can't open %s\n", "xxx.gray");
return 0;
}

while (cinfo.output_scanline < cinfo.output_height)
{
(void) jpeg_read_scanlines(&cinfo, &pcRowBuf, 1);
memcpy(pcOutBuf, pcRowBuf, row_stride);
pcOutBuf += row_stride;

fwrite(pcRowBuf,1, row_stride, outfile);
// printf("cinfo.output_scanline=%d\n", cinfo.output_scanline);
}

fclose(infile);
fclose(outfile);

if (NULL != pcOutBuf)
free(pcOutBuf);

return 0;
}

ffffff的更多相关文章

  1. 颜色代码表#FFFFFF #FF0000 #00FF00 #FF00FF (2015-07-21 10:39)转载

    ▼标签: 颜色代码表 白色 ffffff 红色 ff0000 黑色 000000 it     分类: hht1 白色 #FFFFFF 2 红色 #FF0000 3 绿色 #00FF00 4 蓝色 # ...

  2. 颜色设置 <color name="white">#FFFFFF</color><!--白色 -->

    <?xml version="1.0" encoding="utf-8"?> <resources> <color name=&q ...

  3. android 在代码中使用 #ffffff 模式 设置背景色

    differentsum.setBackgroundColor(Color.parseColor("#F3733F"));

  4. C语言中以十六进制输出字符型变量会出现'ffffff"的问题

    最近在做一个C的嵌入式项目,发现在C语言中用printf()函数打印字符型变量时,如果想采用"%x"的格式将字符型变量值以十六进制形式打印出来,会出现一个小问题,如下: char  ...

  5. RGB(FFFFFF)转255:255:255

    NSString *color = model.display_color; long colorLong = strtoul([color cStringUsingEncoding:NSUTF8St ...

  6. iOS可视化动态绘制连通图

    上篇博客<iOS可视化动态绘制八种排序过程>可视化了一下一些排序的过程,本篇博客就来聊聊图的东西.在之前的博客中详细的讲过图的相关内容,比如<图的物理存储结构与深搜.广搜>.当 ...

  7. 纯CSS3实现的一些酷炫效果

    之前在网上看到一些用纯CSS3实现的酷炫效果,以为实现起来比较困难,于是想看看具体是怎么实现的. 一.笑脸猫动画 实现效果如下: 这个实现起来确实比较麻烦,很多地方需要花时间,有耐心地调整. 1.先看 ...

  8. FragmentTabHost的基本用法

    开通博客以来已经约莫1个月了.几次想提笔写写东西,但总是由于各种各样的原因并没有开始.现在,年假刚结束,项目也还没有开始,但最终促使我写这篇博客的是,看了一篇博友写的新年计划,说是要在新的一年中写50 ...

  9. QT5利用chromium内核与HTML页面交互

    在QT5.4之前,做QT开发浏览器只能选择QWebkit,但是有过使用的都会发现,这个webkit不是出奇的慢,简直是慢的令人发指,Release模式下还行,debug下你就无语了,但是webkit毕 ...

随机推荐

  1. [Codeforces 7E] Defining Macros

    Link:http://codeforces.com/problemset/problem/7/E Brief Introduction:一个表达式由多个“Macros”组成,每个Macro都为一个整 ...

  2. [51nod1538]一道难题

    先观察一下题目给出的式子:对所有满足$\begin{align*}\sum\limits_{i=1}^na_ib_i=m\end{align*}$的$b_{1\cdots n}$,计算$\begin{ ...

  3. 【强联通分量缩点】【搜索】bzoj2208 [Jsoi2010]连通数

    两次dfs缩点,然后n次dfs暴搜. #include<cstdio> #include<vector> #include<cstring> using names ...

  4. es 数据 导出 到 MySQL

    暂时没有找到直接 导出到 mysql 数据库的工具 或者项目 目前实现思路: 使用 elasticdump  工具 实现 从 es 数据 导出到 json 文件 ,然后 使用 脚本程序 操作 改 js ...

  5. Mybatis全部标签

    一.定义SQL语句 (1)select 标签的使用 属性介绍: id :唯一的标识符. parameterType:传给此语句的参数的全路径名或别名 例:com.test.poso.User或user ...

  6. mysql-root本地无法登录处理

    主要有以下几种情况: 1.忘记密码 2.丢失root对localhost的访问权限或者对应的host授权 解决方案: ----------------------------------------- ...

  7. USB High Speed Inter-Chip (HSIC) IP: What is it? And why should I use it?

    来源: https://www.synopsys.com/dw/dwtb.php?a=hsic_usb2_device What is HSIC? HSIC (High-Speed Inter-Chi ...

  8. JS中的Math.pow(a,b)方法

    定义和用法 pow() 方法可返回 x 的 y 次幂的值. 语法 Math.pow(x,y) 参数 描述 x 必需.底数.必须是数字. y 必需.幂数.必须是数字. 返回值 x 的 y 次幂. 说明 ...

  9. 利用CMD查看系统硬件信息

    利用CMD查看系统硬件信息对于在windows下查看系统信息大家一定不陌生了,我现在说几个最常用的方法,对命令感兴趣的朋友看看,(给菜鸟看的,老手就不要笑话我了,大家都是从那个时候过来的,^_^).一 ...

  10. Python \xd7\xaa\xd5\xbdOTT TV\xb1\xa6\xbd\xe0 编码

    import chardet s = '\xd7\xaa\xd5\xbdOTT TV\xb1\xa6\xbd\xe0\xc7\xa3\xca\xd6\xd2\xf8\xba\xd3\xa1\xa4\x ...