Adding images with absolute paths

How do i add absolute paths for an image ?
is there any way to load images that are not stored in the default data path
or is there any way to change the default data path to some other location for that sketch

this is the code that i am working with currently

PImage img;
void setup(){
size(800,600,P3D);
img = loadImage(“A:\Files\7.jpg”);
img.resize(800,600);
image(img,0,0);
}

i am getting an error on line 4 saying that (invalid escape sequence(valid ones are only \b \t \n \f \r " ’ \)

the same code works if i save the image in the data folder and change----A:\Desktop\7.jpg---- to just
----7.jpg-----

is there any way that i can still load files into the sketch that are not saved in the data folder
(i am currently using processing version 3.3.7)(did absolute paths worked in the earlier versions of processing if yes is their any way i can use P3D mode in that version of processing )

Given the \ is an escape character, in order to actually have it inside quotes "", we escape it w/ another \: :upside_down_face:
println("\\");

Nevertheless, we don’t need that for Processing functions, like loadImage() for example, b/c they accept the regular forward slash character / even in Windows! :stuck_out_tongue_winking_eye:

IMO, absolute paths should be avoided, b/c they make our sketches bound to a specific computer when we happen to export the app. :roll_eyes:

2 Likes