Added mono bitmap to image conversion.
Added wxImage::Replace() (replaces one colour with another). Toolbar tips no longer eats ana new colour. This might prevent the wrong colour behaviour reported from some 8-bit visuals. Minor fixes and test code. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5122 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -37,48 +37,46 @@ class WXDLLEXPORT wxImage;
|
|||||||
|
|
||||||
class WXDLLEXPORT wxImageHandler: public wxObject
|
class WXDLLEXPORT wxImageHandler: public wxObject
|
||||||
{
|
{
|
||||||
DECLARE_CLASS(wxImageHandler)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxImageHandler() { m_name = ""; m_extension = ""; m_type = 0; }
|
wxImageHandler() { m_name = ""; m_extension = ""; m_type = 0; }
|
||||||
|
|
||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=0 );
|
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=0 );
|
||||||
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
|
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
|
||||||
|
|
||||||
virtual int GetImageCount( wxInputStream& stream );
|
virtual int GetImageCount( wxInputStream& stream );
|
||||||
|
|
||||||
bool CanRead( wxInputStream& stream ) { return DoCanRead(stream); }
|
bool CanRead( wxInputStream& stream ) { return DoCanRead(stream); }
|
||||||
bool CanRead( const wxString& name );
|
bool CanRead( const wxString& name );
|
||||||
#endif // wxUSE_STREAMS
|
#endif // wxUSE_STREAMS
|
||||||
|
|
||||||
void SetName(const wxString& name) { m_name = name; }
|
void SetName(const wxString& name) { m_name = name; }
|
||||||
void SetExtension(const wxString& ext) { m_extension = ext; }
|
void SetExtension(const wxString& ext) { m_extension = ext; }
|
||||||
void SetType(long type) { m_type = type; }
|
void SetType(long type) { m_type = type; }
|
||||||
void SetMimeType(const wxString& type) { m_mime = type; }
|
void SetMimeType(const wxString& type) { m_mime = type; }
|
||||||
wxString GetName() const { return m_name; }
|
wxString GetName() const { return m_name; }
|
||||||
wxString GetExtension() const { return m_extension; }
|
wxString GetExtension() const { return m_extension; }
|
||||||
long GetType() const { return m_type; }
|
long GetType() const { return m_type; }
|
||||||
wxString GetMimeType() const { return m_mime; }
|
wxString GetMimeType() const { return m_mime; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
virtual bool DoCanRead( wxInputStream& stream ) = 0;
|
virtual bool DoCanRead( wxInputStream& stream ) = 0;
|
||||||
#endif // wxUSE_STREAMS
|
#endif // wxUSE_STREAMS
|
||||||
|
|
||||||
wxString m_name;
|
wxString m_name;
|
||||||
wxString m_extension;
|
wxString m_extension;
|
||||||
wxString m_mime;
|
wxString m_mime;
|
||||||
long m_type;
|
long m_type;
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_CLASS(wxImageHandler)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxImage
|
// wxImage
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
// GRG: Dic/99
|
|
||||||
class WXDLLEXPORT wxHNode
|
class WXDLLEXPORT wxHNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -86,113 +84,112 @@ public:
|
|||||||
unsigned long value;
|
unsigned long value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxImage: public wxObject
|
class WXDLLEXPORT wxImage: public wxObject
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxImage)
|
|
||||||
|
|
||||||
friend class WXDLLEXPORT wxImageHandler;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
wxImage();
|
||||||
|
wxImage( int width, int height );
|
||||||
|
wxImage( const wxString& name, long type = wxBITMAP_TYPE_ANY );
|
||||||
|
wxImage( wxInputStream& stream, long type = wxBITMAP_TYPE_ANY );
|
||||||
|
wxImage( const wxString& name, const wxString& mimetype );
|
||||||
|
wxImage( wxInputStream& stream, const wxString& mimetype );
|
||||||
|
|
||||||
wxImage();
|
wxImage( const wxImage& image );
|
||||||
wxImage( int width, int height );
|
wxImage( const wxImage* image );
|
||||||
wxImage( const wxString& name, long type = wxBITMAP_TYPE_ANY );
|
|
||||||
wxImage( wxInputStream& stream, long type = wxBITMAP_TYPE_ANY );
|
|
||||||
wxImage( const wxString& name, const wxString& mimetype );
|
|
||||||
wxImage( wxInputStream& stream, const wxString& mimetype );
|
|
||||||
|
|
||||||
wxImage( const wxImage& image );
|
// these functions get implemented in /src/(platform)/bitmap.cpp
|
||||||
wxImage( const wxImage* image );
|
wxImage( const wxBitmap &bitmap );
|
||||||
|
operator wxBitmap() const { return ConvertToBitmap(); }
|
||||||
|
wxBitmap ConvertToBitmap() const;
|
||||||
|
|
||||||
// these functions get implemented in /src/(platform)/bitmap.cpp
|
void Create( int width, int height );
|
||||||
wxImage( const wxBitmap &bitmap );
|
void Destroy();
|
||||||
operator wxBitmap() const { return ConvertToBitmap(); }
|
|
||||||
wxBitmap ConvertToBitmap() const;
|
|
||||||
|
|
||||||
void Create( int width, int height );
|
// return the new image with size width*height
|
||||||
void Destroy();
|
wxImage GetSubImage( const wxRect& ) const;
|
||||||
|
|
||||||
// return the new image with size width*height
|
// return the new image with size width*height
|
||||||
wxImage GetSubImage( const wxRect& ) const;
|
wxImage Scale( int width, int height ) const;
|
||||||
|
|
||||||
// return the new image with size width*height
|
// rescales the image in place
|
||||||
wxImage Scale( int width, int height ) const;
|
wxImage& Rescale( int width, int height ) { return *this = Scale(width, height); }
|
||||||
|
|
||||||
// rescales the image in place
|
// replace one colour with another
|
||||||
wxImage& Rescale( int width, int height ) { return *this = Scale(width, height); }
|
void Replace( unsigned char r1, unsigned char g1, unsigned char b1,
|
||||||
|
unsigned char r2, unsigned char g2, unsigned char b2 );
|
||||||
|
|
||||||
// these routines are slow but safe
|
// these routines are slow but safe
|
||||||
void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b );
|
void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b );
|
||||||
unsigned char GetRed( int x, int y );
|
unsigned char GetRed( int x, int y );
|
||||||
unsigned char GetGreen( int x, int y );
|
unsigned char GetGreen( int x, int y );
|
||||||
unsigned char GetBlue( int x, int y );
|
unsigned char GetBlue( int x, int y );
|
||||||
|
|
||||||
static bool CanRead( const wxString& name );
|
static bool CanRead( const wxString& name );
|
||||||
virtual bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_ANY );
|
virtual bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_ANY );
|
||||||
virtual bool LoadFile( const wxString& name, const wxString& mimetype );
|
virtual bool LoadFile( const wxString& name, const wxString& mimetype );
|
||||||
|
|
||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
static bool CanRead( wxInputStream& stream );
|
static bool CanRead( wxInputStream& stream );
|
||||||
virtual bool LoadFile( wxInputStream& stream, long type = wxBITMAP_TYPE_ANY );
|
virtual bool LoadFile( wxInputStream& stream, long type = wxBITMAP_TYPE_ANY );
|
||||||
virtual bool LoadFile( wxInputStream& stream, const wxString& mimetype );
|
virtual bool LoadFile( wxInputStream& stream, const wxString& mimetype );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual bool SaveFile( const wxString& name, int type );
|
virtual bool SaveFile( const wxString& name, int type );
|
||||||
virtual bool SaveFile( const wxString& name, const wxString& mimetype );
|
virtual bool SaveFile( const wxString& name, const wxString& mimetype );
|
||||||
|
|
||||||
#if wxUSE_STREAMS
|
#if wxUSE_STREAMS
|
||||||
virtual bool SaveFile( wxOutputStream& stream, int type );
|
virtual bool SaveFile( wxOutputStream& stream, int type );
|
||||||
virtual bool SaveFile( wxOutputStream& stream, const wxString& mimetype );
|
virtual bool SaveFile( wxOutputStream& stream, const wxString& mimetype );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool Ok() const;
|
bool Ok() const;
|
||||||
int GetWidth() const;
|
int GetWidth() const;
|
||||||
int GetHeight() const;
|
int GetHeight() const;
|
||||||
|
|
||||||
char unsigned *GetData() const;
|
char unsigned *GetData() const;
|
||||||
void SetData( char unsigned *data );
|
void SetData( char unsigned *data );
|
||||||
|
|
||||||
void SetMaskColour( unsigned char r, unsigned char g, unsigned char b );
|
void SetMaskColour( unsigned char r, unsigned char g, unsigned char b );
|
||||||
unsigned char GetMaskRed() const;
|
unsigned char GetMaskRed() const;
|
||||||
unsigned char GetMaskGreen() const;
|
unsigned char GetMaskGreen() const;
|
||||||
unsigned char GetMaskBlue() const;
|
unsigned char GetMaskBlue() const;
|
||||||
void SetMask( bool mask = TRUE );
|
void SetMask( bool mask = TRUE );
|
||||||
bool HasMask() const;
|
bool HasMask() const;
|
||||||
|
|
||||||
wxImage& operator = (const wxImage& image)
|
unsigned long CountColours( unsigned long stopafter = (unsigned long) -1 );
|
||||||
{
|
unsigned long ComputeHistogram( wxHashTable &h );
|
||||||
if ( (*this) != image )
|
|
||||||
Ref(image);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator == (const wxImage& image)
|
wxImage& operator = (const wxImage& image)
|
||||||
{ return m_refData == image.m_refData; }
|
{
|
||||||
bool operator != (const wxImage& image)
|
if ( (*this) != image )
|
||||||
{ return m_refData != image.m_refData; }
|
Ref(image);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
static wxList& GetHandlers() { return sm_handlers; }
|
bool operator == (const wxImage& image)
|
||||||
static void AddHandler( wxImageHandler *handler );
|
{ return m_refData == image.m_refData; }
|
||||||
static void InsertHandler( wxImageHandler *handler );
|
bool operator != (const wxImage& image)
|
||||||
static bool RemoveHandler( const wxString& name );
|
{ return m_refData != image.m_refData; }
|
||||||
static wxImageHandler *FindHandler( const wxString& name );
|
|
||||||
static wxImageHandler *FindHandler( const wxString& extension, long imageType );
|
|
||||||
static wxImageHandler *FindHandler( long imageType );
|
|
||||||
static wxImageHandler *FindHandlerMime( const wxString& mimetype );
|
|
||||||
|
|
||||||
static void CleanUpHandlers();
|
static wxList& GetHandlers() { return sm_handlers; }
|
||||||
static void InitStandardHandlers();
|
static void AddHandler( wxImageHandler *handler );
|
||||||
|
static void InsertHandler( wxImageHandler *handler );
|
||||||
// GRG: Dic/99
|
static bool RemoveHandler( const wxString& name );
|
||||||
unsigned long CountColours( unsigned long stopafter = (unsigned long) -1 );
|
static wxImageHandler *FindHandler( const wxString& name );
|
||||||
unsigned long ComputeHistogram( wxHashTable &h );
|
static wxImageHandler *FindHandler( const wxString& extension, long imageType );
|
||||||
|
static wxImageHandler *FindHandler( long imageType );
|
||||||
|
static wxImageHandler *FindHandlerMime( const wxString& mimetype );
|
||||||
|
|
||||||
|
static void CleanUpHandlers();
|
||||||
|
static void InitStandardHandlers();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
static wxList sm_handlers;
|
||||||
|
|
||||||
static wxList sm_handlers;
|
private:
|
||||||
|
friend class WXDLLEXPORT wxImageHandler;
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxImage)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -201,55 +201,69 @@ MyCanvas::~MyCanvas()
|
|||||||
|
|
||||||
void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
wxPaintDC dc( this );
|
wxPaintDC dc( this );
|
||||||
PrepareDC( dc );
|
PrepareDC( dc );
|
||||||
|
|
||||||
dc.DrawText( "Loaded image", 30, 10 );
|
dc.DrawText( "Loaded image", 30, 10 );
|
||||||
if (my_square && my_square->Ok()) dc.DrawBitmap( *my_square, 30, 30 );
|
if (my_square && my_square->Ok()) dc.DrawBitmap( *my_square, 30, 30 );
|
||||||
|
|
||||||
dc.DrawText( "Drawn directly", 150, 10 );
|
dc.DrawText( "Drawn directly", 150, 10 );
|
||||||
dc.SetBrush( wxBrush( "orange", wxSOLID ) );
|
dc.SetBrush( wxBrush( "orange", wxSOLID ) );
|
||||||
dc.SetPen( *wxWHITE_PEN );
|
dc.SetPen( *wxWHITE_PEN );
|
||||||
dc.DrawRectangle( 150, 30, 100, 100 );
|
dc.DrawRectangle( 150, 30, 100, 100 );
|
||||||
|
|
||||||
if (my_anti && my_anti->Ok()) dc.DrawBitmap( *my_anti, 280, 30 );
|
if (my_anti && my_anti->Ok())
|
||||||
|
dc.DrawBitmap( *my_anti, 280, 30 );
|
||||||
|
|
||||||
dc.DrawText( "PNG handler", 30, 135 );
|
dc.DrawText( "PNG handler", 30, 135 );
|
||||||
if (my_horse_png && my_horse_png->Ok())
|
if (my_horse_png && my_horse_png->Ok())
|
||||||
{
|
{
|
||||||
dc.DrawBitmap( *my_horse_png, 30, 150 );
|
dc.DrawBitmap( *my_horse_png, 30, 150 );
|
||||||
wxRect rect(0,0,100,100);
|
wxRect rect(0,0,100,100);
|
||||||
wxBitmap sub( my_horse_png->GetSubBitmap(rect) );
|
wxBitmap sub( my_horse_png->GetSubBitmap(rect) );
|
||||||
dc.DrawText( "GetSubBitmap()", 280, 190 );
|
dc.DrawText( "GetSubBitmap()", 280, 190 );
|
||||||
dc.DrawBitmap( sub, 280, 210 );
|
dc.DrawBitmap( sub, 280, 210 );
|
||||||
}
|
}
|
||||||
|
|
||||||
dc.DrawText( "JPEG handler", 30, 365 );
|
dc.DrawText( "JPEG handler", 30, 365 );
|
||||||
if (my_horse_jpeg && my_horse_jpeg->Ok()) dc.DrawBitmap( *my_horse_jpeg, 30, 380 );
|
if (my_horse_jpeg && my_horse_jpeg->Ok())
|
||||||
|
dc.DrawBitmap( *my_horse_jpeg, 30, 380 );
|
||||||
|
|
||||||
dc.DrawText( "GIF handler", 30, 595 );
|
dc.DrawText( "GIF handler", 30, 595 );
|
||||||
if (my_horse_gif && my_horse_gif->Ok()) dc.DrawBitmap( *my_horse_gif, 30, 610 );
|
if (my_horse_gif && my_horse_gif->Ok())
|
||||||
|
dc.DrawBitmap( *my_horse_gif, 30, 610 );
|
||||||
|
|
||||||
dc.DrawText( "PCX handler", 30, 825 );
|
dc.DrawText( "PCX handler", 30, 825 );
|
||||||
if (my_horse_pcx && my_horse_pcx->Ok()) dc.DrawBitmap( *my_horse_pcx, 30, 840 );
|
if (my_horse_pcx && my_horse_pcx->Ok())
|
||||||
|
dc.DrawBitmap( *my_horse_pcx, 30, 840 );
|
||||||
|
|
||||||
dc.DrawText( "BMP handler", 30, 1055 );
|
dc.DrawText( "BMP handler", 30, 1055 );
|
||||||
if (my_horse_bmp && my_horse_bmp->Ok()) dc.DrawBitmap( *my_horse_bmp, 30, 1070 );
|
if (my_horse_bmp && my_horse_bmp->Ok())
|
||||||
|
dc.DrawBitmap( *my_horse_bmp, 30, 1070 );
|
||||||
|
|
||||||
dc.DrawText( "PNM handler", 30, 1285 );
|
dc.DrawText( "PNM handler", 30, 1285 );
|
||||||
if (my_horse_pnm && my_horse_pnm->Ok()) dc.DrawBitmap( *my_horse_pnm, 30, 1300 );
|
if (my_horse_pnm && my_horse_pnm->Ok())
|
||||||
|
dc.DrawBitmap( *my_horse_pnm, 30, 1300 );
|
||||||
|
|
||||||
dc.DrawText( "TIFF handler", 30, 1515 );
|
dc.DrawText( "TIFF handler", 30, 1515 );
|
||||||
if (my_horse_tiff && my_horse_tiff->Ok()) dc.DrawBitmap( *my_horse_pnm, 30, 1530 );
|
if (my_horse_tiff && my_horse_tiff->Ok())
|
||||||
|
dc.DrawBitmap( *my_horse_pnm, 30, 1530 );
|
||||||
|
|
||||||
dc.DrawText( "XBM bitmap", 30, 1745 );
|
if (my_smile_xbm && my_smile_xbm->Ok())
|
||||||
dc.SetPen( *wxRED_PEN );
|
{
|
||||||
if (my_smile_xbm && my_smile_xbm->Ok()) {
|
dc.DrawText( "XBM bitmap", 30, 1745 );
|
||||||
dc.DrawBitmap( *my_smile_xbm, 30, 1760 );
|
dc.SetPen( *wxRED_PEN );
|
||||||
dc.DrawText( "..after wxImage conversion", 150, 1745 );
|
dc.DrawBitmap( *my_smile_xbm, 30, 1760 );
|
||||||
wxImage i( *my_smile_xbm );
|
|
||||||
dc.DrawBitmap( i.ConvertToBitmap(), 150, 1760 );
|
dc.DrawText( "After wxImage conversion", 150, 1745 );
|
||||||
}
|
wxImage i( *my_smile_xbm );
|
||||||
|
i.SetMaskColour( 0,0,0 );
|
||||||
|
i.Replace( 255,255,255,
|
||||||
|
wxRED_PEN->GetColour().Red(),
|
||||||
|
wxRED_PEN->GetColour().Green(),
|
||||||
|
wxRED_PEN->GetColour().Blue() );
|
||||||
|
dc.DrawBitmap( i.ConvertToBitmap(), 150, 1760, TRUE );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyCanvas::CreateAntiAliasedBitmap()
|
void MyCanvas::CreateAntiAliasedBitmap()
|
||||||
|
@@ -224,6 +224,29 @@ wxImage wxImage::GetSubImage( const wxRect &rect ) const
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxImage::Replace( unsigned char r1, unsigned char g1, unsigned char b1,
|
||||||
|
unsigned char r2, unsigned char g2, unsigned char b2 )
|
||||||
|
{
|
||||||
|
wxCHECK_RET( Ok(), wxT("invalid image") );
|
||||||
|
|
||||||
|
char unsigned *data = GetData();
|
||||||
|
|
||||||
|
const int w = GetWidth();
|
||||||
|
const int h = GetHeight();
|
||||||
|
|
||||||
|
for (int j = 0; j < h; j++)
|
||||||
|
for (int i = 0; i < w; i++)
|
||||||
|
{
|
||||||
|
if ((data[0] == r1) && (data[1] == g1) && (data[2] == b1))
|
||||||
|
{
|
||||||
|
data[0] = r2;
|
||||||
|
data[1] = g2;
|
||||||
|
data[2] = b2;
|
||||||
|
}
|
||||||
|
data += 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxImage::SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b )
|
void wxImage::SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), wxT("invalid image") );
|
wxCHECK_RET( Ok(), wxT("invalid image") );
|
||||||
@@ -1541,15 +1564,19 @@ wxImage::wxImage( const wxBitmap &bitmap )
|
|||||||
SetMaskColour( 16, 16, 16 ); // anything unlikely and dividable
|
SetMaskColour( 16, 16, 16 ); // anything unlikely and dividable
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkVisual *visual = (GdkVisual*) NULL;
|
int bpp = -1;
|
||||||
if (bitmap.GetPixmap())
|
if (bitmap.GetPixmap())
|
||||||
visual = gdk_window_get_visual( bitmap.GetPixmap() );
|
{
|
||||||
else
|
GdkVisual *visual = gdk_window_get_visual( bitmap.GetPixmap() );
|
||||||
visual = gdk_window_get_visual( bitmap.GetBitmap() );
|
|
||||||
|
|
||||||
if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
|
if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
|
||||||
int bpp = visual->depth;
|
bpp = visual->depth;
|
||||||
if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
|
if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
|
||||||
|
}
|
||||||
|
if (bitmap.GetBitmap())
|
||||||
|
{
|
||||||
|
bpp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
GdkColormap *cmap = gtk_widget_get_default_colormap();
|
GdkColormap *cmap = gtk_widget_get_default_colormap();
|
||||||
|
|
||||||
@@ -1559,7 +1586,21 @@ wxImage::wxImage( const wxBitmap &bitmap )
|
|||||||
for (int i = 0; i < bitmap.GetWidth(); i++)
|
for (int i = 0; i < bitmap.GetWidth(); i++)
|
||||||
{
|
{
|
||||||
wxInt32 pixel = gdk_image_get_pixel( gdk_image, i, j );
|
wxInt32 pixel = gdk_image_get_pixel( gdk_image, i, j );
|
||||||
if (bpp <= 8)
|
if (bpp == 1)
|
||||||
|
{
|
||||||
|
if (pixel == 0)
|
||||||
|
{
|
||||||
|
data[pos] = 0;
|
||||||
|
data[pos+1] = 0;
|
||||||
|
data[pos+2] = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data[pos] = 255;
|
||||||
|
data[pos+1] = 255;
|
||||||
|
data[pos+2] = 255;
|
||||||
|
}
|
||||||
|
} else if (bpp <= 8)
|
||||||
{
|
{
|
||||||
data[pos] = cmap->colors[pixel].red >> 8;
|
data[pos] = cmap->colors[pixel].red >> 8;
|
||||||
data[pos+1] = cmap->colors[pixel].green >> 8;
|
data[pos+1] = cmap->colors[pixel].green >> 8;
|
||||||
|
@@ -272,24 +272,26 @@ bool wxToolBar::Create( wxWindow *parent,
|
|||||||
|
|
||||||
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
|
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
|
||||||
|
|
||||||
#if (GTK_MINOR_VERSION > 0)
|
|
||||||
if (style & wxTB_FLAT)
|
if (style & wxTB_FLAT)
|
||||||
gtk_toolbar_set_button_relief( GTK_TOOLBAR(m_toolbar), GTK_RELIEF_NONE );
|
gtk_toolbar_set_button_relief( GTK_TOOLBAR(m_toolbar), GTK_RELIEF_NONE );
|
||||||
#endif
|
|
||||||
|
|
||||||
m_fg = new GdkColor;
|
m_fg = new GdkColor;
|
||||||
m_fg->red = 0;
|
m_fg->red = 0;
|
||||||
m_fg->green = 0;
|
m_fg->green = 0;
|
||||||
m_fg->blue = 0;
|
m_fg->blue = 0;
|
||||||
gdk_color_alloc( gtk_widget_get_colormap( GTK_WIDGET(m_toolbar) ), m_fg );
|
wxColour fg(0,0,0);
|
||||||
|
fg.CalcPixel( gtk_widget_get_colormap( GTK_WIDGET(m_toolbar) ) );
|
||||||
|
m_fg->pixel = fg.GetPixel();
|
||||||
|
|
||||||
m_bg = new GdkColor;
|
m_bg = new GdkColor;
|
||||||
m_bg->red = 65535;
|
m_bg->red = 65535;
|
||||||
m_bg->green = 65535;
|
m_bg->green = 65535;
|
||||||
m_bg->blue = 50000;
|
m_bg->blue = 49980;
|
||||||
gdk_color_alloc( gtk_widget_get_colormap( GTK_WIDGET(m_toolbar) ), m_bg );
|
wxColour bg(255,255,196);
|
||||||
|
bg.CalcPixel( gtk_widget_get_colormap( GTK_WIDGET(m_toolbar) ) );
|
||||||
#if (GTK_MINOR_VERSION > 0)
|
m_bg->pixel = bg.GetPixel();
|
||||||
|
|
||||||
gtk_tooltips_force_window( GTK_TOOLBAR(m_toolbar)->tooltips );
|
gtk_tooltips_force_window( GTK_TOOLBAR(m_toolbar)->tooltips );
|
||||||
|
|
||||||
GtkStyle *g_style =
|
GtkStyle *g_style =
|
||||||
@@ -299,9 +301,7 @@ bool wxToolBar::Create( wxWindow *parent,
|
|||||||
|
|
||||||
g_style->bg[GTK_STATE_NORMAL] = *m_bg;
|
g_style->bg[GTK_STATE_NORMAL] = *m_bg;
|
||||||
gtk_widget_set_style( GTK_TOOLBAR(m_toolbar)->tooltips->tip_window, g_style );
|
gtk_widget_set_style( GTK_TOOLBAR(m_toolbar)->tooltips->tip_window, g_style );
|
||||||
#else
|
|
||||||
gtk_tooltips_set_colors( GTK_TOOLBAR(m_toolbar)->tooltips, m_bg, m_fg );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_parent->DoAddChild( this );
|
m_parent->DoAddChild( this );
|
||||||
|
|
||||||
|
@@ -272,24 +272,26 @@ bool wxToolBar::Create( wxWindow *parent,
|
|||||||
|
|
||||||
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
|
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
|
||||||
|
|
||||||
#if (GTK_MINOR_VERSION > 0)
|
|
||||||
if (style & wxTB_FLAT)
|
if (style & wxTB_FLAT)
|
||||||
gtk_toolbar_set_button_relief( GTK_TOOLBAR(m_toolbar), GTK_RELIEF_NONE );
|
gtk_toolbar_set_button_relief( GTK_TOOLBAR(m_toolbar), GTK_RELIEF_NONE );
|
||||||
#endif
|
|
||||||
|
|
||||||
m_fg = new GdkColor;
|
m_fg = new GdkColor;
|
||||||
m_fg->red = 0;
|
m_fg->red = 0;
|
||||||
m_fg->green = 0;
|
m_fg->green = 0;
|
||||||
m_fg->blue = 0;
|
m_fg->blue = 0;
|
||||||
gdk_color_alloc( gtk_widget_get_colormap( GTK_WIDGET(m_toolbar) ), m_fg );
|
wxColour fg(0,0,0);
|
||||||
|
fg.CalcPixel( gtk_widget_get_colormap( GTK_WIDGET(m_toolbar) ) );
|
||||||
|
m_fg->pixel = fg.GetPixel();
|
||||||
|
|
||||||
m_bg = new GdkColor;
|
m_bg = new GdkColor;
|
||||||
m_bg->red = 65535;
|
m_bg->red = 65535;
|
||||||
m_bg->green = 65535;
|
m_bg->green = 65535;
|
||||||
m_bg->blue = 50000;
|
m_bg->blue = 49980;
|
||||||
gdk_color_alloc( gtk_widget_get_colormap( GTK_WIDGET(m_toolbar) ), m_bg );
|
wxColour bg(255,255,196);
|
||||||
|
bg.CalcPixel( gtk_widget_get_colormap( GTK_WIDGET(m_toolbar) ) );
|
||||||
#if (GTK_MINOR_VERSION > 0)
|
m_bg->pixel = bg.GetPixel();
|
||||||
|
|
||||||
gtk_tooltips_force_window( GTK_TOOLBAR(m_toolbar)->tooltips );
|
gtk_tooltips_force_window( GTK_TOOLBAR(m_toolbar)->tooltips );
|
||||||
|
|
||||||
GtkStyle *g_style =
|
GtkStyle *g_style =
|
||||||
@@ -299,9 +301,7 @@ bool wxToolBar::Create( wxWindow *parent,
|
|||||||
|
|
||||||
g_style->bg[GTK_STATE_NORMAL] = *m_bg;
|
g_style->bg[GTK_STATE_NORMAL] = *m_bg;
|
||||||
gtk_widget_set_style( GTK_TOOLBAR(m_toolbar)->tooltips->tip_window, g_style );
|
gtk_widget_set_style( GTK_TOOLBAR(m_toolbar)->tooltips->tip_window, g_style );
|
||||||
#else
|
|
||||||
gtk_tooltips_set_colors( GTK_TOOLBAR(m_toolbar)->tooltips, m_bg, m_fg );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_parent->DoAddChild( this );
|
m_parent->DoAddChild( this );
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# Note that this is NOT a relocatable package
|
# Note that this is NOT a relocatable package
|
||||||
%define pref /usr
|
%define pref /usr
|
||||||
%define ver 2.1.11
|
%define ver 2.1.12
|
||||||
%define rel 0
|
%define rel 0
|
||||||
|
|
||||||
Summary: The GTK+ 1.2 port of the wxWindows library
|
Summary: The GTK+ 1.2 port of the wxWindows library
|
||||||
@@ -9,7 +9,7 @@ Version: %{ver}
|
|||||||
Release: %{rel}
|
Release: %{rel}
|
||||||
Copyright: wxWindows Licence
|
Copyright: wxWindows Licence
|
||||||
Group: X11/Libraries
|
Group: X11/Libraries
|
||||||
Source: ftp://wesley.informatik.uni-freiburg.de/pub/linux/wxxt/source/wxGTK-2.1.11.tgz
|
Source: ftp://wesley.informatik.uni-freiburg.de/pub/linux/wxxt/source/wxGTK-2.1.12.tgz
|
||||||
URL: http://wesley.informatik.uni-freiburg.de/~wxxt/docs.html
|
URL: http://wesley.informatik.uni-freiburg.de/~wxxt/docs.html
|
||||||
Packager: Robert Roebling <roebling@ruf.uni-freiburg.de>
|
Packager: Robert Roebling <roebling@ruf.uni-freiburg.de>
|
||||||
BuildRoot: /tmp/wxgtk_root
|
BuildRoot: /tmp/wxgtk_root
|
||||||
|
Reference in New Issue
Block a user