Skip to main content
Mvill.17
Associate III
May 23, 2019
Solved

I want to load a jpg image using touchgfx. I tried the JPEG_file_loader example but it doesn't compile either. Anybody can help me? Thanks

  • May 23, 2019
  • 1 reply
  • 1305 views

void Screen1View::setupScreen()
{
 FILE* f = fopen("C:\\Temp\\image.jpg", "rb");
 uint16_t width, height;

 JPEGFileLoader::getJPEGDimensions(f, width, height);
 BitmapId bmpId;

 //create dynamic bitmap matching file dimensions and in format matching LCD

 if (HAL::lcd().bitDepth() == 16)

 {
 bmpId = Bitmap::dynamicBitmapCreate(width, height, Bitmap::RGB565);
 }
 else
 {
 bmpId = Bitmap::dynamicBitmapCreate(width, height, Bitmap::RGB888);
 }
 if (bmpId != BITMAP_INVALID)
 {
 //Succesfully created, load JPEG file to bitmap
 JPEGFileLoader::readJPEGFile(Bitmap(bmpId), f, lineBuffer);

 }
 //Image shall show the loaded bitmap

 image.setBitmap(Bitmap(bmpId));

 //Position image and add to View

 image.setXY(20, 20);
 add(image);
 Screen1ViewBase::setupScreen();

}
This topic has been closed for replies.
Best answer by Mvill.17

Solved: I missed to define: uint8_t bmpCache[300 * 1024];

1 reply

Mvill.17
Mvill.17AuthorBest answer
Associate III
May 23, 2019

Solved: I missed to define: uint8_t bmpCache[300 * 1024];