Printing image form sd card to brain not working

so ive been trying to print an image to my brain from my sd card and all I get is a memory error no matter what I do so is there any documentation about how to do this besides the API and does it matter how my sd card is formatted. sorry for the repetitive question plz help if you can

how about you include code you are using … until you do that, no one will be able to give specific help.

1 Like

Here is a thread you can review. There is a note that it can only be done through VexCodePro and not blocks.

3 Likes

We had a problem with this too, but it turned out that the image we were trying to display was 720p, and the v5 brain has a resolution of 480 x 272 pixels. I scaled the image resolution down to 480p in photoshop and then the brain displayed it correctly.

1 Like

ty i will try that and what format does it like for images or are pngs fine

I believe .png’s work

I’ve been corrected, .jpegs aren’t supported

png and bmp only,
jpeg is not supported.

3 Likes

You know James, I think it is time to have a code example of loading DRow for GDC image on V5 Robot Brain display - total cool kid!

It’s one line of code.
as long as the image is 480x240 or smaller and in png or bmp format.

Brain.Screen.drawImageFromFile("drow.png", 0, 0);
5 Likes

Not good enough, need to provide full example project package including the image file - otherwise, not real :slight_smile:

thanks for playing “total cool kid!”

Next contestant?

1 Like

@lacsap
Demo as requested.
copy the two images in the “images” folder of the VEXcode project to the root of an SD card and enjoy.

source code
/*----------------------------------------------------------------------------*/
/*                                                                            */
/*    Module:       main.cpp                                                  */
/*    Author:       james                                                     */
/*    Created:      Tue Feb 08 2022                                           */
/*    Description:  V5 project                                                */
/*                                                                            */
/*----------------------------------------------------------------------------*/

// ---- START VEXCODE CONFIGURED DEVICES ----
// ---- END VEXCODE CONFIGURED DEVICES ----

#include "vex.h"

using namespace vex;

// show simple image on screen
void
image_demo1() {
    Brain.Screen.clearScreen();
    Brain.Screen.printAt(10, 40, "Draw image from file");
    this_thread::sleep_for(1000);

    Brain.Screen.drawImageFromFile("drow.png", 0, 0);
}

// show simple image on screen and then scroll off vertically
void
image_demo2() {
    Brain.Screen.setPenColor(white);
    Brain.Screen.clearScreen();
    Brain.Screen.printAt(10, 40, "Draw image from file and scroll up");
    this_thread::sleep_for(1000);

    Brain.Screen.setPenColor(black);

    Brain.Screen.drawImageFromFile("drow.png", 0, 0);

    for(int y=0;y<=240;y+=5) {
      Brain.Screen.drawImageFromFile("drow.png", 0, -y);
      Brain.Screen.drawRectangle(0, 240-y, 480, 5, black );
      this_thread::sleep_for(10);
    }
}

// show simple image on screen and then scroll off horizontally
void
image_demo3() {
    Brain.Screen.setPenColor(white);
    Brain.Screen.clearScreen();
    Brain.Screen.printAt(10, 40, "Draw image from file and scroll left");
    this_thread::sleep_for(1000);

    Brain.Screen.setPenColor(black);

    Brain.Screen.drawImageFromFile("drow.png", 0, 0);

    for(int x=0;x<=480;x+=20) {
      Brain.Screen.drawImageFromFile("drow.png", -x, 0);
      Brain.Screen.drawRectangle(480-x, 0, 20, 240, black );
      this_thread::sleep_for(10);
    }
}

// display image and then replace with another using buffers
void
image_demo4() {
    static  uint8_t  image_1[ 200 * 1024 ];
    static  uint8_t  image_2[ 200 * 1024 ];

    Brain.Screen.setPenColor(white);
    Brain.Screen.clearScreen();
    Brain.Screen.printAt(10, 40, "Read images into buffers and scroll");
    this_thread::sleep_for(1000);

    uint32_t buffer_len_1 = Brain.SDcard.loadfile("drow.png", image_1, sizeof(image_1));
    uint32_t buffer_len_2 = Brain.SDcard.loadfile("drow_1.png", image_2, sizeof(image_2));

    // buffer lengths should be smaller than the buffers
    // if they are the same size then images are bigger.
    if( buffer_len_1 == sizeof(image_1) || buffer_len_2 == sizeof(image_1) ) {
      Brain.Screen.printAt(10, 50, "Error");
      return;
    }

    Brain.Screen.setPenColor(black);

    // draw first image
    Brain.Screen.drawImageFromBuffer( image_1, 0, 0, sizeof(image_1));

    uint8_t *p = image_1;
    uint8_t *q = image_2;
        
    for(int loops = 0;loops < 10;loops++ ) {
      for(int x=20;x<=480;x+=20) {
        Brain.Screen.drawImageFromBuffer( p, -x, 0, buffer_len_1);
        Brain.Screen.drawImageFromBuffer( q, 480-x, 0, buffer_len_2);

        // flickerless display
        Brain.Screen.render();
      }

      // swap buffers
      uint8_t *t = p;
      p = q;
      q = t;
      
      uint32_t l = buffer_len_1;
      buffer_len_1 = buffer_len_2;
      buffer_len_2 = l;
    }
}

int main() {   
    image_demo1();
    this_thread::sleep_for(3000);
    image_demo2();
    this_thread::sleep_for(1000);
    image_demo3();
    this_thread::sleep_for(1000);
    image_demo4();

    while(1) {
        // Allow other tasks to run
        this_thread::sleep_for(10);
    }
}

V5_ImageDemo.zip (331.5 KB)

7 Likes

ugh - sorry I challenged - I expect lots of Drow for GDC on their robot brains - now it is on them to create an autonomous routine selector, e.g., press Drow nose to execute center neutral goal grab, and balance on platform!

Your turn VEXforum elite!

(thanks James, I do believe example codes help teams find a path - much like you did with so many examples in the past!

1 Like

ugh you should see the amount of code I needed in lvgl for that crap to work :roll_eyes:

1 Like

What format is the image? When I unpack “drow_1.png” it is not an ordinary PNG file:

hdpng

Couldn’t open it with viewer or gimp.

1 Like

Looks like something got messed up with the PNG. The header is supposed to be hex 89, then “PNG”, but hex 89 somehow got replaced with “ef bf bd”, which is a substitute replacement character in UTF-8. This pattern also reappears a few other times. My best guess is that someone opened this image in a text editor and saved it… Can never really know for sure though.

1 Like

I’ll check, perhaps VEXcode export messed it up. The original had been resized in PS on a Mac.

1 Like

here’s the project with “uncorrupted” DRow image files, who knew DRow was corruptible…
(and I will replace the original as well)

V5_ImageDemo.zip (331.5 KB)

6 Likes