Jump to content

Closing an Image Box File


kengineer

Recommended Posts

What is the proper way to close an open file for an image box? The image box example included in uGFX use a memory example and not a file one. I am using a limited performance system and can't open too many files at once. The idea I had would be to open the file, show the widget, then close the file. I understand that if I want to do something that requires a redraw (like move) I will need to open the image again. I was able to do this already but am not sure if there is a better or more proper way:

gwinImageOpenFile(HDL_IMG, "image.bmp");
gwinShow(HDL_IMG);
gdispImageClose(&((GImageObject *)HDL_IMG)->image);

 

Edited by kengineer
Link to comment
Share on other sites

The thing to watch out for is that gwinShow may not immediately redraw depending on the current gwin redraw policy. If it doesn't immediately redraw, adding a gfxYield may be sufficient to allow the redraw timer to be triggered and run before you close the image.

If it is just an image box you might want to consider just using the gdisp calls themselves to directly draw the box on the screen especially if you are planning on managing any redraw manually yourself. This would save the ram overhead of the gwin image box itself.

Assuming that it is the FAT file descriptor that is the overhead you want to avoid and not the gfile descriptor (which is small) or the gdisp image structure, another solution would be to change the image code so that it saves the filename and reopens the file automatically if it is closed. Doing that at the gwin level could even save the image structure overhead.  All that however would require changing the ugfx library code for the benefit of not having to manually manage the redraw. If you decide to go that path please contribute the modifications. 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...