Drawing Image on V5 Screen

I was trying to draw an image from the SD card onto the Brain Screen, but I couldn’t figure out how to do it. Does anyone have sample code for that?

Please provide more information, such as what language are you using.
Have you researched on the forum?
If you use PROS, you can use LVGL (though there may currently be a problem with lvgl reading from the SD).
If you use VCS/VEXcode, there may be a function for it (check the docs or VEXCode headers).
Look on the forum for jpearman’s GIF demo, which reads a file from the SD card using raw C-style file access.
A simple search on the forum leads me to these threads, which may provide some insight:

It looks like you can use

bool vex::brain::lcd::drawImageFromFile ( const char * name, int x, int y)

For example

Brain.Screen.drawImageFromFile( "V5-Brain-small.png", 0, 0 );

Sorry I neglected to state I was using VexCode C++. I have looked at some things on the forum and came up with this code

#include "vex.h"

using namespace vex;

// A global instance of vex::brain used for printing to the V5 brain screen
vex::brain       Brain;

int main() {
    while(1) {

        // Allow other tasks to run

Unfortunately this will not draw the image.

The only thing I can think of is that your image file is not in the correct location or is nonexistent, it is not the correct dimensions or encoding, or that your SD card is not properly formatted.
Make sure your sd is formatted with fat32.

1 Like

do not forget to render the image somewhere… here is jpearman’s animated gif example:

and the snippet:

vex::brain       Brain;

int main() {
  int count = 0;

  vex::Gif gif("world.gif", 120, 0 );
  while(1) {
    Brain.Screen.printAt( 5, 230, "render %d", count++ );

yea, render is not necessary. Brain.Screen.render(); switches the V5 over to using double buffered output, that’s useful for displaying sequential images or other graphics without flicker, but not necessary for displaying a single image.

1 Like

perhaps attach the image to this thread, as @theol0403 suggested, it’s probably too large or something simple like that.


Was thinking about that - too early in the morning in this time zone to be really be thinking clearly :slight_smile:


I put the image in and I attached the image in a zipped folder in case that wouldn’t work. @jpearman what are the limits for images?

(Yes there is no background on the cube)

cubeimage.zip (191.8 KB)

You want to resize the image to 480x240, as that is the brain’s resolution.
Since the image is square the best you can do is resize so the height is 240.

1 Like

Ah excellent! Thank you very much everyone! Resizing solved it.