rgb色彩空间转换实现汇总
来源:互联网 发布:js blob转uint8array 编辑:程序博客网 时间:2024/06/05 11:24
转载请注明http://blog.csdn.net/u011046042/article/details/71727885
做视频和图形这块进行总结
色彩空间转换的汇总
rgb到bgr的转换
代码如下:
static void convert_rgb_to_bgr(uint8_t* src, uint8_t* dest, int width){ int x; for (x = 0; x < width; x++) { *dest++ = src[2]; *dest++ = src[1]; *dest++ = src[0]; src += 3; }}
rgb到bgrx的转换
static void convert_rgb_to_bgrx(uint8_t* src, uint8_t* dest, int width){ int x; for (x = 0; x < width; x++) { *dest++ = src[2]; *dest++ = src[1]; *dest++ = src[0]; *dest++ = 0; src += 3; }}
RGB16 到RGB24
static void convert_RGB16_to_RGB24(void *line, int width, uint8_t **out_line){ uint16_t *src_line = line; uint8_t *out_pix; int x; spice_assert(out_line && *out_line); out_pix = *out_line; for (x = 0; x < width; x++) { uint16_t pixel = *src_line++; *out_pix++ = ((pixel >> 7) & 0xf8) | ((pixel >> 12) & 0x7); *out_pix++ = ((pixel >> 2) & 0xf8) | ((pixel >> 7) & 0x7); *out_pix++ = ((pixel << 3) & 0xf8) | ((pixel >> 2) & 0x7); }}
BGRX到RGB24
static void convert_BGRX32_to_RGB24(void *line, int width, uint8_t **out_line){ uint32_t *src_line = line; uint8_t *out_pix; int x; spice_assert(out_line && *out_line); out_pix = *out_line; for (x = 0; x < width; x++) { uint32_t pixel = *src_line++; *out_pix++ = (pixel >> 16) & 0xff; *out_pix++ = (pixel >> 8) & 0xff; *out_pix++ = pixel & 0xff; }}
yuyv到rgb的装换
#define clip_8bit(val) ((val) < 0 ? 0 : (val) > 255 ? 255 : (val))compress_yuyv_to_rgb (const uint8_t *src_ptr,uint8_t *rgb_ptr,const int width, const int height){ int r,g,b; int y,u,v; int i; int table_ub_value; int table_ug_value; int table_vg_value; int table_vr_value; for (i = 0; i < width * height / 2; ++i) { y = src_ptr[0]; u = src_ptr[1]; v = src_ptr[3]; table_ub_value=table_ub[u]; table_ug_value=table_ug[u]; table_vg_value=table_vg[v]; table_vr_value=table_vr[v]; b = y + table_ub_value; g = y - table_ug_value - table_vg_value; r = y + table_vr_value; *rgb_ptr++ = clip_8bit (r); /* R */ *rgb_ptr++ = clip_8bit (g); /* G */ *rgb_ptr++ = clip_8bit (b); /* B */ y = src_ptr[2]; b = y + table_ub_value; g = y - table_ug_value - table_vg_value; r = y + table_vr_value; *rgb_ptr++ = clip_8bit (r); /* R */ *rgb_ptr++ = clip_8bit (g); /* G */ *rgb_ptr++ = clip_8bit (b); /* B */ src_ptr += 4; }}
转载请注明http://blog.csdn.net/u011046042/article/details/71727885
纯代码 C语言,纯干货。方便以后使用,持续更新。
0 0
- rgb色彩空间转换实现汇总
- VC编程实现色彩空间RGB与XYZ相互转换
- PHP实现RGB,HSL,HSV色彩空间转换
- VC编程实现色彩空间RGB与XYZ相互转换
- VC编程实现色彩空间RGB与XYZ相互转换
- RGB到HSV色彩空间转换表
- rgb和Lab,rgb和hsl的色彩空间转换
- VC编程实现色彩空间RGB与HSB(HSV)相互转换
- VC编程实现色彩空间RGB与HSB(HSV)相互转换
- Java 利用 ICC 色彩空间 color space profile 实现 RGB 和 CMYK 颜色的相互转换
- cvCvtColor实现色彩空间转换
- cvCvtColor实现色彩空间转换
- cvCvtColor实现色彩空间转换
- RGB、HSV色彩空间模式的互相转换
- RGB、HSV色彩空间模式的互相转换
- 从RGB到Lab色彩空间的转换
- RGB、HSV色彩空间模式的互相转换
- 从RGB到Lab色彩空间的转换
- linux mysq操作
- java动态代理
- Zookeeper系列(二十五)Zookeeper原理解析之客户端与服务器端交互
- Problem B: 时间类的错误数据处理
- maven下载jar包改用阿里云maven库
- rgb色彩空间转换实现汇总
- Python调用adb命令实现对多台设备同时进行reboot
- BZOJ3894文理分科-最小割
- GRE and VXLAN with Open vSwitch
- 11——数字颠倒
- Ubuntu 16.04 php接入微信扫一扫
- 反向传播BP算法
- LeetCode
- kafka安装