X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b229c8a9112ff3ecbf5b05c3c5469ade34517a9c..28169f14ec80f07874464412c72d7523a7768d81:/src/motif/utils.cpp diff --git a/src/motif/utils.cpp b/src/motif/utils.cpp index b9ddd16c51..56c48759cb 100644 --- a/src/motif/utils.cpp +++ b/src/motif/utils.cpp @@ -25,7 +25,8 @@ #include "wx/app.h" #include "wx/msgdlg.h" #include "wx/cursor.h" -#include "wx/window.h" // for wxTopLevelWindows +#include "wx/dcmemory.h" +#include "wx/bitmap.h" #include #include @@ -1235,3 +1236,30 @@ XmString wxStringToXmString( const char* str ) { return XmStringCreateLtoR((char *)str, XmSTRING_DEFAULT_CHARSET); } + +// ---------------------------------------------------------------------------- +// wxBitmap utility functions +// ---------------------------------------------------------------------------- + +// Creates a bitmap with transparent areas drawn in +// the given colour. +wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, wxColour& colour) +{ + wxBitmap newBitmap(bitmap.GetWidth(), + bitmap.GetHeight(), + bitmap.GetDepth()); + wxMemoryDC destDC; + wxMemoryDC srcDC; + + srcDC.SelectObject(bitmap); + destDC.SelectObject(newBitmap); + + wxBrush brush(colour, wxSOLID); + // destDC.SetOptimization(FALSE); + destDC.SetBackground(brush); + destDC.Clear(); + destDC.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(), + &srcDC, 0, 0, wxCOPY, TRUE); + + return newBitmap; +}