Convert PNG stream to GUI_BITMAP

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Convert PNG stream to GUI_BITMAP

1,134 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by harper23 on Fri Jun 28 09:17:59 MST 2013

I have some PNG streams stored on a slow device (serial flash) that shall be displayed. emWin supports drawing such files with the GUI_PNG_DrawExt() function.


The problem is, that the PNG graphics should be displayed alternatively. Calling the function GUI_PNF_DrawExt() takes to much time. How can the PNG stream converted to a GUI_BITMAP that can be displayed directly on the LCD device? The alpha values in the PNG stream must be kept.

Labels (1)
0 Kudos
3 Replies

741 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wouter on Thu Jul 04 01:58:46 MST 2013

I see what you mean. It looks like the memory devices do not support an additional alpha/transparency layer. The transparency option on memory devices simply works by keeping track which pixel are updates, and only copy the pixels which have changed. This works fine for all standard drawing operations (e.g. line, circle etc.), but not for images with transparency since all pixels are updated in that case.


If the background (where the transparent pixels of the image would be) is static during runtime, you could copy the content of the display to the memory device before drawing the png with transparency layer. This way the transparency layer of the png is taken into account.


I've created a simple example showing how to do this, see below


<code>
hMem1 = GUI_MEMDEV_Create(0, 0, 193, 112);          /* Create memdev with size of PNG image */
hWin = CreateFramewin();                            /* Create GUI */
GUI_Exec();                                         /* Make sure GUI is drawn to LCD */
GUI_MEMDEV_CopyFromLCD(hMem1);                      /* Copy LCD to memdev */
GUI_MEMDEV_Select(hMem1);                           /* Select memdev */
GUI_PNG_DrawEx(&GetData, (void*)_acImage_0, 0, 0);  /* Draw PNG with transparency layer to memdev, GUI is used as background */
hFrameWin = WM_GetFirstChild(hWin);                 /* Get handle of FrameWin */
WM_SelectWindow(hFrameWin);                         /* Select FrameWin */
GUI_MEMDEV_CopyToLCD(hMem1);                        /* Draw memdev to FrameWin*/
while(1)
{
  GUI_Delay(100);
}
</code>
0 Kudos

741 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by harper23 on Wed Jul 03 11:27:41 MST 2013

<span style="font-family: Roboto, sans-serif; font-size: 14px; background-color: #ffffff;">&gt; If decompressing the image from RAM also takes too long, you probably could create a memory device in emWin to hold the decompressed image, which then could be copied to the LCD.</span>


<span>This sounds good. The PNG contains RGB and alpha values. But GUI_MEMDEV_Write ignores the transparency iformation. Are there any settings for emWin, the memory device or any other parameter to set so that alpha blending works when the memory device is "copied to the LCD."</span>

0 Kudos

741 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wouter on Tue Jul 02 04:20:44 MST 2013

Hi,


 


If the speed of the memory is the bottleneck, you could simply copy the PNG to RAM on startup. Storing the PNG file still compressed in RAM will save quite some RAM compared to storing the image as a bitmap.


If decompressing the image from RAM also takes too long, you probably could create a memory device in emWin to hold the decompressed image, which then could be copied to the LCD.


 


Regards,


Wouter

0 Kudos