你好,游客 登录 注册 搜索
背景:
阅读新闻

OK6410 裸机BMP图片解码

[日期:2012-12-09] 来源:Linux社区  作者:cp1300 [字体:大 中 小]

bmpdecode.h

/*************************************************************************************************************
 * 文件名: bmpdecode.h
 * 功能:      BMP图片软件解码
 * 作者:      cp1300@139.com
 * 创建时间:    2012年12月7日20:30
 * 最后修改时间:2012年12月9日
 * 详细:      只支持非压缩的BMP,16bit,24bit,32bit
 *          图片文件最大由BMP_MAX_BUFF决定
 *          因为使用了FATFS,以及比较多的临时变量,内联函数可能需要比较大的堆栈
*************************************************************************************************************/ 
#ifndef BMPDECODE_H_ 
#define BMPDECODE_H_ 
 
//BMP错误定义 
typedef enum 
{ 
    BMP_OK          =  0,  //正常处理完成 
    BMP_OPEN_ERROR  =  1,  //图像打开错误 
    BMP_READ_ERROR  =  2,  //图像读取错误 
    BMP_SIZE_ERROR  =  3,  //图像大小错误 
    BMP_TYPE_ERROR  =  4,  //不支持的图像类型,图像类型错误 
    BMP_OTHER_ERROR =  5  //其它未知错误 
} BMP_ERROR; 
 
 
BMP_ERROR ShowBmpImage(u16 x1,u16 y1,u16 x2,u16 y2,const char *BmpFile);    //指定位置显示一张BMP图片 
 
 
#endif /*BMPDECODE_H_*/ 

main.c

#include "system.h" 
#include "uart.h" 
#include "tft_lcd.h" 
#include "other.h" 
#include "delay.h" 
#include "timer.h" 
#include "ff.h" 
#include "rtc.h" 
#include "bmpdecode.h" 
#include "jpeg.h" 
 
 
 
u8 jpeg_buff[10*1024*1024]; 
u8 buff[10*1024*1024]; 
 
 
FATFS fs; 
 
//LED1闪烁程序,在定时器0中断服务程序中闪烁,周期400MS 
void LED1_flash(void) 
{ 
    LED1_FLASH(); 
} 
 
 
 
void PrintfDirFile(void) 
{ 
    int result; 
    DIR DirInf;   
    FILINFO FileInf; 
    int cnt; 
 
     
    result = f_opendir(&DirInf, "/"); /* 如果不带参数,则从当前目录开始 */ 
    if (result != FR_OK) 
    { 
        lcd_printf("Root Directory is Open Error (%d)\n", result); 
    } 
    /* 读取当前文件夹下的文件和目录 */ 
    lcd_printf("Name            Tyepe        Size\n"); 
    for (cnt = 0; ;cnt++) 
    { 
        result = f_readdir(&DirInf,&FileInf);      /* 读取目录项,索引会自动下移 */ 
        if (result != FR_OK || FileInf.fname[0] == 0) 
        { 
            break; 
        } 
        if (FileInf.fname[0] == '.') 
        { 
            continue; 
        } 
        lcd_printf("%s  ", FileInf.fname); 
        if (FileInf.fattrib == AM_DIR) 
        { 
            lcd_printf("Directory "); 
        } 
        else 
        { 
            lcd_printf("File  ");   
        } 
        lcd_printf("%d\n", FileInf.fsize); 
    } 
} 
 
 
 
//主函数 
int main(void) 
{   
    int result; 
     
    LCD_Init();                                //初始化LCD 
    UART0_Init(DISABLE,115200);                //初始化串口,失能中断接收,波特率115200 
    LED_Init();                                //初始化LED 
    Timer1_Init(400000-1,ENABLE,LED1_flash);    //初始化定时器1,周期400ms 
    RTC_Init(ENABLE);                          //初始化RTC时钟 
    JPEG_Init();                                //初始化JPEG解码器 
     
     
    result = disk_initialize (DISK_SDMMC);      //初始化磁盘 
    if(result == RES_OK) 
    { 
        lcd_printf("Disk Init OK!\n"); 
        result = f_mount(DISK_SDMMC,&fs); 
        if(result == FR_OK) 
        { 
            lcd_printf("Mount Disk OK!\n"); 
            PrintfDirFile();                        //打印根目录下的文件 
            ShowBmpImage(0,0,0,0,"bmp24.BMP");      //显示全屏图片 
            ShowBmpImage(200,200,0,0,"bmp24.BMP");  //显示缩小的图片 
        } 
        else 
        { 
            lcd_printf("Mount Disk ERROR(%d)!\n",result); 
        } 
    } 
    else 
    { 
        lcd_printf("Disk Init ERROR(%d)!\n",result); 
    } 
     
     
    while(1) 
    { 
        LED2_FLASH();      //LED2闪烁 
        Delay_US(600000); 
        //lcd_printf("%d-%d-%d %d:%d\n",Timer.w_year,Timer.w_month,Timer.w_date,Timer.hour,Timer.min); 
    } 
} 

开发板上面的效果图

OK6410 裸机BMP图片解码

linux
相关资讯       OK6410  OK6410裸机  OK6410裸机程序 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款