下面是一个写图片的函数,但是我取模得到的类型char型,函数要求是int型,强制转换数据应该不对。那么有什么办法修改这个函数,直接利用取模得到的就可以显示呢?我的屏幕利用的是RGB模式,是不是不能直接开窗啊?
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned __int64 uint64_t;
void LCD_WriteBMP(uint32_t BmpAddress)
{
uint32_t index = 0, size = 0, width = 0, height = 0, bit_pixel = 0;
uint32_t Address;
uint32_t currentline = 0, linenumber = 0;
Address = CurrentFrameBuffer;
/* Read bitmap size */
size = *(__IO uint16_t *) (BmpAddress + 2);
size |= (*(__IO uint16_t *) (BmpAddress + 4)) << 16;//òì»ò£¨òì1í¬0£©
/* Get bitmap data address offset */
index = *(__IO uint16_t *) (BmpAddress + 10);
index |= (*(__IO uint16_t *) (BmpAddress + 12)) << 16;
/* Read bitmap width */
width = *(uint16_t *) (BmpAddress + 18);
width |= (*(uint16_t *) (BmpAddress + 20)) << 16;
/* Read bitmap height */
height = *(uint16_t *) (BmpAddress + 22);
height |= (*(uint16_t *) (BmpAddress + 24)) << 16;
/* Read bit/pixel */
bit_pixel = *(uint16_t *) (BmpAddress + 28);
if (CurrentLayer == LCD_BACKGROUND_LAYER)
{
/* reconfigure layer size in accordance with the picture */
TLDI_LayerSize(TLDI_Layer1, width, height);
TLDI_ReloadConfig(TLDI_RELOADLAYERTYPE_FBR);
/* Reconfigure the Layer pixel format in accordance with the picture */
if ((bit_pixel/8) == 4)
{
TLDI_LayerPixelFormat(TLDI_Layer1, PF_ARGB8888);
TLDI_ReloadConfig(TLDI_RELOADLAYERTYPE_FBR);
}
else if ((bit_pixel/8) == 2)
{
TLDI_LayerPixelFormat(TLDI_Layer1, PF_RGB565);
TLDI_ReloadConfig(TLDI_RELOADLAYERTYPE_FBR);
}
else
{
TLDI_LayerPixelFormat(TLDI_Layer1, PF_RGB888);
TLDI_ReloadConfig(TLDI_RELOADLAYERTYPE_FBR);
}
}
else
{
/* reconfigure layer size in accordance with the picture */
TLDI_LayerSize(TLDI_Layer2, width, height);
TLDI_ReloadConfig(TLDI_RELOADLAYERTYPE_FBR);
/* Reconfigure the Layer pixel format in accordance with the picture */
if ((bit_pixel/8) == 4)
{
TLDI_LayerPixelFormat(TLDI_Layer2, PF_ARGB8888);
TLDI_ReloadConfig(TLDI_RELOADLAYERTYPE_FBR);
}
else if ((bit_pixel/8) == 2)
{
TLDI_LayerPixelFormat(TLDI_Layer2, PF_RGB565);
TLDI_ReloadConfig(TLDI_RELOADLAYERTYPE_FBR);
}
else
{
TLDI_LayerPixelFormat(TLDI_Layer2, PF_RGB888);
TLDI_ReloadConfig(TLDI_RELOADLAYERTYPE_FBR);
}
}
/* compute the real size of the picture (without the header)) */
size = (size - index);
/* bypass the bitmap header */
BmpAddress += index;
/* start copie image from the bottom */
Address += width*(height-1)*(bit_pixel/8);
for(index = 0; index < size; index++)
{
*(__IO uint8_t*) (Address) = *(__IO uint8_t *)BmpAddress;
/*jump on next byte */
BmpAddress++;
Address++;
currentline++;
if((currentline/(bit_pixel/8)) == width)
{
if(linenumber < height)
{
linenumber++;
Address -=(2*width*(bit_pixel/8));
currentline = 0;
}
}
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>