void BSP_LCD_DrawBitmap2(uint32_t X, uint32_t Y, uint8_t *pBmp, uint32_t width, uint32_t height,
                         uint32_t bitpixel )
{
  uint32_t address;
  uint32_t inputcolormode = 0;
  uint32_t index;
  
  /* Get bitmap data address offset */
  // index = pBmp[10] + (pBmp[11] << 8) + (pBmp[12] << 16)  + (pBmp[13] << 24);

  /* Read bitmap width */
  // width = pBmp[18] + (pBmp[19] << 8) + (pBmp[20] << 16)  + (pBmp[21] << 24);

  /* Read bitmap height */
  // height = pBmp[22] + (pBmp[23] << 8) + (pBmp[24] << 16)  + (pBmp[25] << 24);

  /* Read bit/pixel */
  // bitpixel = pBmp[28] + (pBmp[29] << 8);   
 
  /* Set Address */
  address = LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (((BSP_LCD_GetXSize()*Y) + X)*(4));

  /* Get the Layer pixel format */    
  if ((bitpixel/8) == 4)
  {
    inputcolormode = CM_ARGB8888;
  }
  else if ((bitpixel/8) == 2)
  {
    inputcolormode = CM_RGB565;
  }
  else
  {
    inputcolormode = CM_RGB888;
  }
 
  /* bypass the bitmap header */
  // ST effers again.
  // This doesn't just bypass the header
  // it also moves the pointer to end of the image
  // as it is painted backwards.
  // so i commented it out since my bmp doesn't
  // have a header.. crap
  // pBmp += (index + (width * (height - 1) * (bitpixel/8)));
  pBmp += ((width * (height - 1) * (bitpixel/8)));

  /* Convert picture to ARGB8888 pixel format */
  for(index=0; index < height; index++)
  {
  /* Pixel format conversion */
  ConvertLineToARGB8888((uint32_t *)pBmp, (uint32_t *)address, width, inputcolormode);

  /* Increment the source and destination buffers */
  address+=  ((BSP_LCD_GetXSize() - width + width)*4);
  pBmp -= width*(bitpixel/8);
  }
}
Ejemplo n.º 2
0
/**
  * @brief  Displays a bitmap picture loaded in the internal Flash (32 bpp).
  * @param  X: the bmp x position in the LCD
  * @param  Y: the bmp Y position in the LCD
  * @param  pBmp: Bmp picture address in the internal Flash
  * @retval None
  */
void BSP_LCD_DrawBitmap(uint32_t X, uint32_t Y, uint8_t *pBmp)
{
  uint32_t index = 0, width = 0, height = 0, bitpixel = 0;
  uint32_t address;
  uint32_t inputcolormode = 0;
  
  /* Get bitmap data address offset */
  index = *(__IO uint16_t *) (pBmp + 10);
  index |= (*(__IO uint16_t *) (pBmp + 12)) << 16;

  /* Read bitmap width */
  width = *(uint16_t *) (pBmp + 18);
  width |= (*(uint16_t *) (pBmp + 20)) << 16;

  /* Read bitmap height */
  height = *(uint16_t *) (pBmp + 22);
  height |= (*(uint16_t *) (pBmp + 24)) << 16; 
 
  /* Read bit/pixel */
  bitpixel = *(uint16_t *) (pBmp + 28);   
 
  /* Set Address */
  address = LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (((BSP_LCD_GetXSize()*Y) + X)*(4));

  /* Get the Layer pixel format */    
  if ((bitpixel/8) == 4)
  {
    inputcolormode = CM_ARGB8888;
  }
  else if ((bitpixel/8) == 2)
  {
    inputcolormode = CM_RGB565;
  }
  else
  {
    inputcolormode = CM_RGB888;
  }
 
  /* bypass the bitmap header */
  pBmp += (index + (width * (height - 1) * (bitpixel/8)));

  /* Convert picture to ARGB8888 pixel format */
  for(index=0; index < height; index++)
  {
  /* Pixel format conversion */
  ConvertLineToARGB8888((uint32_t *)pBmp, (uint32_t *)address, width, inputcolormode);

  /* Increment the source and destination buffers */
  address+=  ((BSP_LCD_GetXSize() - width + width)*4);
  pBmp -= width*(bitpixel/8);
  }
}