历史上的今天
今天是:2024年10月19日(星期六)
2019年10月19日 | 基于ARM平台的钢琴游戏 08实现音乐钢琴效果
2019-10-19 来源:51hei
//////////////////////////////////////////////////////////////////
//
// Copyright(C), 2013-2016, GEC Tech. Co., Ltd.
//
// File name: GPLE/bmp.c
//
// Author: Vincent Lin (林世霖) 微信公众号:秘籍酷
//
// Date: 2016-11
//
// Description: 处理BMP格式图像数据
//
// GitHub: github.com/vincent040 Bug Report: 2437231462@qq.com
//
//////////////////////////////////////////////////////////////////
#include #include "bmp.h" #include "ts.h" char * load_bmp(const char *bmpfile, struct image_info *minfo) { int fd = open(bmpfile, O_RDONLY); if(fd == -1) { fprintf(stderr, "opening "%s" failed: %sn", bmpfile, strerror(errno)); exit(0); } // 获得文件大小,并分配内存 struct stat fileinfo; fstat(fd, &fileinfo); int rgb_size = fileinfo.st_size; char *rgb_buf = calloc(1, rgb_size); // 读取BMP内容到内存中 struct bitmap_header header; struct bitmap_info info; struct rgb_quad quad; read(fd, &header, sizeof(header)); read(fd, &info, sizeof(info)); if(info.compression != 0) { read(fd, &quad, sizeof(quad)); fprintf(stderr, "read quad! n"); } read(fd, rgb_buf, rgb_size); minfo->width = info.width; minfo->height= info.height; minfo->pixel_size = info.bit_count/8; #ifdef DEBUG printf("width: %dn", minfo->width); printf("height: %dn", minfo->height); printf("pixel_size: %dn", minfo->pixel_size); #endif close(fd); return rgb_buf; } void bmp2lcd(char *bmpfile, char *FB, struct fb_var_screeninfo *vinfo, int xoffset, int yoffset) { xoffset = xoffset>(65*12+10) ? (65*10+10) : xoffset; struct image_info *minfo = calloc(1, sizeof(struct image_info)); char *rgb_buf = load_bmp(bmpfile, minfo); char *tmp = rgb_buf; // 从最后一行开始显示BMP图像 int pad = ((4-( minfo->width * minfo->pixel_size ) % 4)) % 4; // 0-3 rgb_buf += (minfo->width * minfo->pixel_size + pad) * (minfo->height-1); FB += (yoffset * vinfo->xres + xoffset) * 4; int lcd_w = vinfo->xres - xoffset; int lcd_h = vinfo->yres - yoffset; int x, y; for(x=0; x { for(y=0; y { unsigned long lcd_offset = (vinfo->xres*x + y) * 4; rgb_buf += minfo->pixel_size; memcpy(FB + lcd_offset + vinfo->red.offset/8, rgb_buf + 2, 1); memcpy(FB + lcd_offset + vinfo->green.offset/8, rgb_buf + 1, 1); memcpy(FB + lcd_offset + vinfo->blue.offset/8, rgb_buf + 0, 1); } rgb_buf += pad; rgb_buf -= (minfo->width * minfo->pixel_size + pad) * 2; } free(tmp); }
史海拾趣
|
我在WINCE下用DDRAW做UI,发现图片有时被撕裂了。现在我想用三缓冲的方法去做,希望能解决这个问题。可是我怎么做好像都不成功。下面是代码。还请高手看一下。 LPDIRECTDRAW4 g_ ...… 查看全部问答> |
|
一直在作音视频驱动,总是在和硬件打交道。感觉还是硬件那边稳定,不用再学好多乱七八糟得编程语言。 python,jsp,vbscript,C#,。。。 硬件那边只要把电路搞得很通就行了。爽啊。… 查看全部问答> |
|
msp430f5438测频率成功,能测60K一下频率,误差50HZ以内! #include #include \"LCD_12864.h\" #include \"CLOCK.h\" unsigned int end,start; unsigned char overflow; unsigned long fre; int main( void ) { // Stop watchdog timer to prevent time out reset WDTCTL ...… 查看全部问答> |
|
atlium 作出来的lm3s下载器,漂亮! 不多说,上传图片! [ 本帖最后由 paulhyde 于 2012-5-17 10:20 编辑 ]… 查看全部问答> |
|
本帖最后由 paulhyde 于 2014-9-15 03:52 编辑 在LCD屏上如何让一个图像绕某个点旋转呀?就像模拟仪表盘上的那个箭头,用C语言怎么写呀?求助、、、 … 查看全部问答> |




