kviewshell
GScaler.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifndef _GSCALER_H_
00058 #define _GSCALER_H_
00059 #ifdef HAVE_CONFIG_H
00060 #include "config.h"
00061 #endif
00062 #if NEED_GNUG_PRAGMAS
00063 # pragma interface
00064 #endif
00065
00066
00067
00068
00069 #include "GException.h"
00070 #include "GRect.h"
00071 #include "GBitmap.h"
00072 #include "GPixmap.h"
00073
00074 #ifdef HAVE_NAMESPACES
00075 namespace DJVU {
00076 # ifdef NOT_DEFINED // Just to fool emacs c++ mode
00077 }
00078 #endif
00079 #endif
00080
00081
00103
00104
00117 class GScaler : public GPEnabled
00118 {
00119 protected:
00120 GScaler();
00121 public:
00122 virtual ~GScaler();
00126 void set_input_size(int w, int h);
00130 void set_output_size(int w, int h);
00134 void set_horz_ratio(int numer, int denom);
00138 void set_vert_ratio(int numer, int denom);
00145 void get_input_rect( const GRect &desired_output, GRect &required_input );
00146 protected:
00147
00148 int inw, inh;
00149 int xshift, yshift;
00150 int redw, redh;
00151 int outw, outh;
00152
00153 int *vcoord;
00154 GPBuffer<int> gvcoord;
00155 int *hcoord;
00156 GPBuffer<int> ghcoord;
00157
00158 void make_rectangles(const GRect &desired, GRect &red, GRect &inp);
00159 };
00160
00161
00162
00185 class GBitmapScaler : public GScaler
00186 {
00187 protected:
00188 GBitmapScaler(void);
00189 GBitmapScaler(int inw, int inh, int outw, int outh);
00190 public:
00192 virtual ~GBitmapScaler();
00193
00197 static GP<GBitmapScaler> create(void) {return new GBitmapScaler(); }
00198
00203 static GP<GBitmapScaler> create(
00204 const int inw, const int inh, const int outw, const int outh)
00205 { return new GBitmapScaler(inw,inh,outw,outh); }
00206
00217 void scale( const GRect &provided_input, const GBitmap &input,
00218 const GRect &desired_output, GBitmap &output );
00219 protected:
00220
00221 unsigned char *get_line(int, const GRect &, const GRect &, const GBitmap &);
00222
00223 unsigned char *lbuffer;
00224 GPBuffer<unsigned char> glbuffer;
00225 unsigned char *conv;
00226 GPBuffer<unsigned char> gconv;
00227 unsigned char *p1;
00228 GPBuffer<unsigned char> gp1;
00229 unsigned char *p2;
00230 GPBuffer<unsigned char> gp2;
00231 int l1;
00232 int l2;
00233 };
00234
00235
00259 class GPixmapScaler : public GScaler
00260 {
00261 protected:
00262 GPixmapScaler(void);
00263 GPixmapScaler(int inw, int inh, int outw, int outh);
00264 public:
00266 virtual ~GPixmapScaler();
00267
00271 static GP<GPixmapScaler> create(void) {return new GPixmapScaler(); }
00272
00277 static GP<GPixmapScaler> create(
00278 const int inw, const int inh, const int outw, const int outh)
00279 { return new GPixmapScaler(inw,inh,outw,outh); }
00280
00288 void scale( const GRect &provided_input, const GPixmap &input,
00289 const GRect &desired_output, GPixmap &output );
00290 protected:
00291
00292 GPixel *get_line(int, const GRect &, const GRect &, const GPixmap &);
00293
00294 GPixel *lbuffer;
00295 GPBufferBase glbuffer;
00296 GPixel *p1;
00297 GPBufferBase gp1;
00298 GPixel *p2;
00299 GPBufferBase gp2;
00300 int l1;
00301 int l2;
00302 };
00303
00304
00305
00306
00307
00309
00310
00311
00312
00313
00314
00315 #ifdef HAVE_NAMESPACES
00316 }
00317 # ifndef NOT_USING_DJVU_NAMESPACE
00318 using namespace DJVU;
00319 # endif
00320 #endif
00321 #endif