格式的转换和解码.doc

  1. 1、本文档共5页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
格式的转换和解码

void cvt_420p_to_rgb565(int width,int height,unsigned char *src, unsigned short *dst) { int line, col, linewidth; int y, u, v, yy, vr, ug, vg, ub; int r, g, b; const unsigned char *py, *pu, *pv; linewidth = width 1; py = src; pu = py + (width * height); pv = pu + (width * height) / 4; y = *py++; yy = y 8; u = *pu - 128; ug = 88 * u; ub = 454 * u; v = *pv - 128; vg = 183 * v; vr = 359 * v; for (line = 0; line height; line++) { for (col = 0; col width; col++) { r = (yy + vr) 8; g = (yy - ug - vg) 8; b = (yy + ub ) 8; if (r 0) r = 0; if (r 255) r = 255; if (g 0) g = 0; if (g 255) g = 255; if (b 0) b = 0; if (b 255) b = 255; *dst++ = (((unsigned short)r3)11) | (((unsigned short)g2)5) | (((unsigned short)b3)0); y = *py++; yy = y 8; if (col 1) { pu++; pv++; u = *pu - 128; ug = 88 * u; ub = 454 * u; v = *pv - 128; vg = 183 * v; vr = 359 * v; } } if ((line 1) == 0) { pu -= linewidth; pv -= linewidth; } } } /*jpeg的解码和24位转换成16位*/ void jpeg_error_exit (j_common_ptr cinfo) { cinfo-err-output_message (cinfo); exit (EXIT_FAILURE); } unsigned short rgb24_to_rgb16(unsigned char r,unsigned char g,unsigned char b) { int r16,g16,b16; unsigned short rgb16; b16 = (b * 0x1f) / 0xff ; g16 = (g * 0x3f) / 0xff ; r16 = (r * 0x1f) / 0xff ; rgb16 = (r1611)|(g165)|(b16); return rgb16; } unsigned char buf24_to16(unsigned char * buf,int w,int h) { unsigned char *buf24; unsigned short *buf16; unsigned int n,i; int size = w * h * 3; buf16 = (unsigned short *)buf; for (i = 0;i size ;i += 3) { *buf16 = rgb24_to_rgb16(buf[i],buf[i+1],buf[i+2]); buf16++; } } /*This returns an array for a 24 bit image.*/ u_char *decode_jpeg (unsigned char *filename, unsigned short *widthPtr, unsigned short *heightPtr) { register JSAMPARRAY lineBuf; struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr err_mgr; int bytesPerPix; FILE *inFile; u_cha

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档