diff options
| author | Manolo Gouy <Manolo> | 2010-04-16 20:19:09 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2010-04-16 20:19:09 +0000 |
| commit | 913530758af63f00676c6746988aef8b35b02531 (patch) | |
| tree | d6b59be15047e3c2742158eb5063aca55ea94eba /src/ps_image.cxx | |
| parent | 0f180e130639f1017e7ca6b668357304632c1a62 (diff) | |
Improved the hierarchy of Fl_Device subclasses to allow separation of platform-specific devices.
This introduces multiple inheritance.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7520 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/ps_image.cxx')
| -rw-r--r-- | src/ps_image.cxx | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/src/ps_image.cxx b/src/ps_image.cxx index 61534238c..65e967755 100644 --- a/src/ps_image.cxx +++ b/src/ps_image.cxx @@ -34,7 +34,7 @@ #include <FL/Fl_Pixmap.H> #include <FL/Fl_Bitmap.H> -int Fl_PSfile_Device::alpha_mask(const uchar * data, int w, int h, int D, int LD){ +int Fl_PS_Device::alpha_mask(const uchar * data, int w, int h, int D, int LD){ mask = 0; if((D/2)*2 != D){ //no mask info @@ -182,18 +182,27 @@ 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}; -// 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; -void Fl_PSfile_Device::draw_scaled_image(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D, int LD) { +void Fl_PS_Device::draw_scaled_image(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D, int LD) { if(D<3){ //mono @@ -260,7 +269,7 @@ void Fl_PSfile_Device::draw_scaled_image(const uchar *data, double x, double y, }; -void Fl_PSfile_Device::draw_scaled_image(Fl_Draw_Image_Cb call, void *data, double x, double y, double w, double h, int iw, int ih, int D) { +void Fl_PS_Device::draw_scaled_image(Fl_Draw_Image_Cb call, void *data, double x, double y, double w, double h, int iw, int ih, int D) { int level2_mask = 0; fprintf(output,"save\n"); @@ -348,7 +357,7 @@ void Fl_PSfile_Device::draw_scaled_image(Fl_Draw_Image_Cb call, void *data, doub delete[] rgbdata; } -void Fl_PSfile_Device::draw_scaled_image_mono(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D, int LD) { +void Fl_PS_Device::draw_scaled_image_mono(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D, int LD) { fprintf(output,"save\n"); @@ -409,7 +418,7 @@ void Fl_PSfile_Device::draw_scaled_image_mono(const uchar *data, double x, doubl -void Fl_PSfile_Device::draw_scaled_image_mono(Fl_Draw_Image_Cb call, void *data, double x, double y, double w, double h, int iw, int ih, int D) { +void Fl_PS_Device::draw_scaled_image_mono(Fl_Draw_Image_Cb call, void *data, double x, double y, double w, double h, int iw, int ih, int D) { fprintf(output,"save\n"); int i,j,k; @@ -458,7 +467,7 @@ void Fl_PSfile_Device::draw_scaled_image_mono(Fl_Draw_Image_Cb call, void *data, ////////////////////////////// Image classes ////////////////////// -void Fl_PSfile_Device::draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy){ +void Fl_PS_Device::draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy){ const char * const * di =pxm->data(); int w,h; if (!fl_measure_pixmap(di, w, h)) return; @@ -474,7 +483,7 @@ void Fl_PSfile_Device::draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int fl_mask_bitmap=0; }; -void Fl_PSfile_Device::draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy){ +void Fl_PS_Device::draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy){ const uchar * di = rgb->array; int w = rgb->w(); int h = rgb->h(); @@ -488,7 +497,7 @@ void Fl_PSfile_Device::draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, i mask=0; }; -void Fl_PSfile_Device::draw(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy){ +void Fl_PS_Device::draw(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy){ const uchar * di = bitmap->array; int w,h; int LD=(bitmap->w()+7)/8; |
