summaryrefslogtreecommitdiff
path: root/src/Fl_Image.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2014-06-12 13:28:04 +0000
committerPierre Ossman <ossman@cendio.se>2014-06-12 13:28:04 +0000
commited7983f5b5aa2e4ccb6aff951e8a14c4015c7980 (patch)
treea6fd7ab5c02f03a91a2df1cde7ba4461044c9202 /src/Fl_Image.cxx
parent5e9624286ae76237cb1a73622db999c77b611f2d (diff)
Add ability to convert a Fl_Pixmap into a Fl_RGB_Image.
This is very convenient as a lot of other functions only accept a Fl_RGB_Image. Adding this functionality also required a bit of spring cleaning in the the drawing routines. STR #2659. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10192 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Image.cxx')
-rw-r--r--src/Fl_Image.cxx17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx
index a178eba38..c27d90b63 100644
--- a/src/Fl_Image.cxx
+++ b/src/Fl_Image.cxx
@@ -165,7 +165,22 @@ Fl_Image::measure(const Fl_Label *lo, // I - Label
//
size_t Fl_RGB_Image::max_size_ = ~((size_t)0);
-/** The destructor free all memory and server resources that are used by the image. */
+int fl_convert_pixmap(const char*const* cdata, uchar* out, Fl_Color bg);
+
+/** The constructor creates a new RGBA image from the specified Fl_Pixmap.
+
+ The RGBA image is built fully opaque except for the transparent area
+ of the pixmap that is assigned the \par bg color with full transparency */
+Fl_RGB_Image::Fl_RGB_Image(const Fl_Pixmap *pxm, Fl_Color bg):
+ Fl_Image(pxm->w(), pxm->h(), 4), id_(0), mask_(0)
+{
+ array = new uchar[w() * h() * d()];
+ alloc_array = 1;
+ fl_convert_pixmap(pxm->data(), (uchar*)array, bg);
+ data((const char **)&array, 1);
+}
+
+/** The destructor frees all memory and server resources that are used by the image. */
Fl_RGB_Image::~Fl_RGB_Image() {
uncache();
if (alloc_array) delete[] (uchar *)array;