怎么用红牛开发板的TFT屏显示灰度图?我写了个程序 但是处理后显示的图片乱麻麻的,不是灰度图捏。请大家帮我看一下,感激~~~
/* Includes ------------------------------------------------------------------*/
#include "lcd.h"
#include "stm32f10x_lib.h"
#include "platform_config.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
static vu32 TimingDelay = 0;
GPIO_InitTypeDef GPIO_InitStructure;
ErrorStatus HSEStartUpStatus;
extern unsigned char Image_Table[];
unsigned char Gray_Table[82944];
//unsigned char Gray_Table[27648];
/* Private function prototypes -----------------------------------------------*/
void RCC_Configuration(void);
void InterruptConfig(void);
void NVIC_Configuration(void);
void Delay(vu32 nCount);
void Decrement_TimingDelay(void);
void SysTick_Config(void);
/* Private functions ---------------------------------------------------------*/
/*******************************************************************************
* Function Name : main
* Description : Main program.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
int main(void)
{
u32 i;
#ifdef DEBUG
debug();
#endif
/* System Clocks Configuration */
RCC_Configuration();
/* Interrupt Configuration */
InterruptConfig();
/* Configure the systick */
SysTick_Config();
/* Initialize the LCD */
STM3210E_LCD_Init();
/* Clear the LCD */
LCD_Clear(Black);
LCD_SetDisplayWindow(00, 00, 239, 319);
LCD_WriteBMP(48, 64, 144, 192, Image_Table);
for(i=0;i<100000;i++);
BMPtoGray(Image_Table,Gray_Table);
LCD_Clear(Black);
LCD_SetDisplayWindow(00, 00, 239, 319);
LCD_WriteBMP(48, 64, 144, 192, Gray_Table);
}
void BMPtoGray(u8 *bitmap,u8 *graymap)
{
u32 i;
for(i=0;i<27648;i++)
{
*graymap=(*bitmap*30+*(bitmap+1)*59+*(bitmap+2)*11)/100;
*(graymap+1)= *(graymap+2)=*graymap;
graymap+=3;
bitmap+=3;
}
} |