• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kviewshell

GPixmap.h

Go to the documentation of this file.
00001 //C-  -*- C++ -*-
00002 //C- -------------------------------------------------------------------
00003 //C- DjVuLibre-3.5
00004 //C- Copyright (c) 2002  Leon Bottou and Yann Le Cun.
00005 //C- Copyright (c) 2001  AT&T
00006 //C-
00007 //C- This software is subject to, and may be distributed under, the
00008 //C- GNU General Public License, Version 2. The license should have
00009 //C- accompanied the software or you may obtain a copy of the license
00010 //C- from the Free Software Foundation at http://www.fsf.org .
00011 //C-
00012 //C- This program is distributed in the hope that it will be useful,
00013 //C- but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //C- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //C- GNU General Public License for more details.
00016 //C- 
00017 //C- DjVuLibre-3.5 is derived from the DjVu(r) Reference Library
00018 //C- distributed by Lizardtech Software.  On July 19th 2002, Lizardtech 
00019 //C- Software authorized us to replace the original DjVu(r) Reference 
00020 //C- Library notice by the following text (see doc/lizard2002.djvu):
00021 //C-
00022 //C-  ------------------------------------------------------------------
00023 //C- | DjVu (r) Reference Library (v. 3.5)
00024 //C- | Copyright (c) 1999-2001 LizardTech, Inc. All Rights Reserved.
00025 //C- | The DjVu Reference Library is protected by U.S. Pat. No.
00026 //C- | 6,058,214 and patents pending.
00027 //C- |
00028 //C- | This software is subject to, and may be distributed under, the
00029 //C- | GNU General Public License, Version 2. The license should have
00030 //C- | accompanied the software or you may obtain a copy of the license
00031 //C- | from the Free Software Foundation at http://www.fsf.org .
00032 //C- |
00033 //C- | The computer code originally released by LizardTech under this
00034 //C- | license and unmodified by other parties is deemed "the LIZARDTECH
00035 //C- | ORIGINAL CODE."  Subject to any third party intellectual property
00036 //C- | claims, LizardTech grants recipient a worldwide, royalty-free, 
00037 //C- | non-exclusive license to make, use, sell, or otherwise dispose of 
00038 //C- | the LIZARDTECH ORIGINAL CODE or of programs derived from the 
00039 //C- | LIZARDTECH ORIGINAL CODE in compliance with the terms of the GNU 
00040 //C- | General Public License.   This grant only confers the right to 
00041 //C- | infringe patent claims underlying the LIZARDTECH ORIGINAL CODE to 
00042 //C- | the extent such infringement is reasonably necessary to enable 
00043 //C- | recipient to make, have made, practice, sell, or otherwise dispose 
00044 //C- | of the LIZARDTECH ORIGINAL CODE (or portions thereof) and not to 
00045 //C- | any greater extent that may be necessary to utilize further 
00046 //C- | modifications or combinations.
00047 //C- |
00048 //C- | The LIZARDTECH ORIGINAL CODE is provided "AS IS" WITHOUT WARRANTY
00049 //C- | OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
00050 //C- | TO ANY WARRANTY OF NON-INFRINGEMENT, OR ANY IMPLIED WARRANTY OF
00051 //C- | MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00052 //C- +------------------------------------------------------------------
00053 // 
00054 // $Id: GPixmap.h,v 1.8 2003/11/07 22:08:21 leonb Exp $
00055 // $Name: release_3_5_15 $
00056 
00057 #ifndef _GPIXMAP_H_
00058 #define _GPIXMAP_H_
00059 #ifdef HAVE_CONFIG_H
00060 #include "config.h"
00061 #endif
00062 #if NEED_GNUG_PRAGMAS
00063 # pragma interface
00064 #endif
00065 
00084 
00085 
00086 #include "GSmartPointer.h"
00087 
00088 #ifdef HAVE_NAMESPACES
00089 namespace DJVU {
00090 # ifdef NOT_DEFINED // Just to fool emacs c++ mode
00091 }
00092 #endif
00093 #endif
00094 
00095 
00096 class GBitmap;
00097 class GRect;
00098 class ByteStream;
00099 
00100 
00109 struct GPixel
00110 {
00112   unsigned char b;
00114   unsigned char g;
00116   unsigned char r;
00118   friend int operator==(const GPixel & p1, const GPixel & p2);
00120   friend int operator!=(const GPixel & p1, const GPixel & p2);
00122   friend unsigned int hash(const GPixel &p);
00125 
00126   static const GPixel WHITE; 
00128   static const GPixel BLACK; 
00130   static const GPixel BLUE;  
00132   static const GPixel GREEN; 
00134   static const GPixel RED;
00136 };
00137 
00138 
00148 class GPixmap : public GPEnabled
00149 {
00150 protected:
00151   GPixmap(void);
00152   GPixmap(int nrows, int ncolumns, const GPixel *filler=0);
00153   GPixmap(const GBitmap &ref);
00154   GPixmap(const GBitmap &ref, const GRect &rect);
00155   GPixmap(const GPixmap &ref);
00156   GPixmap(const GPixmap &ref, const GRect &rect);
00157   GPixmap(ByteStream &ref);
00158 
00159 public:
00161   virtual ~GPixmap();
00162 
00163   void destroy(void);
00169   static GP<GPixmap> create(void) {return new GPixmap();}
00170 
00174   static GP<GPixmap> create(
00175     const int nrows, const int ncolumns, const GPixel *filler=0)
00176   { return new GPixmap(nrows,ncolumns,filler); }
00177 
00181   static GP<GPixmap> create(const GBitmap &ref)
00182   { return new GPixmap(ref); }
00183 
00189   static GP<GPixmap> create(const GBitmap &ref, const GRect &rect)
00190   { return new GPixmap(ref,rect); }
00191 
00194   static GP<GPixmap> create(const GPixmap &ref)
00195   { return new GPixmap(ref); }
00196 
00200   static GP<GPixmap> create(const GPixmap &ref, const GRect &rect)
00201   { return new GPixmap(ref,rect); }
00202 
00205   static GP<GPixmap> create(ByteStream &ref)
00206   { return new GPixmap(ref); }
00207 
00209 
00215   void init(int nrows, int ncolumns,  const GPixel *filler=0);
00218   void init(const GPixmap &ref);
00221   void init(const GPixmap &ref, const GRect &rect);
00226   void init(const GBitmap &ref, const GPixel *ramp=0);
00232   void init(const GBitmap &ref, const GRect &rect, const GPixel *ramp=0);
00235   void init(ByteStream &ref);
00238   GPixmap& operator=(const GBitmap &ref);
00242   GPixmap& operator=(const GPixmap &ref);
00244 
00248   unsigned int rows() const;
00250   unsigned int columns() const;
00253   const GPixel * operator[] (int row) const;
00256   GPixel * operator[] (int row);
00261   unsigned int rowsize() const;
00263 
00273   void downsample(const GPixmap *src, int factor, const GRect *rect=0);
00281   void upsample(const GPixmap *src, int factor, const GRect *rect=0);
00288   void downsample43(const GPixmap *src, const GRect *rect=0); 
00295   void upsample23(const GPixmap *src, const GRect *rect=0);
00297 
00308   void attenuate(const GBitmap *bm, int x, int y);
00314   void blit(const GBitmap *bm, int x, int y, const GPixel *color);
00321   void blit(const GBitmap *bm, int x, int y, const GPixmap *color);
00326   void blend(const GBitmap *bm, int x, int y, const GPixmap *color);
00334   void stencil(const GBitmap *bm, 
00335                const GPixmap *pm, int pms, 
00336                const GRect *pmr, double corr=1.0);
00338   
00352   void ordered_666_dither(int xmin=0, int ymin=0);
00364   void ordered_32k_dither(int xmin=0, int ymin=0);
00369   void color_correct(double corr);
00372   static void color_correct(double corr, GPixel *pixels, int npixels);
00373 
00375   
00379   inline unsigned int get_memory_usage() const;
00383   void save_ppm(ByteStream &bs, int raw=1) const;
00385 
00398   GPixel *take_data(size_t &offset);
00405   inline void borrow_data(GPixel &data, int w, int h); 
00407   void donate_data(GPixel *data, int w, int h); 
00408   
00413   GP<GPixmap> rotate(int count=0);
00414 
00416   
00417   // Please ignore these two functions. Their only purpose is to allow
00418   // DjVu viewer compile w/o errors. eaf. 
00419   // Is this still useful ?. lyb.
00420   int get_grays(void) const { return 256; };
00421   void set_grays(int) {};\
00422   
00423 protected:
00424   // data
00425   unsigned short nrows;
00426   unsigned short ncolumns;
00427   unsigned short nrowsize;
00428   GPixel *pixels;
00429   GPixel *pixels_data;
00430   friend class DjVu_PixImage;
00431 };
00432 
00434 
00435 // INLINE --------------------------
00436 
00437 
00438 inline int 
00439 operator==(const GPixel & p1, const GPixel & p2)
00440 {
00441   return p1.r==p2.r && p1.g==p2.g && p1.b==p2.b;
00442 }
00443 
00444 inline int 
00445 operator!=(const GPixel & p1, const GPixel & p2)
00446 {
00447   return p1.r!=p2.r || p1.g!=p2.g || p1.b!=p2.b;
00448 }
00449 
00450 inline unsigned int 
00451 hash(const GPixel &p)
00452 {
00453   unsigned int x = (p.b<<16)|(p.g<<8)|(p.r);
00454   return x ^ (p.b<<4) ^ (p.r<<12);
00455 }
00456 
00457 inline unsigned int
00458 GPixmap::rows() const
00459 {
00460   return nrows;
00461 }
00462 
00463 inline unsigned int
00464 GPixmap::columns() const
00465 {
00466   return ncolumns;
00467 }
00468 
00469 inline unsigned int
00470 GPixmap::rowsize() const
00471 {
00472   return nrowsize;
00473 }
00474 
00475 inline GPixel *
00476 GPixmap::operator[](int row)
00477 {
00478   if (row<0 || row>=nrows || !pixels) return 0;
00479   return &pixels[row * nrowsize];
00480 }
00481 
00482 inline const GPixel *
00483 GPixmap::operator[](int row) const
00484 {
00485   if (row<0 || row>=nrows) return 0;
00486   return &pixels[row * nrowsize];
00487 }
00488 
00489 inline GPixmap & 
00490 GPixmap::operator=(const GBitmap &ref)
00491 {
00492   init(ref);
00493   return *this;
00494 }
00495 
00496 inline GPixmap & 
00497 GPixmap::operator=(const GPixmap &ref)
00498 {
00499   init(ref);
00500   return *this;
00501 }
00502 
00503 inline void
00504 GPixmap::borrow_data(GPixel &data, int w, int h)
00505 {
00506   donate_data(&data,w,h);
00507   pixels_data=0;
00508 }
00509 
00511 // Memory usage
00513 
00514 
00515 inline unsigned int 
00516 GPixmap::get_memory_usage() const
00517 {
00518   return  sizeof(GPixmap)+(nrows * ncolumns * sizeof(GPixel));
00519 }
00520 
00521 // ---------------------------------
00522 
00523 #ifdef HAVE_NAMESPACES
00524 }
00525 # ifndef NOT_USING_DJVU_NAMESPACE
00526 using namespace DJVU;
00527 # endif
00528 #endif
00529 #endif
00530 
00531 

kviewshell

Skip menu "kviewshell"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • kviewshell
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal