Added raw bitmap access support to GTK 2.0.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31996 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -43,6 +43,13 @@ All:
|
|||||||
the client size and total size of the window. Code that sets the
|
the client size and total size of the window. Code that sets the
|
||||||
client size using the best size, or that added extra space to sizers
|
client size using the best size, or that added extra space to sizers
|
||||||
to compensate for this bug may need to be changed.
|
to compensate for this bug may need to be changed.
|
||||||
|
- Changed calculation of scrolling area to not clip away some bits
|
||||||
|
due to a rounding error.
|
||||||
|
- Changed GetVirtualSize() to return client size by default until
|
||||||
|
SetVirtualSize() gets called. From then on it will only return
|
||||||
|
that.
|
||||||
|
- Various changes to how wxListCtrl and wxTreeCtrl react to right
|
||||||
|
mouse clicks and left mouse click for starting a drag operation.
|
||||||
|
|
||||||
|
|
||||||
All (GUI):
|
All (GUI):
|
||||||
@@ -83,6 +90,9 @@ wxGTK:
|
|||||||
are only called with GTK+ 2.4.x installed and should yield linker
|
are only called with GTK+ 2.4.x installed and should yield linker
|
||||||
errors otherwise.
|
errors otherwise.
|
||||||
- wxTextCtrl text insertion efficiency fixed. (Mart Raudsepp)
|
- wxTextCtrl text insertion efficiency fixed. (Mart Raudsepp)
|
||||||
|
- Added wxRawBitmap support
|
||||||
|
- Corrected Input method handler code (for Chinese etc.) and its
|
||||||
|
interaction with wxWidgets' events.
|
||||||
|
|
||||||
wxMac:
|
wxMac:
|
||||||
|
|
||||||
@@ -101,6 +111,7 @@ wxMSW:
|
|||||||
wxWinCE:
|
wxWinCE:
|
||||||
- Added support for MS Handheld PC 2000. This was done before 2.5.4,
|
- Added support for MS Handheld PC 2000. This was done before 2.5.4,
|
||||||
but not mentioned anywhere.
|
but not mentioned anywhere.
|
||||||
|
- Added (preliminary) support for sockets
|
||||||
|
|
||||||
wxUniv:
|
wxUniv:
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#include "wx/string.h"
|
#include "wx/string.h"
|
||||||
#include "wx/palette.h"
|
#include "wx/palette.h"
|
||||||
#include "wx/gdiobj.h"
|
#include "wx/gdiobj.h"
|
||||||
|
#include "wx/rawbmp.h"
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
typedef struct _GdkPixbuf GdkPixbuf;
|
typedef struct _GdkPixbuf GdkPixbuf;
|
||||||
@@ -130,6 +131,11 @@ public:
|
|||||||
|
|
||||||
// Basically, this corresponds to Win32 StretchBlt()
|
// Basically, this corresponds to Win32 StretchBlt()
|
||||||
wxBitmap Rescale( int clipx, int clipy, int clipwidth, int clipheight, int width, int height );
|
wxBitmap Rescale( int clipx, int clipy, int clipwidth, int clipheight, int width, int height );
|
||||||
|
|
||||||
|
// raw bitmap access support functions
|
||||||
|
void *GetRawData(wxPixelDataBase& data, int bpp);
|
||||||
|
void UngetRawData(wxPixelDataBase& data);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool CreateFromXpm(const char **bits);
|
bool CreateFromXpm(const char **bits);
|
||||||
bool CreateFromImage(const wxImage& image, int depth);
|
bool CreateFromImage(const wxImage& image, int depth);
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#include "wx/string.h"
|
#include "wx/string.h"
|
||||||
#include "wx/palette.h"
|
#include "wx/palette.h"
|
||||||
#include "wx/gdiobj.h"
|
#include "wx/gdiobj.h"
|
||||||
|
#include "wx/rawbmp.h"
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
typedef struct _GdkPixbuf GdkPixbuf;
|
typedef struct _GdkPixbuf GdkPixbuf;
|
||||||
@@ -130,6 +131,11 @@ public:
|
|||||||
|
|
||||||
// Basically, this corresponds to Win32 StretchBlt()
|
// Basically, this corresponds to Win32 StretchBlt()
|
||||||
wxBitmap Rescale( int clipx, int clipy, int clipwidth, int clipheight, int width, int height );
|
wxBitmap Rescale( int clipx, int clipy, int clipwidth, int clipheight, int width, int height );
|
||||||
|
|
||||||
|
// raw bitmap access support functions
|
||||||
|
void *GetRawData(wxPixelDataBase& data, int bpp);
|
||||||
|
void UngetRawData(wxPixelDataBase& data);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool CreateFromXpm(const char **bits);
|
bool CreateFromXpm(const char **bits);
|
||||||
bool CreateFromImage(const wxImage& image, int depth);
|
bool CreateFromImage(const wxImage& image, int depth);
|
||||||
|
@@ -160,6 +160,11 @@ typedef wxPixelFormat<unsigned char, 24, 0, 1, 2> wxImagePixelFormat;
|
|||||||
// Cocoa is standard RGB or RGBA (normally it is RGBA)
|
// Cocoa is standard RGB or RGBA (normally it is RGBA)
|
||||||
typedef wxPixelFormat<unsigned char, 24, 0, 1, 2> wxNativePixelFormat;
|
typedef wxPixelFormat<unsigned char, 24, 0, 1, 2> wxNativePixelFormat;
|
||||||
|
|
||||||
|
#define wxPIXEL_FORMAT_ALPHA 3
|
||||||
|
#elif defined(__WXGTK__)
|
||||||
|
// Under GTK+ 2.X we use GdkPixbuf, which should be RGBA
|
||||||
|
typedef wxPixelFormat<unsigned char, 24, 0, 1, 2> wxNativePixelFormat;
|
||||||
|
|
||||||
#define wxPIXEL_FORMAT_ALPHA 3
|
#define wxPIXEL_FORMAT_ALPHA 3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -32,12 +32,17 @@
|
|||||||
#include "smile.xbm"
|
#include "smile.xbm"
|
||||||
#include "smile.xpm"
|
#include "smile.xpm"
|
||||||
|
|
||||||
#if defined(__WXMSW__) || defined(__WXMAC__)
|
#if defined(__WXMSW__)
|
||||||
#ifdef wxHAVE_RAW_BITMAP
|
#ifdef wxHAVE_RAW_BITMAP
|
||||||
#include "wx/rawbmp.h"
|
#include "wx/rawbmp.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__WXMAC__) || defined(__WXGTK__)
|
||||||
|
#define wxHAVE_RAW_BITMAP
|
||||||
|
#include "wx/rawbmp.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// derived classes
|
// derived classes
|
||||||
|
|
||||||
class MyFrame;
|
class MyFrame;
|
||||||
@@ -271,7 +276,7 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.UseAlpha();
|
// data.UseAlpha();
|
||||||
|
|
||||||
Data::Iterator p(data);
|
Data::Iterator p(data);
|
||||||
|
|
||||||
|
@@ -306,7 +306,7 @@ bool wxBitmap::Create( int width, int height, int depth )
|
|||||||
if (depth == -1)
|
if (depth == -1)
|
||||||
depth = visual->depth;
|
depth = visual->depth;
|
||||||
|
|
||||||
wxCHECK_MSG( (depth == visual->depth) || (depth == 1), FALSE,
|
wxCHECK_MSG( (depth == visual->depth) || (depth == 1) || (depth == 32), FALSE,
|
||||||
wxT("invalid bitmap depth") )
|
wxT("invalid bitmap depth") )
|
||||||
|
|
||||||
m_refData = new wxBitmapRefData();
|
m_refData = new wxBitmapRefData();
|
||||||
@@ -318,6 +318,14 @@ bool wxBitmap::Create( int width, int height, int depth )
|
|||||||
M_BMPDATA->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 );
|
M_BMPDATA->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 );
|
||||||
M_BMPDATA->m_bpp = 1;
|
M_BMPDATA->m_bpp = 1;
|
||||||
}
|
}
|
||||||
|
#ifdef __WXGTK20__
|
||||||
|
else if (depth == 32)
|
||||||
|
{
|
||||||
|
M_BMPDATA->m_pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, true,
|
||||||
|
8, width, height);
|
||||||
|
M_BMPDATA->m_bpp = 32;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
M_BMPDATA->m_pixmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, depth );
|
M_BMPDATA->m_pixmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, depth );
|
||||||
@@ -1557,6 +1565,37 @@ void wxBitmap::PurgeOtherRepresentations(wxBitmap::Representation keep)
|
|||||||
|
|
||||||
#endif // __WXGTK20__
|
#endif // __WXGTK20__
|
||||||
|
|
||||||
|
void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp)
|
||||||
|
{
|
||||||
|
#ifdef __WXGTK20__
|
||||||
|
if (bpp != 32)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
GdkPixbuf *pixbuf = GetPixbuf();
|
||||||
|
if (!pixbuf)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (gdk_pixbuf_get_has_alpha( pixbuf ))
|
||||||
|
wxPrintf( wxT("Has alpha\n") );
|
||||||
|
else
|
||||||
|
wxPrintf( wxT("No alpha.\n") );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
data.m_height = gdk_pixbuf_get_height( pixbuf );
|
||||||
|
data.m_width = gdk_pixbuf_get_width( pixbuf );
|
||||||
|
data.m_stride = gdk_pixbuf_get_rowstride( pixbuf );
|
||||||
|
|
||||||
|
return gdk_pixbuf_get_pixels( pixbuf );
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxBitmap::UngetRawData(wxPixelDataBase& data)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxBitmapHandler
|
// wxBitmapHandler
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@@ -306,7 +306,7 @@ bool wxBitmap::Create( int width, int height, int depth )
|
|||||||
if (depth == -1)
|
if (depth == -1)
|
||||||
depth = visual->depth;
|
depth = visual->depth;
|
||||||
|
|
||||||
wxCHECK_MSG( (depth == visual->depth) || (depth == 1), FALSE,
|
wxCHECK_MSG( (depth == visual->depth) || (depth == 1) || (depth == 32), FALSE,
|
||||||
wxT("invalid bitmap depth") )
|
wxT("invalid bitmap depth") )
|
||||||
|
|
||||||
m_refData = new wxBitmapRefData();
|
m_refData = new wxBitmapRefData();
|
||||||
@@ -318,6 +318,14 @@ bool wxBitmap::Create( int width, int height, int depth )
|
|||||||
M_BMPDATA->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 );
|
M_BMPDATA->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 );
|
||||||
M_BMPDATA->m_bpp = 1;
|
M_BMPDATA->m_bpp = 1;
|
||||||
}
|
}
|
||||||
|
#ifdef __WXGTK20__
|
||||||
|
else if (depth == 32)
|
||||||
|
{
|
||||||
|
M_BMPDATA->m_pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, true,
|
||||||
|
8, width, height);
|
||||||
|
M_BMPDATA->m_bpp = 32;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
M_BMPDATA->m_pixmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, depth );
|
M_BMPDATA->m_pixmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, depth );
|
||||||
@@ -1557,6 +1565,37 @@ void wxBitmap::PurgeOtherRepresentations(wxBitmap::Representation keep)
|
|||||||
|
|
||||||
#endif // __WXGTK20__
|
#endif // __WXGTK20__
|
||||||
|
|
||||||
|
void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp)
|
||||||
|
{
|
||||||
|
#ifdef __WXGTK20__
|
||||||
|
if (bpp != 32)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
GdkPixbuf *pixbuf = GetPixbuf();
|
||||||
|
if (!pixbuf)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (gdk_pixbuf_get_has_alpha( pixbuf ))
|
||||||
|
wxPrintf( wxT("Has alpha\n") );
|
||||||
|
else
|
||||||
|
wxPrintf( wxT("No alpha.\n") );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
data.m_height = gdk_pixbuf_get_height( pixbuf );
|
||||||
|
data.m_width = gdk_pixbuf_get_width( pixbuf );
|
||||||
|
data.m_stride = gdk_pixbuf_get_rowstride( pixbuf );
|
||||||
|
|
||||||
|
return gdk_pixbuf_get_pixels( pixbuf );
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxBitmap::UngetRawData(wxPixelDataBase& data)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxBitmapHandler
|
// wxBitmapHandler
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user