cancel
Showing results for 
Search instead for 
Did you mean: 

How to load an image from an external device and save it in flash and use it afterwards as any other images that were included in the project?

GMeur
Senior

Hi,

I would like to know how I could go about loading an image from an external device and saving it in flash while modifying the BitmapDataBase (better said : creating another database that serves the same purpose as the BitmapDateBase is overwritten each time a 'generate' is done in the studio) so as to be able to use bmpId afterwards and just use it as any other image.

I'm using for now the best solution I've been able to find (far from perfect) : I pre-generate in the external flash X photos (completely transparent) of a given size and format ( 181 * 181, ARGB8888) that I place each in a section of 128K. Therefore, each space has its corresponding bitmapId that I can use afterwards. When I copy an image, I write a signature at the end of the section so as to say that there is, indeed, an image there.

However, this solution works only for images of that specific size (meaning that I've to resize smaller/bigger images so as they match these exact dimensions) and specific format. An image without transparency for instance won't paint right, unless I convert it to that specific format… So it works, but it's obviously a rather ugly solution and far from satisfying as it's rather limited.

As I haven't been able to find a way to do that properly, I'm eager to hear from you.

G.

4 REPLIES 4
MM..1
Chief III

Maybe i dont understand your Idea. What is external device , and why save in flash and how flash internal or external ???

Simple reply is learn use dynamic image. Is your images changed on runtime or on development time?

Alexandre RENOUX
Principal

Hello GMeur,

You cannot dynamically modify the BitmapDataBase since it is created by the code generation in TouchGFX Designer.

The current solution to fetch images from external memory and use them in your UI application is to use Dynamic Bitmaps.

/Alexandre

GMeur
Senior

@MM..1​  : by external device I meant an USB, an external hard drive,… any "device" that can store images. I know how to use dynamic bitmaps but it's not what i'm looking to do.

@Alexandre RENOUX : yeah yeah, I know the BitmapDataBase cannot be dynamically modified that's why I'm doing it the way I described above.

But let me try to explain myself better by giving you a brief example. Imagine I want to create a screen to create user accounts… I would like to be able to choose a name for that user account but also an icon. So imagine that I include by default 10 icons for the user to choose from… Doing that is quite easy, I just have to include all the images in the project, generate it, and then create a table called 'BITMAP_ID_ICONS' that references only those icons' ids.

Now, imagine I'd like too for the user to import their own icons through a USB device… Indeed, solely having the possibility to choose from 10 icons is quite limited…

So I create another screen called 'USB' that lists all the files from the USB flash drive that's currently connected. As I want to previsualize the PNG files, I use dynamic bitmaps… Simple, no? Now, when the user selects a png file to import it, I've to copy it to the 'internal memory' (flash) because, cleary, I need to have access to this image even after, when there is no more USB connected… And ideally, I want to have a bitmap_id that's linked to that image and that I can include to my previous table (BITMAP_ID_ICONS) so that I can show all default icons plus the ones that were imported by the users (the idea is treating all images identically). How can I go about to do this? Also, I have to specify that I don't have a SD drive connected to my PCB that I could use to store those images… They have to go in flash…

Hope I've been clearer :)

Then maybe you need some way to change const to no const

const touchgfx::Bitmap::BitmapData bitmap_database[] =
{

i see more way for example after generated run an cmd script to manage cpp files edit usw.