so I’m having trouble coding a picture to be displayed on the V5 screen. This is the code I used (I have no idea how to use this particular piece of code, so there’s probably some silly mistake):
vex::brain::lcd::drawImageFromFile(pic.png, 120, 0);
The reason I want it to start 120 pixels from the left is because it’s a square image.
Thanks in advance
pic.png is not a filename.
"pic.png" would be. The
"s tell the compiler that the stuff inside of them is a string. Otherwise it will think you are referring to a member
png of the object
drawImageFromFile is not a static method, so you have to call it on a
vex::brain::lcd object. Luckily for you, there is one of these created with every
vex::brain object. Also, your code template should have come with a
vex::brain having already been set up for you. (If you’re using Robot Mesh Studio, that
vex::brain is named
Brain.) It has a
vex::brain::lcd member that goes by the name
Screen. So putting this all together, you would for Brain’s Screen’s drawImageFromFile method by stringing them together:
After all that, just make sure that you have an SD card plugged into the brain with a
"pic.png" on it.
Of course! I totally forgot about the "s. I would have probably tried for hours until I realized that it should be Screen instead of lcd.
Thank you so much for your help!
So I’m using vex code and I used this line of code
vex::brain::lcd::drawImageFromFile("image.png", 0, 0) and I get an error. what could that be?
you need to use the line that John_TYler suggested:
Brain.Screen.drawImageFromFile("image.png", 0, 0);
Second paragraph of my reply
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.