wxIMAGE_RESOLUTION_CM = 2
};
+// alpha channel values: fully transparent, default threshold separating
+// transparent pixels from opaque for a few functions dealing with alpha and
+// fully opaque
+const unsigned char wxIMAGE_ALPHA_TRANSPARENT = 0;
+const unsigned char wxIMAGE_ALPHA_THRESHOLD = 0x80;
+const unsigned char wxIMAGE_ALPHA_OPAQUE = 0xff;
+
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
// converts image's alpha channel to mask, if it has any, does nothing
// otherwise:
- bool ConvertAlphaToMask(unsigned char threshold = 128);
+ bool ConvertAlphaToMask(unsigned char threshold = wxIMAGE_ALPHA_THRESHOLD);
// This method converts an image where the original alpha
// information is only available as a shades of a colour
// these functions provide fastest access to wxImage data but should be
// used carefully as no checks are done
unsigned char *GetData() const;
- void SetData( unsigned char *data );
- void SetData( unsigned char *data, int new_width, int new_height );
+ void SetData( unsigned char *data, bool static_data=false );
+ void SetData( unsigned char *data, int new_width, int new_height, bool static_data=false );
unsigned char *GetAlpha() const; // may return NULL!
bool HasAlpha() const { return GetAlpha() != NULL; }
- void SetAlpha(unsigned char *alpha = NULL);
+ void SetAlpha(unsigned char *alpha = NULL, bool static_data=false);
void InitAlpha();
+ // return true if this pixel is masked or has alpha less than specified
+ // threshold
+ bool IsTransparent(int x, int y,
+ unsigned char threshold = wxIMAGE_ALPHA_THRESHOLD) const;
+
// Mask functions
void SetMaskColour( unsigned char r, unsigned char g, unsigned char b );
// Get the current mask colour or find a suitable colour
protected:
static wxList sm_handlers;
+ // return the index of the point with the given coordinates or -1 if the
+ // image is invalid of the coordinates are out of range
+ //
+ // note that index must be multiplied by 3 when using it with RGB array
+ long XYToIndex(int x, int y) const;
+
private:
friend class WXDLLEXPORT wxImageHandler;