Re: Question about libwiisprite transparency August 04, 2008 06:52AM | Registered: 15 years ago Posts: 211 |
Re: Question about libwiisprite transparency August 04, 2008 10:19PM | Admin Registered: 15 years ago Posts: 5,132 |
Quote
chaosteils letter
If you look closely at the image.h header file, _pixels, _CreateImage etc. are protected. That means you would have to create a class called "DrawableImage : public Image" and then you could access all these protected members and actually alter image data. (pixels are RGBA tiled, just for your information)
However, if you just want to implement some clipping, please look more closely at the LayerManagers ViewWindow functions, that may also help you.
Re: Question about libwiisprite transparency August 05, 2008 03:07AM | Registered: 15 years ago Posts: 211 |
Re: Question about libwiisprite transparency August 05, 2008 04:51AM | Admin Registered: 15 years ago Posts: 5,132 |
Re: Question about libwiisprite transparency August 05, 2008 05:10AM | Registered: 15 years ago Posts: 211 |
Re: Question about libwiisprite transparency August 05, 2008 07:06PM | Admin Registered: 15 years ago Posts: 5,132 |
Re: Question about libwiisprite transparency August 06, 2008 10:11PM | Admin Registered: 15 years ago Posts: 5,132 |
#ifndef LIBWIISPRITE_DRAWABLEIMAGE #define LIBWIISPRITE_DRAWABLEIMAGE #includenamespace wsp{ //The namespace used in libwiisprite class DrawableImage : public Image{ public: DrawableImage(); //Constructor virtual ~DrawableImage(); //Destructor int GetRed(int x, int y);//Retrieve the red value of a designated pixel on the DrawableImage int GetGreen(int x, int y);//Retrieve the blue value of a designated pixel on the DrawableImage int GetBlue(int x, int y);//Retrieve the green value of a designated pixel on the DrawableImage u8 GetAlpha(int x, int y);//Retrieve the alpha value of a designated pixel on the DrawableImage void SetRed(int x, int y, int r);//Sets the red value of a designated pixel on the DrawableImage void SetGreen(int x, int y, int g);//Sets the blue value of a designated pixel on the DrawableImage void SetBlue(int x, int y, int b);//Sets the green value of a designated pixel on the DrawableImage void SetAlpha(int x, int y, u8 a);//Sets the alpha value of a designated pixel on the DrawableImage bool CheckPixel(int x, int y, int r, int g, int b, u8 a);/*Compares the designated pixel on the DrawableImage with the values given to call the function*/ void SetPixel(int x, int y, int r, int g, int b, u8 a);//Sets the color values of the designated pixel on the DrawableImage void MakeTransparent(int r, int g, int b, u8 a);//Makes all pixels that match those values in the DrawableImage transparent private: u8* _pixels; u32 _width, _height; bool _initialized; GXTexObj _texObj; }; }; #endif
Re: Question about libwiisprite transparency August 07, 2008 02:15AM | Registered: 15 years ago Posts: 211 |
Re: Question about libwiisprite transparency August 07, 2008 02:22AM | Admin Registered: 15 years ago Posts: 5,132 |
include#include "drawableimage.h" #include #include #include namespace wsp{ //Libwiisprite namespace DrawableImage::DrawableImage() : _pixels(NULL), _width(0), _height(0), _initialized(false){ } DrawableImage::~DrawableImage(){ DestroyImage(); } int DrawableImage::GetRed(int x, int y){ int Red; //Red = _pixels(x, y, Red Value); return Red; } int DrawableImage::GetGreen(int x, int y){ int Green; //Green = _pixels(x, y, Green value); return Green; } int DrawableImage::GetBlue(int x, int y){ int Blue; //int Blue = _pixels(x, y, Blue value); return Blue; } u8 DrawableImage::GetAlpha(int x, int y){ u8 Alpha; //u8 Alpha = _pixels(x, y, Alpha value); return Alpha; } void DrawableImage::SetRed(int x, int y, int r){ /*_pixels(x, y, Red value) = _pixels(x, y, r);*/ } void DrawableImage::SetGreen(int x, int y, int g){ //_pixels(x, y, Green value) = _pixels(x, y, g); } void DrawableImage::SetBlue(int x, int y, int b){ //_pixels(x, y, Blue value) = _pixels(x, y, b); } void DrawableImage::SetAlpha(int x, int y, u8 a){ //_pixels(x, y, Alpha value) = _pixels(x, y, a); } bool DrawableImage::CheckPixel(int x, int y, int r, int g, int b, u8 a){ if(GetRed(x, y) == r && GetGreen(x, y) == g && GetBlue(x, y) == b && GetAlpha(x, y) == a) return true; else return false; } void DrawableImage::SetPixel(int x, int y, int r, int g, int b, u8 a){ SetRed(x, y, r); SetGreen(x, y, g); SetBlue(x, y, b); SetAlpha(x, y, a); } void DrawableImage::MakeTransparent(int r, int g, int b, u8 a){ int height = GetHeight(); int width = GetWidth(); for(int y = 0; y < Height; y++){ for(int x = 0; x < width; x++){ if(CheckPixel(x, y, r, g, b, a)) SetPixel(x, y, r, g, b, 0); } } } }
Re: Question about libwiisprite transparency August 07, 2008 03:06AM | Registered: 15 years ago Posts: 211 |
Re: Question about libwiisprite transparency August 07, 2008 08:38AM | Registered: 15 years ago Posts: 109 |
Re: Question about libwiisprite transparency August 07, 2008 08:41AM | Registered: 15 years ago Posts: 211 |
Re: Question about libwiisprite transparency August 07, 2008 08:48AM | Registered: 15 years ago Posts: 109 |
Re: Question about libwiisprite transparency August 07, 2008 08:49AM | Registered: 15 years ago Posts: 211 |
Re: Question about libwiisprite transparency August 07, 2008 08:52AM | Registered: 15 years ago Posts: 109 |
Re: Question about libwiisprite transparency August 07, 2008 03:17PM | Admin Registered: 15 years ago Posts: 5,132 |
Re: Question about libwiisprite transparency August 08, 2008 03:02AM | Registered: 15 years ago Posts: 7 |
Re: Question about libwiisprite transparency August 08, 2008 10:01AM | Registered: 15 years ago Posts: 109 |
Re: Question about libwiisprite transparency August 08, 2008 04:36PM | Admin Registered: 15 years ago Posts: 5,132 |
Quote
chaosteil
Why, that's easy. I already told you that _pixels is an array of colors, so to access for example the first pixel, the values would be these:
R: _pixels[0], G: _pixels[1], B: _pixels[2], A: _pixels[3]
To convert a (x;y) to an image location, use this: loc = (y*imagewidth)+x, so to get RGBA values, it would be this: _pixels[loc], _pixels[loc+1], _pixels[loc+2], _pixels[loc+3]
I hope that helped ;)
Re: Question about libwiisprite transparency August 08, 2008 06:47PM | Registered: 15 years ago Posts: 109 |