Author: manolo
Date: 2010-04-15 01:24:25 -0700 (Thu, 15 Apr 2010)
New Revision: 7506
Log:
ps_image.cxx: better byte-swapping algorithm.

Modified:
   branches/branch-1.3/src/ps_image.cxx

Modified: branches/branch-1.3/src/ps_image.cxx
===================================================================
--- branches/branch-1.3/src/ps_image.cxx        2010-04-14 20:47:34 UTC (rev 
7505)
+++ branches/branch-1.3/src/ps_image.cxx        2010-04-15 08:24:25 UTC (rev 
7506)
@@ -182,23 +182,14 @@
   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};
 
+// bitwise inversion of a byte
+static inline uchar swap_byte(const uchar b){
+ return (swapped[b & 0xF] << 4) | swapped[b >> 4];
+ }
 
-// 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;
-}
-
-
 extern uchar **fl_mask_bitmap;
 
 

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to