diff options
| author | Manolo Gouy <Manolo> | 2010-04-15 08:24:25 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2010-04-15 08:24:25 +0000 |
| commit | 595b20f8028a4756eb487a285a5f5ed4e173b2ef (patch) | |
| tree | 294e4448a5459701ea3af1c39cee6e7fc4da8fa7 | |
| parent | fe76949b830f6a0b7efa213aa337a223fe2ab139 (diff) | |
ps_image.cxx: better byte-swapping algorithm.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7506 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | src/ps_image.cxx | 21 |
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; |
