cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746-DISCo - How to grab a screen area and save this on bitmap structure ?

In order to create a faster scrollbar function I need to fill a bitmap structure with an area get from the screen.

I have starting to develop this new function starting from the BSP_LCD_DrawBitmap source but how to reverse the LL_ConvertLineToARGB8888() ?

Here the status of this develop.

void BSP_LCD_GrabBitmap(uint32_t Xpos, uint32_t Ypos, uint32_t Width, uint32_t Height, uint8_t *pbmp)
{
  uint32_t index = 0, width = 0, height = 0, bit_pixel = 0;
  uint32_t address;
  uint32_t input_color_mode = 0;
 
  grab_image.fileHeader.bfType     = 0x4d42u;
  grab_image.fileHeader.bfSize     = sizeof(grab_BITMAPINFOHEADER) + sizeof(grab_BITMAPFILEHEADER) + (1288 * 2);
  grab_image.fileHeader.bfOffBits  = sizeof(grab_BITMAPINFOHEADER) + sizeof(grab_BITMAPFILEHEADER);
  grab_image.infoHeader.biSize     = sizeof(grab_BITMAPINFOHEADER);
  grab_image.infoHeader.biWidth    = Width;
  grab_image.infoHeader.biHeight   = Height;
  grab_image.infoHeader.biPlanes   = 1u;
  grab_image.infoHeader.biBitCount = 16;
 
 
 
  /* Get bitmap data address offset */
  //index = pbmp[10] + (pbmp[11] << 8) + (pbmp[12] << 16)  + (pbmp[13] << 24);
  index = grab_image.fileHeader.bfOffBits;
 
  /* Read bitmap width */
  //width = pbmp[18] + (pbmp[19] << 8) + (pbmp[20] << 16)  + (pbmp[21] << 24);
  width = grab_image.infoHeader.biWidth;
 
  /* Read bitmap height */
  //height = pbmp[22] + (pbmp[23] << 8) + (pbmp[24] << 16)  + (pbmp[25] << 24);
  height = grab_image.infoHeader.biHeight;
 
  /* Read bit/pixel */
  //bit_pixel = pbmp[28] + (pbmp[29] << 8);
  bit_pixel = grab_image.infoHeader.biBitCount;
 
  /* Set the address */
  address = hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (((BSP_LCD_GetXSize()*Ypos) + Xpos)*(4));
 
  /* Get the layer pixel format */
  if ((bit_pixel/8) == 4)
  {
    input_color_mode = CM_ARGB8888;
  }
  else if ((bit_pixel/8) == 2)
  {
    input_color_mode = CM_RGB565;
  }
  else
  {
    input_color_mode = CM_RGB888;
  }
 
  /* Bypass the bitmap header */
  pbmp += (index + (width * (height - 1) * (bit_pixel/8)));
 
  /* Convert picture to ARGB8888 pixel format */
  for(index=0; index < height; index++)
  {
    /* Pixel format conversion */
    >>>  LL_ConvertLineToARGB8888((uint32_t *)pbmp, (uint32_t *)address, width, input_color_mode);
   // to convert to ARGB8888 to Line
 
    /* Increment the source and destination buffers */
    address+=  (BSP_LCD_GetXSize()*4);
    pbmp -= width*(bit_pixel/8);
  }
}

0 REPLIES 0