raw转bmp
来源:互联网 发布:小米电视怎么样 知乎 编辑:程序博客网 时间:2024/06/05 10:52
int saveRawToBmp(uint8_t *pBuf, int32_t width, int32_t height, const char *pFileName){ char heard[54] = { \ 0x42,0x4d,0x30,0x0C,0x01,0x00,0x00,0x00,0x00,0x00, \ 0x36,0x04,0x00,0x00,0x28,0x00,0x00,0x00,0xF5,0x00, \ 0x00,0x00,0x46,0x00,0x00,0x00,0x01,0x00,0x08,0x00, \ 0x00,0x00,0x00,0x00,0xF8,0x0b,0x01,0x00,0x12,0x0b, \ 0x00,0x00,0x12,0x0b,0x00,0x00,0x00,0x00,0x00,0x00, \ 0x00,0x00,0x00,0x00 }; char patte[1024] = {0}; char end[2] = {0, 0}; char color = 0; int32_t w = width; int32_t h = height; int32_t size = w * h; int32_t allsize = size + 1080; int32_t pos = 0; int32_t idx = 0; int32_t ret = 0; FILE *pFp = NULL; do { if ((NULL == pBuf) || (NULL == pFileName)) { ret = -1; break; } if ((width < 0) || (height < 0)) { ret = -2; break; } heard[2] = allsize & 0xFF; heard[3] = (allsize >> 8) & 0xFF; heard[4] = (allsize >> 16) & 0xFF; heard[5] = (allsize >> 24) & 0xFF; heard[18] = w & 0xFF; heard[19] = (w >> 8) & 0xFF; heard[20] = (w >> 16) & 0xFF; heard[21] = (w >> 24) & 0xFF; heard[22] = h & 0xFF; heard[23] = (h >> 8) & 0xFF; heard[24] = (h >> 16) & 0xFF; heard[25] = (h >> 24) & 0xFF; allsize -= 1078; heard[34] = allsize & 0xFF; heard[35] = (allsize >> 8) & 0xFF; heard[36] = (allsize >> 16) & 0xFF; heard[37] = (allsize >> 24) & 0xFF; for (idx = 0; idx < 1024; idx += 4) { patte[pos++] = color; patte[pos++] = color; patte[pos++] = color; patte[pos++] = 0; color++; } //====== Write raw data ====== pFp = fopen(pFileName, "wb"); if (NULL == pFp) { ret = -3; break; } fwrite(heard, 1, sizeof(heard), pFp); fwrite(patte, 1, sizeof(patte), pFp);#if 1 for (idx = height - 1; idx >= 0; idx--) { fwrite(&pBuf[idx * width], sizeof(uint8_t) * width, 1, pFp); }#else fwrite(buf, 1, size, pFp);#endif fwrite(end, 1, sizeof(end), pFp); fflush(pFp); if (0 != fsync(fileno(pFp))) { ret = -4; break; } } while (0); if (NULL != pFp) { fclose(pFp); pFp = NULL; } return ret;}
阅读全文
0 0
- raw转bmp
- raw格式数据转BMP格式(OpenCV)
- RAW格式转化为BMP
- RAW格式图像转为BMP格式
- Raw格式转换为Bmp格式
- 数字图像---之jpg,bmp,raw,png
- RAW(转)
- BMP之二:转成RAW文件及应用
- BMP之三:转成RAW文件及应用
- imageMagick 转换RGB raw 图像 到 BMP 图像 方法
- *.bmp序列保存为*.raw文件[matlb实现]
- ffmpeg源码分析--16.bmp格式分析及raw与bmp的相互转换
- RAW格式(转)
- cow2转raw
- RAW
- C语言将raw data(rgb/rgba)写成bmp文件(bmp24或32)
- 为raw数据添加图像头,并保存为bmp图像
- 为raw数据添加图像头,并保存为bmp图像(改进)
- yii2整合smarty
- Android 仿京东淘宝多规格选择
- tensorflow进行MNIST手写数字识别-LSTM
- 【剑指offer】面试题9:斐波那契数列
- Django 1.11 使用paginator,Django自带分页器
- raw转bmp
- Bzoj 1798 [Ahoi2009]Seq 维护序列seq【线段树+多标记Lazy】
- mybatis ${} #{} 传值
- 进程与线程-3、内核级线程切换过程
- C# 事件 订阅与发布
- RTMP与HLS压力测试工具安装与配置
- Java8系列之重新认识HashMap 2016/06/27 | 分类: 基础技术 | 9 条评论 | 标签: HashMap, java8 分享到: 67 原文出处: 前利 简介 Java为数
- git error 解决方案
- Mysql index使用事项