summaryrefslogtreecommitdiff
path: root/src/drivers/Quartz
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/Quartz')
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver.h3
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx20
2 files changed, 23 insertions, 0 deletions
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.h b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.h
index b000aa230..f72e8be8d 100644
--- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.h
+++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.h
@@ -48,6 +48,9 @@ public:
const char *class_name() {return class_id;};
virtual int has_feature(driver_feature mask) { return mask & NATIVE; }
+ // --- bitmap stuff
+ Fl_Bitmask create_bitmask(int w, int h, const uchar *array);
+ void delete_bitmask(Fl_Bitmask bm);
void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy);
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx
index 8bac28c42..442b8b29a 100644
--- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx
+++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_image.cxx
@@ -278,6 +278,26 @@ void Fl_Quartz_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int
copy_offscreen(X, Y, W, H, (Fl_Offscreen)pxm->id_, cx, cy);
}
+Fl_Bitmask Fl_Quartz_Graphics_Driver::create_bitmask(int w, int h, const uchar *array) {
+ static uchar reverse[16] = /* Bit reversal lookup table */
+ { 0x00, 0x88, 0x44, 0xcc, 0x22, 0xaa, 0x66, 0xee,
+ 0x11, 0x99, 0x55, 0xdd, 0x33, 0xbb, 0x77, 0xff };
+ int rowBytes = (w+7)>>3 ;
+ uchar *bmask = (uchar*)malloc(rowBytes*h), *dst = bmask;
+ const uchar *src = array;
+ for ( int i=rowBytes*h; i>0; i--,src++ ) {
+ *dst++ = ((reverse[*src & 0x0f] & 0xf0) | (reverse[(*src >> 4) & 0x0f] & 0x0f))^0xff;
+ }
+ CGDataProviderRef srcp = CGDataProviderCreateWithData( 0L, bmask, rowBytes*h, 0L);
+ CGImageRef id_ = CGImageMaskCreate( w, h, 1, 1, rowBytes, srcp, 0L, false);
+ CGDataProviderRelease(srcp);
+ return (Fl_Bitmask)id_;
+}
+
+void Fl_Quartz_Graphics_Driver::delete_bitmask(Fl_Bitmask bm) {
+ if (bm) CGImageRelease((CGImageRef)bm);
+}
+
#endif // FL_CFG_GFX_QUARTZ