int Bmp2Jpg(const char *bmp_data, const char *jeg_file, const int width, const int height)
{
    int ret;
    ;
    JSAMPROW * row_pointer;
    ;
    ;
    struct jpeg_compress_struct cinfo;
    struct jpeg_error_mgr jerr;
    FILE *outfile;                        

    //Convert BMP to JPG
    cinfo.err = jpeg_std_error(&jerr);
    //* Now we can initialize the JPEG compression object.
    jpeg_create_compress(&cinfo);

    if ((outfile = fopen(jeg_file, "wb")) == NULL)
    {
        fprintf(stderr, "can't open %s\n", jeg_file);
        ;
    }
    jpeg_stdio_dest(&cinfo, outfile);

    cinfo.image_width = width;             //* image width and height, in pixels
    cinfo.image_height = height;
    cinfo.input_components = depth;    //* # of color components per pixel
    cinfo.in_color_space = JCS_RGB;     //* colorspace of input image
    jpeg_set_defaults(&cinfo);

     //Now you can set any non-default parameters you wish to.
     //Here we just illustrate the use of quality (quantization table) scaling:

    jpeg_set_quality(&cinfo, JPEG_QUALITY, TRUE ); //* limit to baseline-JPEG values
    jpeg_start_compress(&cinfo, TRUE);

    //一次写入
    ;
    row_pointer = );
    ];

    ;i<height;i++)
    {
        unsigned char * lineData = NULL;
        lineData = );
        line[i]=lineData;
        ;j<width;j++)
        {
            lineData[j*+] = bmp_data[rgb_index];
            rgb_index ++;
            lineData[j*+] = bmp_data[rgb_index];
            rgb_index ++;
            lineData[j*+] = bmp_data[rgb_index];
            rgb_index ++;
        }
        row_pointer[height-i-] = lineData;
    }
    jpeg_write_scanlines(&cinfo, row_pointer, height);
    jpeg_finish_compress(&cinfo);
    jpeg_destroy_compress(&cinfo);
    ; i<height; i++)
    {
        free(line[i]);
    }
    free(row_pointer);
    fclose(outfile);

    ;
} 

BMP格式转JPEG格式的更多相关文章

  1. ecshop图片上传JPEG格式失败问题

    在根目录下找到includes文件目录,在其目录中找到cls_image.php打开并找到: $allow_file_types = '|GIF|JPG|JEPG|PNG|BMP|SWF|'; 此处J ...

  2. 一般源码安装添加的GD库 是不支持 jpeg 格式的图片的

    一般源码安装添加的GD库 是不支持 jpeg 格式的图片的,只支持如下格式 GD Support enabled GD Version bundled (2.0.34 compatible) GIF ...

  3. JPEG格式 介绍

    JPEG格式 jpeg是有损压缩格式, 将像素信息用jpeg保存成文件再读取出来,其中某些像素值会有少许变化.在保存时有个质量参数可在[0,100]之间选择,参数越大图片就越保真,但图片的体积也就越大 ...

  4. JPEG格式

    Jpg文件格式[参考] 微处理机中的存放顺序有正序(big endian)和逆序(little endian)之分.正序存放就是高字节存放在前低字节在后,而逆序存放就是低字节在前高字节在后.例如,十六 ...

  5. 图像JPEG格式介绍

    1 JPG格式介绍 JPEG (Joint PhotographicExperts GROUP)是由国际标准组织和国际电话电报咨询委员会为静态图像所建立的第一个国际数字图像压缩标准,也是至今一直在使用 ...

  6. 让阿里云的Centos,PHP组件 ImageMagick支持png和jpeg格式

    我们在Centos安装ImageMagick教程中讲述了如何安装ImageMagick,安装完毕之后发现程序并不支持png和jpeg格式的图片,但是这两种图片又是我们平时所常见的,所以我们还要进一步地 ...

  7. 嵌入式Linux基于framebuffer的jpeg格式本地LCD屏显示

    在基于Linux的视频监控采集系统中,摄像头采集到的一帧视频图像数据一般都是经过硬件自动压缩成jpeg格式的,然后再保存到摄像头设备的缓冲区.如果要把采集到的jpeg格式显示在本地LCD屏上,由于我们 ...

  8. 超图不支持JPEG格式的WMTS服务

    就目前面而言,超图不支持JPEG格式的WMTS服务,只支持PNG格式的. <本篇完>

  9. linux下将jpg,jpeg格式转为PDF

    1.安装imagemagick(用其中的convert)和gthumb     sudo apt-get install imagemagick gthumb 2.将tiff图片转换为png或jpeg ...

随机推荐

  1. ubuntu下make无法安装的问题

    发布时间:2015-10-30 10:51:30来源:linux网站作者:_莫欺少年穷 在帮同学服务器安装环境过程中,发现,make 命令不能使用,提示: The program 'make' is ...

  2. awk中使用shell变量

    方法:使用-v参数. 对于多个shell变量使用多个-v 有个关于shell变量中的空格问题:

  3. centOS安装apache服务器

    # yum install httpd 启动 systemctl start httpd 重启 systemctl restart httpd 停止 systemctl stop httpd

  4. Ajax缓存处理

    如果直接用jQuery里的$.ajax()方法的话,去除缓存很简单,只需要配置一下缓存属性cache为false,但如果想要简单写法getJSON(),去除缓存就不能通过配置来解决了.因为getJSO ...

  5. SQL Server technical bulletin - How to resolve a deadlock

    https://support.microsoft.com/en-us/help/832524/sql-server-technical-bulletin-how-to-resolve-a-deadl ...

  6. 如何用wamp配置多域名虚拟目录

    一.前言 自从重装了最新版wamp64后就不可用了,下面来介绍我的解决方法,两者均可尝试,差别并不大! 二.配置虚拟主机 1.首先打开apache的配置文件httpd.conf (路径\wamp64\ ...

  7. apache实现http自动转为https

    1.确认此服务器apache已经配置过证书可以用https访问到 2.确认/etc/apache2/ports.conf 下有 Listen 80Listen 443(此条) 3.配置虚礼主机定将域名 ...

  8. httpClient的post方法使用form格式数据调用接口

    Http使用post调用接口,接口只接受form表单数据格式问题? 这个问题的关键是form表单提交的是数据格式是什么样子的,使用httpClient工具类时Header信息如何写. 会影响解决问题思 ...

  9. Spring Boot入门——集成Mybatis

    步骤: 1.新建maven项目 2.在pom.xml文件中引入相关依赖 <!-- mysql依赖 --> <dependency> <groupId>mysql&l ...

  10. java文件读写常用方法

    // TODO Auto-generated method stub //File file = new File("D:\\Android\\workspace\\Practice1\\s ...