We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Is it possible to display the filename and the path of an image that has been loaded in setup? I tried to just print the image variable - I get this: "processing.core.PImage@28b301f2"
PImage img; // Declare variable "a" of type PImage
void setup() {
size(640, 360);
img = loadImage("moonwalk.jpg"); // Load the image into the program
}
void draw() {
image(img, 0, 0);
println(img);// try to print the image filename (and maybe it's path?)
}
Answers
AFAIK, there is no way to check the path of a
PImage
after it has been loaded. The best that you can do is store the path in a global variable:Of course, this probably isn't anything like what you want. Depending on your needs, you could create a separate set of
String
s that contain the filenames of correspondingPImages
, or, perhaps, you could create a wrapper class that stores thePImage
and the filename:Thanks Calsign, I had searched far and wide for something built in. I think your method could be useful.
there is one typo in the class that stops it running: I changed "class SmartPIamge" to: "class SmartPImage"
I guess the typo is proof you wrote that in your head, rather than my more mortal way of using the ide and trial and error :)
cheers!
For anyone else watching: change "string" to "String" and "imgPath" to "imgFilename" to get your Calsign's first example to work.
Indeed, it appears that I am a bit careless today. This is what happens when I don't test the code before posting... it should be all fixed, now.