niebieski20 Posted June 25, 2016 Report Share Posted June 25, 2016 Hi, Im new in uGFX. I worked before with STemWin and uGFX seems to be much better library as I can control everything and idea that all is an option is really great. So far I generate simple project with uGFX studio where I got container with few buttons and background filled with image. Everything is working as it should. But now I would like to change background image dynamically in application. What would be the best way to do that?? I read forum and I found that I should use gwinContainerDraw_Image(). Is there any example of use of that function?? If I add to project generated by uGFX Studio gwinContainerDraw_Image(&ghContainerPage0, &IMAGE); I got blank screen. Regards. Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted June 25, 2016 Report Share Posted June 25, 2016 Hello and welcome to the community! It is correct that you are supposed to use gwinContainerDraw_Image() for this. The bad news is that the µGFX-Studio doesn't yet support this feature so you have to code it yourself. Once you created the container you can use gwinSetCustomDraw() to change the image pointer and therefore change the image background. This is a working example: #include "gfx.h" static GHandle ghContainer; static gdispImage imgBackground1; static gdispImage imgBackground2; static void createWidgets(void) { GWidgetInit wi; gwinWidgetClearInit(&wi); // Prepare the background images gdispImageOpenFile(&imgBackground1, "background_1.bmp"); gdispImageOpenFile(&imgBackground2, "background_2.bmp"); // Create container wi.g.show = TRUE; wi.g.x = 0; wi.g.y = 0; wi.g.width = 250; wi.g.height = 250; wi.text = "Container"; wi.customDraw = gwinContainerDraw_Image; wi.customParam = (void*)&imgBackground1; ghContainer = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER); gwinRedraw(ghContainer); } int main(int argc, char* argv[]) { (void)argc; (void)argv; gfxInit(); // GWIN settings gwinSetDefaultFont(gdispOpenFont("*")); gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE); // Create the background container createWidgets(); while (1) { gfxSleepMilliseconds(1500); gwinSetCustomDraw(ghContainer, gwinContainerDraw_Image, (void*)&imgBackground2); gfxSleepMilliseconds(1500); gwinSetCustomDraw(ghContainer, gwinContainerDraw_Image, (void*)&imgBackground1); } return 0; } There are of course several optimizations to consider. This is just a minimal example explaining the theory of operation. Please note: The µGFX-Studio is in a very very very early beta stage. While the µGFX library itself is very mature and provides tons and tons of features, the µGFX-Studio is very young and doesn't support many features yet. If you don't find a feature in the µGFX-Studio this doesn't mean that the µGFX library itself doesn't support it. We are happy to hear all your feedback including bug reports, criticism and feature requests about the µGFX-Studio in the corresponding forum section. Link to comment Share on other sites More sharing options...
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