Welcome! Log In Create A New Profile

Advanced

Question about libwiisprite transparency

Posted by Arikado 
Re: Question about libwiisprite transparency
August 14, 2008 05:23AM
Nope I can retrieve data from the array, I just can't change it. Chaosteil also has no idea what I'm doing wrong.



Edited 1 time(s). Last edit at 08/14/2008 05:27AM by Arikado.
Re: Question about libwiisprite transparency
August 14, 2008 05:37AM
If you can't change it, then it may be something to do with the image, _pixels is an array, does it contain the information of that image?
Re: Question about libwiisprite transparency
August 14, 2008 05:50AM
Yes, each member contains the RGBA data for each represented pixel. Chaosteil's example:

_pixels[0] contains R data of the first pixel
_pixels[0+1] contains G data of the first pixel
_pixels[0+2] contains B data of the first pixel
_pixels[0+3] contains A data of the first pixel
Re: Question about libwiisprite transparency
August 14, 2008 05:53AM
I think I may have a possible reason, when you load an image into video memory, before accessing it, the program will (but not explicitly) lock that image so that no data can be written to that location otherwise you could possibly get horrible errors and what not. Locking essentially stops anything over writing where that object is located, that may be the reason why you are unable to write to those locations, you simply aren't allowed. But that's only an idea. If it is the reason then it would be something in the source code, so you would have to rebuild the library with something added to unlock that surface while you write to it then lock it straight after.
Re: Question about libwiisprite transparency
August 14, 2008 10:25AM
Strange... but i, i+1 and i+2 don't give any problem...
Re: Question about libwiisprite transparency
August 14, 2008 12:33PM
I know that I got the format right, since my code and the library code itself uses the property with this dataformat. Any attempts to use it as a plain x+y*width array will fail! If you want to do that, I recommend MY class.
Also, don't forget to _Flush the buffer once you are done with it.
Re: Question about libwiisprite transparency
August 14, 2008 04:15PM
@WiiPhlex

You are actually right on with whats going on. Fortunately, there is a function in the Image class that allows you to unlock the image for drawing purposes and access the pixel data. _Initialzed() is it I believe. Since this is private, I call it before going through every pixel for checks and changes in MakeTransparent(). Please refer to my latest "code post".

Unfortunately, _Initialzed() appears to not do anything at all. Whether I use it or not I get a crash.



Edited 1 time(s). Last edit at 08/14/2008 04:17PM by Arikado.
Re: Question about libwiisprite transparency
August 14, 2008 04:47PM
Arikado,
The code you posted crashes on my Wii as well.

To get rid of the crash, remove the declaration of _pixels in your derived class, DrawableImage. You also would need to remove this variable from your constructor initialization list for DrawableImage. Your other private member variables in DrawableImage, are also duplicates of the base class ones, so you might want to remove those as well.

_pixels is a protected member variable of the class Image, so you don't need to do anything other than inherit from the class to gain access to it in your subclass. Your program crashes because the _pixels you're using is never initialized to anything other than NULL.

I hope that fixes things for you.

-Santa
Re: Question about libwiisprite transparency
August 14, 2008 05:34PM
Interesting idea. Thanks
Re: Question about libwiisprite transparency
August 14, 2008 06:01PM
Dudes, just use my already written and working class.
And please, uninstall the compiler if you even concider it that _Initalized will ready the image for editing, it is a getter and tells you if the image is ready for usage. And you should never need to call it.
Re: Question about libwiisprite transparency
August 14, 2008 10:20PM
@SantaCode
You were dead on. Your idea fixed the crash. Now I just have something else to work out quick (specifically setting _pixels[i+3] = 0 doesn't make it transparent so I'm working with GX).

@henke37
I like your class alot but really just wanted the challenge of writing it on my own.
Re: Question about libwiisprite transparency
August 15, 2008 03:51AM
I think this would have been far easier dealing directly with the API and not using Libwiisprite, but who doesn't enjoy a challenge every now and again.
Re: Question about libwiisprite transparency
August 15, 2008 08:53AM
Doesn't make _pixel[i+3] = 0 it transparent... maybe its in ARGB format, instead of RGBA... so try _pixels = 0
Re: Question about libwiisprite transparency
August 15, 2008 09:02AM
Libwiisprite converts when an image is loaded

if(color_type == PNG_COLOR_TYPE_RGBA) // Swap RGBA to ARGB
png_set_swap_alpha(png_ptr);
Re: Question about libwiisprite transparency
August 15, 2008 09:11AM
So _pixel is ARGB?
Re: Question about libwiisprite transparency
August 15, 2008 09:22AM
Re: Question about libwiisprite transparency
August 15, 2008 09:24AM
That's why _pixel[i+3] = 0 doesn't make it transparent :D.
Re: Question about libwiisprite transparency
August 15, 2008 09:25AM
_pixel[0] = a
_pixel[1] = r
_pixel[2] = g
_pixel[3] = b

edit: sorry Arikado I thought you had the source code? I would have posted this sooner if I knew you hadn't.



Edited 1 time(s). Last edit at 08/15/2008 09:34AM by WiiPhlex.
Re: Question about libwiisprite transparency
August 15, 2008 09:39AM
Now Arikade needs to change lots of little A's, R's, G's an B's in his source.
Re: Question about libwiisprite transparency
August 15, 2008 09:45AM
At least he knows, it's much better when you know why something isn't actually working.
Sorry, only registered users may post in this forum.

Click here to login