2019-07-08 12:45 AM
Hello,
I would like to know if you could give me any tips about how to display with TouchGFX an image on screen that comes from a USB stick?
Thanks in advance for your help.
2019-07-08 08:59 AM
I've used LodePNG for decoding PNG files and like it so far.
The sequence would be to read the PNG file off the USB stick, decode the file using LodePNG, then copy the decoded data into a dynamic bitmap.
The library uses quite a bit of dynamic memory as does temporarily storing the PNG data (depending on size of images) so you'll want to make sure your heap is large enough to handle it. In my case when doing this I place the heap in my larger external RAM.
2019-07-09 04:12 AM
@Community member is right. That's the procedure. We use something else for decoding pngs i think, and this is not something we're pushing officially. So, what me and Cameron have not done now is to load the pngs from a USB stick. But if you manage to do that we may be able to help you from there.
Let us know!
/Martin
2019-07-09 09:33 AM
If you're having trouble reading the file off the USB stick, ST's example projects are a good resource. There should be a few USB examples for most dev kits. Specifically look for USB bootloader example projects for a reference project that reads files off a USB drive.
2019-09-03 02:30 AM
Hej,
I'm back to this matter after a long break.
What I would like to know is how to copy the decoded data into my dynamic bitmap easily. Here's my current code:
if(f_open(&MyFile, "0:key.png", FA_READ) == FR_OK){
uint16_t read;
size_t png_size = f_size(&MyFile);
unsigned char* img = 0;
unsigned width, height;
unsigned error;
unsigned char* png_file = (unsigned char*)malloc(png_size);
if(png_file != NULL){
res = f_read(&MyFile, png_file, png_size, (UINT*) &read);
}
error = lodepng_decode24(&img, &width, &height, png_file, png_size);
free(png_file);
BitmapId bmpId = Bitmap::dynamicBitmapCreate(width, height, Bitmap::RGB888);
//xQueueSend(bitmap_msg_q, &bmpId,0);
f_close(&MyFile);
}
}
Thanks.
2019-09-04 02:23 AM
Hej,
I'm back to this matter after a long break.
What I would like to know is how to copy the decoded data into my dynamic bitmap easily. Here's my current code:
if(f_open(&MyFile, "0:key.png", FA_READ) == FR_OK){
uint16_t read;
size_t png_size = f_size(&MyFile);
unsigned char* img = 0;
unsigned width, height;
unsigned error;
unsigned char* png_file = (unsigned char*)malloc(png_size);
if(png_file != NULL){
res = f_read(&MyFile, png_file, png_size, (UINT*) &read);
}
error = lodepng_decode24(&img, &width, &height, png_file, png_size);
free(png_file);
BitmapId bmpId = Bitmap::dynamicBitmapCreate(width, height, Bitmap::RGB888);
//xQueueSend(bitmap_msg_q, &bmpId,0);
f_close(&MyFile);
}
Thanks.
2019-09-04 03:22 AM
Hi,
Bitmap has the following method:
const uint8_t* Bitmap::getData() const;
It will return a pointer to the data store for the Bitmap. You can just memcpy your data into this region (taking care only to copy exactly what's needed or risk overriding things in the bitmap cache).
/Martin