encode RGB24 to jpeg, using libjpeg
来源:互联网 发布:c语言编程大赛 编辑:程序博客网 时间:2024/05/20 18:19
#include <stdio.h>
#include "jpeglib.h"
#include <setjmp.h>
extern JSAMPLE * image_buffer; /* Points to large array of R,G,B-order data */
extern int image_height; /* Number of rows in image */
extern int image_width; /* Number of columns in image */
void encode_jpeg_file (char * filename, int quality)
{
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
FILE * outfile; /* target file */
JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */
int row_stride; /* physical row width in image buffer */
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo);
if ((outfile = fopen(filename, "wb")) == NULL) {
fprintf(stderr, "can't open %s/n", filename);
exit(1);
}
jpeg_stdio_dest(&cinfo, outfile);
cinfo.image_width = image_width;
cinfo.image_height = image_height;
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
jpeg_set_defaults(&cinfo);
jpeg_set_quality(&cinfo, quality, TRUE );
jpeg_start_compress(&cinfo, TRUE);
row_stride = image_width * 3;
while (cinfo.next_scanline < cinfo.image_height)
{
/* jpeg_write_scanlines expects an array of pointers to scanlines.
* Here the array is only one element long, but you could pass
* more than one scanline at a time if that's more convenient.
*/
row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride];
(void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
}
jpeg_finish_compress(&cinfo);
fclose(outfile);
jpeg_destroy_compress(&cinfo);
}
- encode RGB24 to jpeg, using libjpeg
- encode YUV420 to jpeg, using libjpeg
- decoder jpeg to rgb 24, using libjpeg
- YUV422 to JPEG ---libjpeg 参考网页
- RGB24转jpeg
- RGB565 to RGB24, RGB555 & RGB24
- RGB565 to RGB24, RGB555 & RGB24
- JPEG开源代码:libjpeg
- 使用libjpeg解码jpeg图片
- 使用libjpeg解码jpeg图片
- libjpeg-jpeg压缩与解压缩
- RGB565 to RGB24
- RGB565 to RGB24
- How to compile the IJG JPEG library (libjpeg) for Visual Studio 2010
- An example of using libexif to set JPEG Orientation Tag
- An example of using libexif to set JPEG Orientation Tag
- RGB565 to RGB24, RGB555 & RGB2
- 颜色转换rgb24 to yuv420
- 读取 bmp 文件头信息, read bmp infomation
- 读取 wav文件 头信息, Read wav file information
- ubuntu搭建subversion服务器, build svn server in ubuntu
- int java.util.Random.nextInt(int n)
- test video frame rate & bitrate code in linux
- encode RGB24 to jpeg, using libjpeg
- UML建模复习笔记(一UML概述)
- decoder jpeg to rgb 24, using libjpeg
- linux上获得本地IP地址和MAC地址(get local ip address and mac address)
- Android Camera系统
- encode YUV420 to ogg, theora codec
- Mysql日期和时间函数大全(转)
- encode YUV420 to jpeg, using libjpeg
- linux 下 列出所有alsa设备代码