summaryrefslogtreecommitdiff
path: root/src/Fl_Bitmap.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2004-08-25 00:20:27 +0000
committerMatthias Melcher <fltk@matthiasm.com>2004-08-25 00:20:27 +0000
commit8327822026ac50dc9e20823988b0f53bc143b7ba (patch)
tree864e83d7482fa6414d48621a16b677246e49f8ae /src/Fl_Bitmap.cxx
parent522f98d5230e78f983ffcc8f05391c060661cf1a (diff)
Updated config stuff to allow for --enable-quartz ofr Mac OS X which in
turn defined USE_QUARTZ to 1 and defines __APPLE_QUARTZ__. If Quartz is not disabled, it will define __APPLE_QD__ for Quickdraw. I also replaced all relevand #ifdef __APPLE__ with #ifdef __APPLE_QD__ #elif defined(__APPLE_QUARTZ__). This does not affect the compile at this time and both version will generate the same Quickdraw code. I will start to replace all QD calls with Quartz calls for the remainder of the week until I can completely remove all QD calls from the Quartz branch. Thanks to Robert Smith for a great initial Quartz implementation. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3782 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Bitmap.cxx')
-rw-r--r--src/Fl_Bitmap.cxx70
1 files changed, 65 insertions, 5 deletions
diff --git a/src/Fl_Bitmap.cxx b/src/Fl_Bitmap.cxx
index cc9d7a16e..c1799e29c 100644
--- a/src/Fl_Bitmap.cxx
+++ b/src/Fl_Bitmap.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.23 2004/04/11 04:38:57 easysw Exp $"
+// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.24 2004/08/25 00:20:25 matthiaswm Exp $"
//
// Bitmap drawing routines for the Fast Light Tool Kit (FLTK).
//
@@ -31,7 +31,7 @@
#include <FL/Fl_Bitmap.H>
#include "flstring.h"
-#ifdef __APPLE__ // MacOS bitmask functions
+#ifdef __APPLE_QD__ // MacOS bitmask functions
Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *array) {
Rect srcRect;
srcRect.left = 0; srcRect.right = w;
@@ -77,6 +77,51 @@ Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *array) {
void fl_delete_bitmask(Fl_Bitmask id) {
if (id) DisposeGWorld(id);
}
+#elif defined(__APPLE_QUARTZ__)
+# warning quartz
+Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *array) {
+ Rect srcRect;
+ srcRect.left = 0; srcRect.right = w;
+ srcRect.top = 0; srcRect.bottom = h;
+ GrafPtr savePort;
+
+ GetPort(&savePort); // remember the current port
+
+ Fl_Bitmask gw;
+ NewGWorld( &gw, 1, &srcRect, 0L, 0L, 0 );
+ PixMapHandle pm = GetGWorldPixMap( gw );
+ if ( pm )
+ {
+ LockPixels( pm );
+ if ( *pm )
+ {
+ uchar *base = (uchar*)GetPixBaseAddr( pm );
+ if ( base )
+ {
+ PixMapPtr pmp = *pm;
+ // verify the parameters for direct memory write
+ if ( pmp->pixelType == 0 || pmp->pixelSize == 1 || pmp->cmpCount == 1 || pmp->cmpSize == 1 )
+ {
+ static uchar reverse[16] = /* Bit reversal lookup table */
+ { 0x00, 0x88, 0x44, 0xcc, 0x22, 0xaa, 0x66, 0xee, 0x11, 0x99, 0x55, 0xdd, 0x33, 0xbb, 0x77, 0xff };
+ uchar *dst = base;
+ const uchar *src = array;
+ int rowBytesSrc = (w+7)>>3 ;
+ int rowPatch = (pmp->rowBytes&0x3fff) - rowBytesSrc;
+ for ( int j=0; j<h; j++,dst+=rowPatch )
+ for ( int i=0; i<rowBytesSrc; i++,src++ )
+ *dst++ = (reverse[*src & 0x0f] & 0xf0) | (reverse[(*src >> 4) & 0x0f] & 0x0f);
+ }
+ }
+ UnlockPixels( pm );
+ }
+ }
+ SetPort(savePort);
+ return gw; /* tell caller we succeeded! */
+}
+void fl_delete_bitmask(Fl_Bitmask id) {
+ if (id) DisposeGWorld(id);
+}
#elif defined(WIN32) // Windows bitmask functions...
// 'fl_create_bitmap()' - Create a 1-bit bitmap for drawing...
static Fl_Bitmask fl_create_bitmap(int w, int h, const uchar *data) {
@@ -213,7 +258,7 @@ void fl_delete_bitmask(Fl_Bitmask bm) {
// If you want to test/fix this, uncomment the "#ifdef __APPLE__" and comment out
// the "#if 0" here. Also see Fl_Image.cxx for a similar check...
-//#ifdef __APPLE__
+//#ifdef __APPLE_QD__
#if 0
// Create an 8-bit mask used for alpha blending
Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *array) {
@@ -356,7 +401,7 @@ void Fl_Bitmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
// secret bitblt code found in old MSWindows reference manual:
BitBlt(fl_gc, X, Y, W, H, tempdc, cx, cy, 0xE20746L);
DeleteDC(tempdc);
-#elif defined(__APPLE__)
+#elif defined(__APPLE_QD__)
if (!id) id = fl_create_bitmask(w(), h(), array);
GrafPtr dstPort;
GetPort( &dstPort );
@@ -370,6 +415,21 @@ void Fl_Bitmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
&dst, // dst bounds
srcOr, // mode
0L); // mask region
+#elif defined(__APPLE_QUARTZ__)
+# warning quartz
+ if (!id) id = fl_create_bitmask(w(), h(), array);
+ GrafPtr dstPort;
+ GetPort( &dstPort );
+ Rect src, dst;
+ GetPortBounds( (Fl_Offscreen)id, &src );
+ SetRect( &src, cx, cy, cx+W, cy+H );
+ SetRect( &dst, X, Y, X+W, Y+H );
+ CopyBits(GetPortBitMapForCopyBits((Fl_Offscreen)id), // srcBits
+ GetPortBitMapForCopyBits(dstPort), // dstBits
+ &src, // src bounds
+ &dst, // dst bounds
+ srcOr, // mode
+ 0L); // mask region
#else
if (!id) id = fl_create_bitmask(w(), h(), array);
@@ -474,5 +534,5 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) {
//
-// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.23 2004/04/11 04:38:57 easysw Exp $".
+// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.24 2004/08/25 00:20:25 matthiaswm Exp $".
//