Welcome! Log In Create A New Profile

Advanced

libwiisprite won't load images (FIXED)

Posted by XEnterprises 
libwiisprite won't load images (FIXED)
October 27, 2009 12:49AM
Hello, I'm new to Wii homebrew development but not to programming. I have been programming for a few years now.

So, anyway, I'm trying to use libwiisprite and it looks pretty simple to me so I use this line:
if(image.LoadImage("/apps/XsTests/cursor.png") != IMG_LOAD_ERROR_NONE) { } else { imgloaded = true; }
to load an image. I've tried many other path formats and I got it to work before, but I don't remember how exactly. I know it has something to do with the path. I have initialized fatlib and libwiisprite correctly, it just won't load the images.

Any help as to how I format the path?

Thanks,
X Enterprises



Edited 1 time(s). Last edit at 10/29/2009 12:24AM by XEnterprises.
Re: libwiisprite won't load images
October 27, 2009 01:20AM
please ask a mod(most likely Arikado) to have this topic moved to this section: Coding

To answer your question, I cant remember if libwiisprite put's the "sd:/" in the file path for you or not, but try changing the file path from "/apps/XsTests/cursor.png" to "sd:/apps/XsTests/cursor.png" and report back what happens.

*Offtopic, WTF? your registered date says "Tomorrow"?



Edited 1 time(s). Last edit at 10/27/2009 01:21AM by Matando.
Re: libwiisprite won't load images
October 27, 2009 02:30AM
@Matando
Dead on with what the cause of the problem is
Re: libwiisprite won't load images
October 27, 2009 11:11PM
Sorry Matando, your solution doesn't work.

I have it setup so that if it could not load the image, it turns the background color to red. And the background turned red.

Any other ideas?
Re: libwiisprite won't load images
October 28, 2009 01:26AM
Are you sure that the file is in the right location and the file is a valid png file?

maybe you could share the image loading functions of your code to help diagnose the problem and get it to work.
Re: libwiisprite won't load images
October 28, 2009 01:50AM
I'm sure the file is in the right location. Does the image have to have a certain bit depth?

Here's the code:
// Create the game window and initalise the VIDEO subsystem
GameWindow gwd;
gwd.InitVideo();

gwd.SetBackground((GXColor){ 255, 255, 255, 255 });

Sprite sprite;
Image image;

bool imgloaded = false;

if(image.LoadImage("sd:/apps/XsTests/cursor.png") != IMG_LOAD_ERROR_NONE) { } else { imgloaded = true; }

if (imgloaded == true) {
	gwd.SetBackground((GXColor){ 0, 241, 0, 255 });
} else {
	gwd.SetBackground((GXColor){ 241, 0, 0, 255 });
}
	
sprite.SetImage(&image);
//^ That says  & image
//The code tag made it look funny

I'm going to try and load it from the root of the sd card.

Thanks for your help. :)
Re: libwiisprite won't load images
October 28, 2009 09:32PM
Make sure the dimensions of the image (width, height) are multiples of 4.
Re: libwiisprite won't load images
October 28, 2009 11:09PM
Here, try this(changes are in bold). Oh and sorry, i HAD to fix your spelling error, lol

// Create the game window and initialize the VIDEO subsystem
GameWindow gwd;
gwd.InitVideo();

gwd.SetBackground((GXColor){ 255, 255, 255, 255 });

Sprite sprite;
Image image;

bool imgloaded;

if(image.LoadImage("sd:/apps/XsTests/cursor.png") != IMG_LOAD_ERROR_NONE) { imgloaded = false; } else { imgloaded = true; }

if (imgloaded == true) {
	gwd.SetBackground((GXColor){ 0, 241, 0, 255 });
} else {
	gwd.SetBackground((GXColor){ 241, 0, 0, 255 });
}
	
sprite.SetImage(&image);
//^ That says  & image
//The code tag made it look funny

you should just declare bool at first, instead of defining it at the same time, and make it false if "image.LoadImage" fails.

other than that, it should work(actually it should've worked w/ or w/o those changes), unless of course as Arikado said the image doesn't have dimensions with multiples of 4.
Re: libwiisprite won't load images
October 29, 2009 12:23AM
It works now! :)
Thank you so much Arikado!
And thank you, Matando. :)

Now Ican start on a project. :)
Sorry, only registered users may post in this forum.

Click here to login