summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ps_image.cxx21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/ps_image.cxx b/src/ps_image.cxx
index 67d46b070..61534238c 100644
--- a/src/ps_image.cxx
+++ b/src/ps_image.cxx
@@ -182,22 +182,13 @@ int Fl_PSfile_Device::alpha_mask(const uchar * data, int w, int h, int D, int LD
return 0;
}
+// bitwise inversion of all 4-bit quantities
+static const unsigned char swapped[16] = {0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
-
-// TODO: anybody has more efficient algoritm?
-static inline uchar swap_byte(const uchar i){
- uchar b =0;
- if(i & 1) b |= 128;
- if(i & 2) b |= 64;
- if(i & 4) b |= 32;
- if(i & 8) b |= 16;
- if(i & 16) b |= 8;
- if(i & 32) b |= 4;
- if(i & 64) b |= 2;
- if(i & 128) b |= 1;
- return b;
-}
-
+// bitwise inversion of a byte
+static inline uchar swap_byte(const uchar b){
+ return (swapped[b & 0xF] << 4) | swapped[b >> 4];
+ }
extern uchar **fl_mask_bitmap;