24-bit rendering from wxImage into wxBitmap
I think requiring GTK 1.0.4 is enough (not 1.0.6) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@935 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1000,10 +1000,10 @@ GUI_TK_LINK=
|
|||||||
MAKEINCLUDE=
|
MAKEINCLUDE=
|
||||||
|
|
||||||
if test "$wxUSE_GTK" = 1; then
|
if test "$wxUSE_GTK" = 1; then
|
||||||
AM_PATH_GTK(1.0.6, [
|
AM_PATH_GTK(1.0.4, [
|
||||||
GUI_TK_INCLUDE="$GTK_CFLAGS"
|
GUI_TK_INCLUDE="$GTK_CFLAGS"
|
||||||
GUI_TK_LIBRARY="$GTK_LIBS"
|
GUI_TK_LIBRARY="$GTK_LIBS"
|
||||||
], AC_MSG_ERROR(Is gtk-config in path and GTK+ is version 1.0.6?))
|
], AC_MSG_ERROR(Is gtk-config in path and GTK+ is version 1.0.4?))
|
||||||
TOOLKIT=GTK
|
TOOLKIT=GTK
|
||||||
TOOLKIT_DEF=__WXGTK__
|
TOOLKIT_DEF=__WXGTK__
|
||||||
MAKEINCLUDE=../gtk.inc
|
MAKEINCLUDE=../gtk.inc
|
||||||
|
@@ -16,9 +16,6 @@ wxHelpController
|
|||||||
Fix printing of bitmaps
|
Fix printing of bitmaps
|
||||||
-> No idea.
|
-> No idea.
|
||||||
|
|
||||||
wxImage
|
|
||||||
-> 24-bit support
|
|
||||||
|
|
||||||
-------------------- Low priority ---------------------
|
-------------------- Low priority ---------------------
|
||||||
|
|
||||||
wxDebugContext <-> wxLogXXX functions
|
wxDebugContext <-> wxLogXXX functions
|
||||||
|
@@ -101,25 +101,32 @@ wxBitmap::wxBitmap(void)
|
|||||||
|
|
||||||
wxBitmap::wxBitmap( int width, int height, int depth )
|
wxBitmap::wxBitmap( int width, int height, int depth )
|
||||||
{
|
{
|
||||||
|
wxCHECK_RET( (width > 0) && (height > 0), "invalid bitmap size" )
|
||||||
|
wxCHECK_RET( (depth > 0) || (depth == -1), "invalid bitmap depth" )
|
||||||
|
|
||||||
m_refData = new wxBitmapRefData();
|
m_refData = new wxBitmapRefData();
|
||||||
|
|
||||||
|
GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
|
||||||
|
|
||||||
M_BMPDATA->m_mask = (wxMask *) NULL;
|
M_BMPDATA->m_mask = (wxMask *) NULL;
|
||||||
M_BMPDATA->m_pixmap =
|
M_BMPDATA->m_pixmap = gdk_pixmap_new( parent, width, height, depth );
|
||||||
gdk_pixmap_new( (GdkWindow*) &gdk_root_parent, width, height, depth );
|
|
||||||
M_BMPDATA->m_width = width;
|
M_BMPDATA->m_width = width;
|
||||||
M_BMPDATA->m_height = height;
|
M_BMPDATA->m_height = height;
|
||||||
M_BMPDATA->m_bpp = depth;
|
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth;
|
||||||
|
|
||||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap::wxBitmap( char **bits )
|
wxBitmap::wxBitmap( char **bits )
|
||||||
{
|
{
|
||||||
|
wxCHECK_RET( bits != NULL, "invalid bitmap data" )
|
||||||
|
|
||||||
m_refData = new wxBitmapRefData();
|
m_refData = new wxBitmapRefData();
|
||||||
|
|
||||||
GdkBitmap *mask = NULL;
|
GdkBitmap *mask = (GdkBitmap*) NULL;
|
||||||
|
GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
|
||||||
|
|
||||||
M_BMPDATA->m_pixmap =
|
M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits );
|
||||||
gdk_pixmap_create_from_xpm_d( (GdkWindow*) &gdk_root_parent, &mask, NULL, (gchar **) bits );
|
|
||||||
|
|
||||||
if (mask)
|
if (mask)
|
||||||
{
|
{
|
||||||
@@ -129,7 +136,7 @@ wxBitmap::wxBitmap( char **bits )
|
|||||||
|
|
||||||
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
|
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
|
||||||
|
|
||||||
M_BMPDATA->m_bpp = 24; // ?
|
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; // ?
|
||||||
|
|
||||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||||
}
|
}
|
||||||
@@ -375,6 +382,20 @@ wxBitmap::wxBitmap( const wxImage &image )
|
|||||||
|
|
||||||
// Render
|
// Render
|
||||||
|
|
||||||
|
enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR };
|
||||||
|
byte_order b_o;
|
||||||
|
|
||||||
|
if (render_depth >= 24)
|
||||||
|
{
|
||||||
|
GdkVisual *visual = gdk_visual_get_system();
|
||||||
|
if ((visual->red_mask > visual->green_mask) && (visual->green_mask > visual->blue_mask)) b_o = RGB;
|
||||||
|
else if ((visual->red_mask > visual->blue_mask) && (visual->blue_mask > visual->green_mask)) b_o = RGB;
|
||||||
|
else if ((visual->blue_mask > visual->red_mask) && (visual->red_mask > visual->green_mask)) b_o = BRG;
|
||||||
|
else if ((visual->blue_mask > visual->green_mask) && (visual->green_mask > visual->red_mask)) b_o = BGR;
|
||||||
|
else if ((visual->green_mask > visual->red_mask) && (visual->red_mask > visual->blue_mask)) b_o = GRB;
|
||||||
|
else if ((visual->green_mask > visual->blue_mask) && (visual->blue_mask > visual->red_mask)) b_o = GBR;
|
||||||
|
}
|
||||||
|
|
||||||
int r_mask = image.GetMaskRed();
|
int r_mask = image.GetMaskRed();
|
||||||
int g_mask = image.GetMaskGreen();
|
int g_mask = image.GetMaskGreen();
|
||||||
int b_mask = image.GetMaskBlue();
|
int b_mask = image.GetMaskBlue();
|
||||||
@@ -434,13 +455,20 @@ wxBitmap::wxBitmap( const wxImage &image )
|
|||||||
gdk_image_put_pixel( data_image, x, y, pixel );
|
gdk_image_put_pixel( data_image, x, y, pixel );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 32:
|
||||||
case 24:
|
case 24:
|
||||||
{
|
{
|
||||||
break;
|
guint32 pixel = 0;
|
||||||
}
|
switch (b_o)
|
||||||
case 32:
|
|
||||||
{
|
{
|
||||||
break;
|
case RGB: pixel = (r << 16) | (g << 8) | b; break;
|
||||||
|
case RBG: pixel = (r << 16) | (b << 8) | g; break;
|
||||||
|
case BRG: pixel = (b << 16) | (r << 8) | g; break;
|
||||||
|
case BGR: pixel = (b << 16) | (g << 8) | r; break;
|
||||||
|
case GRB: pixel = (g << 16) | (r << 8) | b; break;
|
||||||
|
case GBR: pixel = (g << 16) | (b << 8) | r; break;
|
||||||
|
}
|
||||||
|
gdk_image_put_pixel( data_image, x, y, pixel );
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
@@ -101,25 +101,32 @@ wxBitmap::wxBitmap(void)
|
|||||||
|
|
||||||
wxBitmap::wxBitmap( int width, int height, int depth )
|
wxBitmap::wxBitmap( int width, int height, int depth )
|
||||||
{
|
{
|
||||||
|
wxCHECK_RET( (width > 0) && (height > 0), "invalid bitmap size" )
|
||||||
|
wxCHECK_RET( (depth > 0) || (depth == -1), "invalid bitmap depth" )
|
||||||
|
|
||||||
m_refData = new wxBitmapRefData();
|
m_refData = new wxBitmapRefData();
|
||||||
|
|
||||||
|
GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
|
||||||
|
|
||||||
M_BMPDATA->m_mask = (wxMask *) NULL;
|
M_BMPDATA->m_mask = (wxMask *) NULL;
|
||||||
M_BMPDATA->m_pixmap =
|
M_BMPDATA->m_pixmap = gdk_pixmap_new( parent, width, height, depth );
|
||||||
gdk_pixmap_new( (GdkWindow*) &gdk_root_parent, width, height, depth );
|
|
||||||
M_BMPDATA->m_width = width;
|
M_BMPDATA->m_width = width;
|
||||||
M_BMPDATA->m_height = height;
|
M_BMPDATA->m_height = height;
|
||||||
M_BMPDATA->m_bpp = depth;
|
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth;
|
||||||
|
|
||||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap::wxBitmap( char **bits )
|
wxBitmap::wxBitmap( char **bits )
|
||||||
{
|
{
|
||||||
|
wxCHECK_RET( bits != NULL, "invalid bitmap data" )
|
||||||
|
|
||||||
m_refData = new wxBitmapRefData();
|
m_refData = new wxBitmapRefData();
|
||||||
|
|
||||||
GdkBitmap *mask = NULL;
|
GdkBitmap *mask = (GdkBitmap*) NULL;
|
||||||
|
GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
|
||||||
|
|
||||||
M_BMPDATA->m_pixmap =
|
M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits );
|
||||||
gdk_pixmap_create_from_xpm_d( (GdkWindow*) &gdk_root_parent, &mask, NULL, (gchar **) bits );
|
|
||||||
|
|
||||||
if (mask)
|
if (mask)
|
||||||
{
|
{
|
||||||
@@ -129,7 +136,7 @@ wxBitmap::wxBitmap( char **bits )
|
|||||||
|
|
||||||
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
|
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
|
||||||
|
|
||||||
M_BMPDATA->m_bpp = 24; // ?
|
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; // ?
|
||||||
|
|
||||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||||
}
|
}
|
||||||
@@ -375,6 +382,20 @@ wxBitmap::wxBitmap( const wxImage &image )
|
|||||||
|
|
||||||
// Render
|
// Render
|
||||||
|
|
||||||
|
enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR };
|
||||||
|
byte_order b_o;
|
||||||
|
|
||||||
|
if (render_depth >= 24)
|
||||||
|
{
|
||||||
|
GdkVisual *visual = gdk_visual_get_system();
|
||||||
|
if ((visual->red_mask > visual->green_mask) && (visual->green_mask > visual->blue_mask)) b_o = RGB;
|
||||||
|
else if ((visual->red_mask > visual->blue_mask) && (visual->blue_mask > visual->green_mask)) b_o = RGB;
|
||||||
|
else if ((visual->blue_mask > visual->red_mask) && (visual->red_mask > visual->green_mask)) b_o = BRG;
|
||||||
|
else if ((visual->blue_mask > visual->green_mask) && (visual->green_mask > visual->red_mask)) b_o = BGR;
|
||||||
|
else if ((visual->green_mask > visual->red_mask) && (visual->red_mask > visual->blue_mask)) b_o = GRB;
|
||||||
|
else if ((visual->green_mask > visual->blue_mask) && (visual->blue_mask > visual->red_mask)) b_o = GBR;
|
||||||
|
}
|
||||||
|
|
||||||
int r_mask = image.GetMaskRed();
|
int r_mask = image.GetMaskRed();
|
||||||
int g_mask = image.GetMaskGreen();
|
int g_mask = image.GetMaskGreen();
|
||||||
int b_mask = image.GetMaskBlue();
|
int b_mask = image.GetMaskBlue();
|
||||||
@@ -434,13 +455,20 @@ wxBitmap::wxBitmap( const wxImage &image )
|
|||||||
gdk_image_put_pixel( data_image, x, y, pixel );
|
gdk_image_put_pixel( data_image, x, y, pixel );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 32:
|
||||||
case 24:
|
case 24:
|
||||||
{
|
{
|
||||||
break;
|
guint32 pixel = 0;
|
||||||
}
|
switch (b_o)
|
||||||
case 32:
|
|
||||||
{
|
{
|
||||||
break;
|
case RGB: pixel = (r << 16) | (g << 8) | b; break;
|
||||||
|
case RBG: pixel = (r << 16) | (b << 8) | g; break;
|
||||||
|
case BRG: pixel = (b << 16) | (r << 8) | g; break;
|
||||||
|
case BGR: pixel = (b << 16) | (g << 8) | r; break;
|
||||||
|
case GRB: pixel = (g << 16) | (r << 8) | b; break;
|
||||||
|
case GBR: pixel = (g << 16) | (b << 8) | r; break;
|
||||||
|
}
|
||||||
|
gdk_image_put_pixel( data_image, x, y, pixel );
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user