文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>日记 [2009年04月29日]BMP图片的显示

日记 [2009年04月29日]BMP图片的显示

时间:2009-04-29  来源:owen0725

如何显示一张BMP的图片到 EINK中. 之前显示BMP图片总是倒过来的,显示效果也不好,后果发现 BMP图片的数据是: 开头 118byte 是图片的信息,包括图片的大小,像素等等. 118Byte 之后就是图片的数据,图片的数据头和尾是对调的,所以顺序发送数据到 EPD上显示的图片是不正常的. 下面如何显示BMP图片部分的代码:      FILE bmpfd;    unsigned char *addr, *buf, tmp;    int width, h, i;      if (GetImageHeader (file, &ImageHeader))
   {
     printf("width: %d,
   }
     width = ImageHeader.Width;
   h = ImageHeader.Height;
       bmpfd = fopen(file,"r+");
   if(!bmpfd)
   {
     fclose(bmpfd); 
     printf("open %s file fail\n",file);
     return -1; 
   }  
     BytesPerRow  = (((((width - 1) / 2) / 4) + 1) * 4);//use w    count = h * BytesPerRow;
   addr = (unsigned char *)malloc(sizeof(unsigned char)*count);
   buf = (unsigned char *)malloc(sizeof(unsigned char)*count);
   if(!addr){
     printf("assign memery error \n");
     return -1; 
   }
   memset(addr,0x00,count/2);
   fseek(bmpfd,118,SEEK_SET);
  
   int count = fread(addr,1,count,bmpfd);
   for(i=0;i<count;i++)    {       tmp = *(addr + i);       *(addr + i) = ((tmp<<4)&0xf0) | ((tmp>>4)&0x0f);    }      start = addr + (count - BytesPerRow);       // change data    for(i=0;i<count;i++){        *(buf + i) = start[i];    }          wrBsDataMain((unsigned char*)buf,BytesPerRow,h,width);             
相关阅读 更多 +
排行榜 更多 +
摧毁大厦游戏

摧毁大厦游戏

飞行射击 下载
合并动物城手游版

合并动物城手游版

休闲益智 下载
哈士奇大冒险

哈士奇大冒险

休闲益智 下载