Nico Hell Posted July 17, 2020 Report Posted July 17, 2020 Hello ! I started this topic because I might need some help to be able to display a PNG image on my screen. I tried to follow everything from the documentation but without success. I will try to explain what I would like to do if possible: the system I use already uses a filesystem (LittleFS), this filesystem contains a PNG file that I want to display on my screen but I do not know well what I have to do to make it works. Should I implement a USERFS ? I tried that but without success, perhaps I did not implement it properly. Otherwise, as my system already contains a file manager, what I would rather do is open my file and use it directly within a ImageBox widget, is there a way to do that ? Thanks for you help, if you need further details, just ask
Nico Hell Posted July 17, 2020 Author Report Posted July 17, 2020 static GHandle gh_image; /******************************************************************************/ eStatus IF_EINK_DISPLAY_displayPNGFile(char * const pc_iFilePath, uint16_t u16_iX, uint16_t u16_iY, uint16_t u16_iWidth, uint16_t u16_iHeight) { uint32_t u32_startTick = HAL_GetTick(); eStatus e_status = eOK; GWidgetInit widget; gwinSetDefaultFont(gdispOpenFont("UI2")); gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE); gdispClear(White); e_status = AP_FILE_MNGR_fillBufferFromFile(pc_iFilePath, g_au8_screenBuffer, CF_IT8951_SCREEN_WIDTH*CF_IT8951_SCREEN_HEIGHT); // Apply some default values for GWIN widget.g.show = TRUE; // create the first image widget widget.g.x = u16_iX; widget.g.y = u16_iY; widget.g.width = u16_iWidth; widget.g.height = u16_iHeight; gh_image = gwinImageCreate(NULL, &widget.g); gwinImageOpenMemory(gh_image, g_au8_screenBuffer); LOG(IF_EINK_DISPLAY, LVL_INFO, "PNG display in %d ms", HAL_GetTick() - u32_startTick); return e_status; } Here is the code implemented, I load my file in a buffer and try to use uGFX API to display it on screen, no effect currently
Nico Hell Posted July 21, 2020 Author Report Posted July 21, 2020 Nevermind, I got it right, I just needed to call gdispFlush() to refresh my screen and it works a bit (still some kind of decompression issue but that is something else)
Nico Hell Posted July 22, 2020 Author Report Posted July 22, 2020 (edited) Actually I might need some help with my current issue, I managed to open and display a PNG file using OpenMemory function. However, the image displayed is a bit weird: it looks like parts of it are mixed up or removed. I will attach the image I want to display and the actual result I get + the code just to show how it is done. Can someone possibly explain this weird behaviour ? Any help would be appreciated. static GHandle gh_image; /******************************************************************************/ eStatus IF_EINK_DISPLAY_displayImage(uint8_t * const kpu8_imgBuffer, uint16_t u16_iX, uint16_t u16_iY, uint16_t u16_iWidth, uint16_t u16_iHeight) { uint32_t u32_startTick = HAL_GetTick(); eStatus e_status = eOK; GWidgetInit widget; gwinSetDefaultFont(gdispOpenFont("UI2")); gwinSetDefaultStyle(&BlackWidgetStyleLP, FALSE); gwinSetDefaultColor(GFX_WHITE); gdispClear(White); // Apply some default values for GWIN gwinWidgetClearInit(&widget); // Apply some default values for GWIN widget.g.show = TRUE; // create the first image widget widget.g.x = u16_iX; widget.g.y = u16_iY; widget.g.width = u16_iWidth; widget.g.height = u16_iHeight; gh_image = gwinImageCreate(NULL, &widget.g); gwinImageOpenMemory(gh_image, kpu8_imgBuffer); //Refresh screen to display image gdispFlush(); LOG(IF_EINK_DISPLAY, LVL_INFO, "PNG display in %d ms", HAL_GetTick() - u32_startTick); return e_status; } Edited July 22, 2020 by Nico Hell Correction
Joel Bodenmann Posted July 24, 2020 Report Posted July 24, 2020 Unfortunately nothing comes to mind. Things you can do to proceed: Try to display the same PNG file in an µGFX application you compile as a native desktop application (Windows, Linux, Mac OS...). If that works without any problems there's a good chance that the image you're loading into memory is corrupted at which point you'd need to revisit your USERFS implementation. The PNG decoder is in general known to work although it is not used as often due to large memory requirements for the decompression algorithm. Before all of this it might be worth confirming that your display driver is working correctly. Run some tests (eg. color fills, drawing rectangles, circles & text) to see whether the issue is actually in the image loading/rendering and not somewhere else.
Nico Hell Posted July 27, 2020 Author Report Posted July 27, 2020 (edited) Thanks for your answer, I guess I will try that. I tried to test if the file read was corrupted by looking directly into the memory, it did not seem to be corrupted, the pointer passed to gwinImageOpenMemory was correct, containing the very same data than the original PNG file. Could still be a driver issue or the interaction between the driver and uGFX, I need to look more in depth into that. Edited July 27, 2020 by Nico Hell
Joel Bodenmann Posted July 28, 2020 Report Posted July 28, 2020 If the memory of the image you're passing is correct then the following two cases seem the most likely: Your GDISP driver / display controller / display module setup has an issue. Perform tests as explained in my previous post to check. There's an issue in the PNG decoder. You can simply test another PNG image to see whether you have the same issue.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now