#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#pragma pack (1)
typedef struct
{
unsigned char info[2]; //BM
unsigned int size; //
unsigned int reserve1; //0
unsigned int offset; //0x3E
unsigned int headerinfo; //0x28
unsigned int width; //
unsigned int height; //
unsigned short planes; //1
unsigned short bitpixel; //1
unsigned int compression; //0
unsigned int datasize; //
unsigned int hres; //0
unsigned int vres; //0
unsigned int colors; //0
unsigned int important; //0
unsigned int palette; //0
unsigned int bdata; //0xFFFFFF00
}BMPHEADER;
void mkbmp(int width,int height,char *data,int datasize)
{
BMPHEADER header;
FILE *fp = NULL;
memset(&header,0,sizeof(BMPHEADER));
header.info[0] = 'B';header.info[1] = 'M';
header.size = datasize + sizeof(header);
header.reserve1 = 0;
header.offset = 0x3E;
header.headerinfo = 0x28;
header.width = width;header.height = height;
header.planes = 1;header.bitpixel = 1;
header.compression = 0;
header.datasize = datasize;
header.hres = 0;header.vres = 0;
header.colors = 0;
header.important = 0;header.palette = 0;
header.bdata = 0xFFFFFF;
fp = fopen("bmp.bmp","wb");
fwrite(&header,sizeof(header),1,fp);
fwrite(data,datasize,1,fp);
fclose(fp);
}
void main()
{
BMPHEADER header;
FILE* fp;
char *buffer = "\xF0\0\0\0\x0F\0\0\0";
int width = 4,height = 2;
int bwidth = ((width + 7) / 8 + 3)/4 * 4;
int size = bwidth * height;
mkbmp(width,height,buffer,size);
fp = fopen("f:\\1.bmp","rb");
fread((void*)&header,1,sizeof(BMPHEADER),fp);
printf("info=%c%c\n",header.info[0],header.info[1]);
printf("size=%d\n",header.size);
printf("reserve1=%d\n",header.reserve1);
printf("offset=%d\n",header.offset);
printf("headerinfo=%d\n",header.headerinfo);
printf("width=%d\n",header.width);
printf("height=%d\n",header.height);
printf("planes=%d\n",header.planes);
printf("compression=%d\n",header.compression);
printf("datasize=%d\n",header.datasize);
printf("hres=%d\n",header.hres);
printf("vres=%d\n",header.vres);
printf("colors=%d\n",header.colors);
printf("important=%d\n",header.important);
printf("palette=%d\n",header.palette);
printf("bdata=%x\n",header.bdata);
fclose(fp);
}
分享到:
相关推荐
VC下彩色位图转单色位图,可实现截图,生成位图数据文件。
数字图像处理,何东健-彩色位图转黑白位图代码
建立黑白蔚图的3D模型,请在chrome浏览器中打开
将真彩位图转化成256彩色或黑白位图的源代码
将真彩位图转化成各色或黑白位图.zip
一个效果非常好的24,16bit真彩位图转化成256彩色或黑白位图的演示程序代码,其中调用了一个动态连接库。
visual c++把彩色位图变成黑白位图.zip
商业编程-源码-真彩位图转化成256彩色或黑白位图的代码.zip
利用8连通原理计算黑白位图上的物体个数。 注意:“只能计算黑白位图上的物体个数!代码仅供参考。” 个人能力有限,代码可能不太符合规范,望各位谅解。 代码中预留有4连通和D连通的算法,可以自己调用和查看。 如...
visual c++ vc将真彩位图转化成各色或黑白位图.zip
一个效果非常好的24,16bit真彩位图转化成256彩色或黑白位图的演示程序
详细:彩色图片变成黑白图片 用处:有些图片的使用只能用黑白的,比如某些打印机只能传黑白图片进行 打印,但是如果想打印彩色图片的话就可以用。
本工具可以轻松将BMP图片转换为黑白位图、RGB565、ARGB565等单片机常用格式,也可将转换后的图片还原为电脑可查看的PPM格式。是你为单片机转换图片、制作动画的实用工具。核心代码采用C语言编写,灵活高效,同时方便...
基于V4L2的8位位图采集程序,采集图片尾黑白图片,程序实用。
先调用android的系统工具,获取图片生成bitmap文件,再使用android中的二值化技术,将图片转化成黑白图片
制作出来的单色位图用在LCD液晶显示上效果非常不错
Windows位图(Bitmap)和调色板(Palette) 普通的显示器屏幕是由...举个例子,下图1是一幅普通的黑白位图,图2是被放大后的图,图中每个方格代表了一个像素,我们可以看到:整个骷髅就是由这样一些黑点和白点组成的。
在使用 12864 液晶的时候,如何将彩色图像处理成黑白位图。又如何将黑白位图处理成单片机可读写 的数据?下面我来简单介绍一下如何处理。