1

I am trying to load 8 images. These images do not load and I don't know why. I use Xcode which placed the files to the directory. I think there might be something wrong with my code.

Function:

void loadImages() {
for(int i = 0; i < 8; i++) pict[0] = NULL;
pict[0] = IMG_Load("jpg/colorfull small jpg.jpg");
if(pict[0] == NULL) cout << "Unable to load image\n";

pict[1] = IMG_Load("jpg/colorfull big jpg.jpg");
if(pict[1] == NULL) cout << "Unable to load image\n";

pict[2] = IMG_Load("jpg/colorless small jpg.jpg");
if(pict[2] == NULL) cout << "Unable to load image\n";

pict[3] = IMG_Load("jpg/colorless big jpg.jpg");
if(pict[3] == NULL) cout << "Unable to load image\n";

pict[4] = IMG_Load("png/colorfull small png.png");
if(pict[4] == NULL) cout << "Unable to load image\n";

pict[5] = IMG_Load("png/colorfull big png.png");
if(pict[5] == NULL) cout << "Unable to load image\n";

pict[6] = IMG_Load("png/colorless small png.png");
if(pict[6] == NULL) cout << "Unable to load image\n";

pict[7] = IMG_Load("png/colorless big png.png");
if(pict[7] == NULL) cout << "Unable to load image\n"; }

Compiler:

enter image description here

enter image description here

Directory:

enter image description here

genpfault
  • 51,148
  • 11
  • 85
  • 139
Sam
  • 1,130
  • 12
  • 36

1 Answers1

2

Make sure the current working directory for your process is what you think it is.

Or use absolute paths.

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • Thank you. After reading your post about the working directory, I brought up a problem from earlier this day with SFML. I got an answer that told me how to get the real location of folder. I did it again in here and it helped. Thank you however for the inspiration. Link to previous question: http://stackoverflow.com/questions/20203108/sfml-image-not-loading – Sam Nov 26 '13 at 20:04