linux下生成bmp图片的测试程序
来源:互联网 发布:知乎 发哥 编辑:程序博客网 时间:2024/05/22 08:00
原文地址::http://wenku.baidu.com/link?url=8PrgVQ_h2yyVAewEz0Ugap_zzVxusWe1d0-ddMtqiJe7NqXuR5g8n6J45iZhjXgfBM16RwhX4bXeLiyaxhml_mx0xoiMwB2GoXYdrcdRROS
相关文章
1、ARGB32位转化为RGB24位的函数(修改版)----http://blog.csdn.net/tinyhell127/article/details/7859226
2、VC创建BMP文件----http://blog.csdn.net/jonahzheng/article/details/8029870
/*linux bmp generator*/
#include <string.h>
#include <stdio.h>
typedef int BOOL;
typedef int LONG;
typedef unsigned char BYTE;
typedef unsigned int DWORD;
typedef unsigned short WORD;
typedef struct {
WORD bfType;//2
DWORD bfSize;//4
WORD bfReserved1;//2
WORD bfReserved2;//2
DWORD bfOffBits;//4
}__attribute__((packed))FileHead;
typedef struct{
DWORD biSize;//4
LONG biWidth;//4
LONG biHeight;//4
WORD biPlanes;//2
WORD biBitCount;//2
DWORD biCompress;//4
DWORD biSizeImage;//4
LONG biXPelsPerMeter;//4
LONG biYPelsPerMeter;//4
DWORD biClrUsed;//4
DWORD biClrImportant;//4
}__attribute__((packed))Infohead;
typedef struct
{
BYTE b;
BYTE g;
BYTE r;
}RGB_data;//RGB TYPE
int bmp_generator(char *filename,int height,int width,unsigned char *data)
{
FileHead bmp_head;
Infohead bmp_info;
int size = width*height*3;
bmp_head.bfType=0x4d42;
bmp_head.bfSize=size+sizeof(FileHead)+sizeof(Infohead);//24+head+info no quad
bmp_head.bfReserved1=bmp_head.bfReserved2=0;
bmp_head.bfOffBits=bmp_head.bfSize-size;
//finish the initial of head
bmp_info.biSize=40;
bmp_info.biWidth=width;
bmp_info.biHeight=height;
bmp_info.biPlanes=1;
bmp_info.biBitCount = 24;
bmp_info.biCompress=0;
bmp_info.biSizeImage=size;
bmp_info.biXPelsPerMeter=0;
bmp_info.biYPelsPerMeter=0;
bmp_info.biClrUsed=0;
bmp_info.biClrImportant=0;
//finish the initial of infohead;
//copy the data
FILE *fp;
if(!(fp=fopen(filename,"wb"))) return 0;
fwrite(&bmp_head,1,sizeof(FileHead),fp);
fwrite(&bmp_info,1,sizeof(Infohead),fp);
fwrite(data,1,size,fp);
fclose(fp);
return 0;
}
int main(void)
{
int i,j;
RGB_data buffer[1280][800];//hight width
char *path = "/home/s/800-1280_0.bmp";//generator path
printf("bmp generator!\n");
memset(buffer, 0, sizeof(buffer));
//testdata
for (i=0;i<1280;i++) //hight
for (j=0;j<800;j++)//width
{
if(i%2)
buffer[i][j].g=buffer[i][j].b=buffer[i][j].r=0;
else
buffer[i][j].g=buffer[i][j].b=buffer[i][j].r=0xff;
}
bmp_generator(path,1280,800,(unsigned char*)buffer);
return 0;
}
- linux下生成bmp图片的测试程序
- 一个在linux下生成bmp程序
- 一个在linux下生成bmp程序
- 用程序生成bmp图片
- a10下ov7670测试程序,拍照一张bmp图片
- 保存bmp图片的程序
- Linux下提取bmp图片颜色信息生成fb文件并用framebuffer显示
- linux下读取bmp图片文件头
- Android Camera生成bmp格式的图片
- Android camera生成bmp格式的图片
- linux下bmp转化为jpeg程序源代码, jpeg图片压缩
- 手动生成BMP图片
- BMP图片显示程序
- bmp图片解码程序
- linux下测试程序运行的时间
- Linux 下HelloWorld程序的一些测试
- Linux下测试程序的运行时间
- linux下测试程序运行的时间
- 关于硬币组合问题和DP的结合
- mysql进阶(二十二)MySQL错误之Incorrect string value: '\xE7\x81\xAB\xE7\x8B\x90...中文字符输入错误
- Plus One
- LeetCode Climbing Stairs(经典动态规划)
- must have one-pixel frame that is either transparent or white
- linux下生成bmp图片的测试程序
- 贝叶斯决策-模式识别
- Jedis使用示例
- Spring2.0与Hibernate3.0的错误解决
- 解决webView显示时候加广告问题
- iOS 证书
- jQuery获取高度问题
- 在Tomcat中部署war
- 2016云计算大会PPT打包下载