TImage.h

Go to the documentation of this file.
00001 // @(#)root/graf:$Id: TImage.h 30544 2009-10-02 15:33:12Z couet $
00002 // Author: Fons Rademakers, Reiner Rohlfs   15/10/2001
00003 
00004 /*************************************************************************
00005  * Copyright (C) 2001-2001, Rene Brun, Fons Rademakers and Reiner Rohlfs *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TImage
00013 #define ROOT_TImage
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TImage                                                               //
00019 //                                                                      //
00020 // Abstract interface to image processing library.                      //
00021 //                                                                      //
00022 //////////////////////////////////////////////////////////////////////////
00023 
00024 #ifndef ROOT_TNamed
00025 #include "TNamed.h"
00026 #endif
00027 
00028 #ifndef ROOT_TAttImage
00029 #include "TAttImage.h"
00030 #endif
00031 #ifndef ROOT_GuiTypes
00032 #include "GuiTypes.h"
00033 #endif
00034 #ifndef ROOT_TVectorDfwd
00035 #include "TVectorDfwd.h"
00036 #endif
00037 
00038 class TVirtualPad;
00039 class TArrayD;
00040 class TArrayL;
00041 class TH2D;
00042 class TPoint;
00043 class TText;
00044 
00045 class TImage : public TNamed, public TAttImage {
00046 
00047 friend TImage operator+(const TImage &i1, const TImage &s2);
00048 friend TImage operator/(const TImage &i1, const TImage &s2);
00049 
00050 public:
00051    // Defines image file types
00052    enum EImageFileTypes {
00053       kXpm = 0,
00054       kZCompressedXpm,
00055       kGZCompressedXpm,
00056       kPng,
00057       kJpeg,
00058       kXcf,
00059       kPpm,
00060       kPnm,
00061       kBmp,
00062       kIco,
00063       kCur,
00064       kGif,
00065       kTiff,
00066       kXbm,
00067       kFits,
00068       kTga,
00069       kXml,
00070       kUnknown,
00071       kAnimGif
00072    };
00073 
00074    enum EText3DType {
00075       kPlain = 0,  // regular 2D text
00076       kEmbossed,
00077       kSunken,
00078       kShadeAbove,
00079       kShadeBelow,
00080       kEmbossedThick,
00081       kSunkenThick,
00082       kOutlineAbove,
00083       kOutlineBelow,
00084       kOutlineFull,
00085       k3DTypes
00086    };
00087 
00088    enum ECharType {
00089       kUTF8 = 0,
00090       kChar = 1,
00091       kUnicode = 4
00092    };
00093 
00094    enum ETileType {
00095       kStretch = 0,
00096       kTile,
00097       kStretchY,
00098       kStretchX
00099    };
00100 
00101    enum ECoordMode {
00102       kCoordModeOrigin = 0,
00103       kCoordModePrevious
00104    };
00105 
00106    enum EColorChan {
00107       kRedChan   = BIT(0),
00108       kGreenChan = BIT(1),
00109       kBlueChan  = BIT(2),
00110       kAlphaChan = BIT(3),
00111       kAllChan   = kRedChan | kGreenChan | kBlueChan | kAlphaChan 
00112    };
00113 
00114 protected:
00115    TImage(const char *file) : TNamed(file, "") { }
00116    TImage() { }
00117 
00118 public:
00119    TImage(const TImage &img) : TNamed(img), TAttImage(img) { }
00120    TImage &operator=(const TImage &img)
00121             { TNamed::operator=(img); TAttImage::operator=(img); return *this; }
00122    TImage(UInt_t /*w*/, UInt_t /*h*/) : TNamed(), TAttImage() { }
00123 
00124    virtual ~TImage() { }
00125 
00126    // Cloning
00127    virtual TObject *Clone(const char *) const { return 0; }
00128 
00129    // Input / output
00130    virtual void ReadImage(const char * /*file*/, EImageFileTypes /*type*/ = TImage::kUnknown) {}
00131    virtual void WriteImage(const char * /*file*/, EImageFileTypes /*type*/ = TImage::kUnknown)  {}
00132    virtual void SetImage(const Double_t * /*imageData*/, UInt_t /*width*/, UInt_t /*height*/, TImagePalette * /*palette*/ = 0) {}
00133    virtual void SetImage(const TArrayD & /*imageData*/, UInt_t /*width*/, TImagePalette * /*palette*/ = 0) {}
00134    virtual void SetImage(const TVectorD & /*imageData*/, UInt_t /*width*/, TImagePalette * /*palette*/ = 0) {}
00135    virtual void SetImage(Pixmap_t /*pxm*/, Pixmap_t /*mask*/ = 0) {}
00136 
00137    // Create an image from the given pad. (See TASImage::FromPad)
00138    virtual void FromPad(TVirtualPad * /*pad*/, Int_t /*x*/ = 0, Int_t /*y*/ = 0, UInt_t /*w*/ = 0, UInt_t /*h*/ = 0) {}
00139 
00140    // Restore the image original size. (See TASImage::UnZoom)
00141    virtual void UnZoom() {}
00142 
00143    // Zoom the image. (See TASImage::Zoom)
00144    virtual void Zoom(UInt_t /*offX*/, UInt_t /*offY*/, UInt_t /*width*/, UInt_t /*height*/) {}
00145 
00146    // Flip the image by a multiple of 90 degrees. (See TASImage::Flip)
00147    virtual void Flip(Int_t /*flip*/ = 180) {}
00148 
00149    // Converts image to Gray. (See TASImage::Gray)
00150    virtual void Gray(Bool_t /*on*/ = kTRUE) {}
00151    virtual Bool_t IsGray() const { return kFALSE; }
00152 
00153    // Mirror the image. (See TASImage::Mirror)
00154    virtual void Mirror(Bool_t /*vert*/ = kTRUE) {}
00155 
00156    // Scale the image. (See TASImage::Scale)
00157    virtual void Scale(UInt_t /*width*/, UInt_t /*height*/) {}
00158    
00159    // Slice the image. (See TASImage::Slice)
00160    virtual void Slice(UInt_t /*xStart*/, UInt_t /*xEnd*/, UInt_t /*yStart*/,  UInt_t /*yEnd*/,
00161                       UInt_t /*toWidth*/, UInt_t /*toHeight*/) {}
00162 
00163    // Tile the image. (See TASImage::Tile)
00164    virtual void Tile(UInt_t /*width*/, UInt_t /*height*/) {}
00165 
00166    // Crop the image. (See TASImage::Crop)
00167    virtual void Crop(Int_t /*x*/ = 0, Int_t /*y*/ = 0, UInt_t /*width*/ = 0, UInt_t /*height*/ = 0) {}
00168 
00169    // Enlarge image. (See TASImage::Pad)
00170    virtual void Pad(const char * /*color*/ = "#FFFFFFFF", UInt_t /*left*/ = 0, 
00171                    UInt_t /*right*/ = 0, UInt_t /*top*/ = 0, UInt_t /*bottom*/ = 0) {}
00172 
00173    // Gaussian blurr. (See TASImage::Blur)
00174    virtual void Blur(Double_t /*horizontal*/ = 3, Double_t /*vertical*/ = 3) { }
00175    
00176    // Reduces colordepth of an image. (See TASImage::Vectorize)
00177    virtual Double_t *Vectorize(UInt_t /*max_colors*/ = 256, UInt_t /*dither*/ = 4, Int_t /*opaque_threshold*/ = 0) { return 0; }
00178 
00179    // (See TASImage::HSV)
00180    virtual void HSV(UInt_t /*hue*/ = 0, UInt_t /*radius*/ = 360, Int_t /*H*/ = 0, Int_t /*S*/ = 0, Int_t /*V*/ = 0, 
00181                     Int_t /*x*/ = 0, Int_t /*y*/ = 0, UInt_t /*width*/ = 0, UInt_t /*height*/ = 0) {}
00182 
00183    // Render multipoint gradient inside a rectangle. (See TASImage::Gradient)
00184    virtual void Gradient(UInt_t /*angle*/ = 0, const char * /*colors*/ = "#FFFFFF #000000", const char * /*offsets*/ = 0,
00185                          Int_t /*x*/ = 0, Int_t /*y*/ = 0, UInt_t /*width*/ = 0, UInt_t /*height*/ = 0) {}
00186 
00187    // Merge two images. (See TASImage::Merge)
00188    virtual void Merge(const TImage * /*im*/, const char * /*op*/ = "alphablend", Int_t /*x*/ = 0, Int_t /*y*/ = 0) {}
00189 
00190    // Append image. (See TASImage::Append)
00191    virtual void Append(const TImage * /*im*/, const char * /*option*/ = "+", const char * /*color*/ = "#00000000") {}
00192 
00193    // Bevel effect. (See TASImage::Bevel)
00194    virtual void Bevel(Int_t /*x*/ = 0, Int_t /*y*/ = 0, UInt_t /*width*/ = 0, UInt_t /*height*/ = 0,
00195                       const char * /*hi*/ = "#ffdddddd", const char * /*lo*/ = "#ff555555", 
00196                       UShort_t /*thick*/ = 1, Bool_t /*pressed*/ = kFALSE) {}
00197 
00198    virtual void BeginPaint(Bool_t /*fast*/ = kTRUE) {}
00199    virtual void EndPaint() {}
00200    virtual void DrawLine(UInt_t /*x1*/, UInt_t /*y1*/, UInt_t /*x2*/, UInt_t /*y2*/, 
00201                          const char * /*col*/ = "#000000", UInt_t /*thick*/ = 1) {}
00202    virtual void DrawDashLine(UInt_t /*x1*/, UInt_t /*y1*/, UInt_t /*x2*/, UInt_t /*y2*/, UInt_t /*nDash*/,
00203                              const char * /*pDash*/, const char * /*col*/ = "#000000", UInt_t /*thick*/ = 1) {}
00204    virtual void DrawBox(Int_t /*x1*/, Int_t /*y1*/, Int_t /*x2*/, Int_t /*y2*/, 
00205                          const char * /*col*/ = "#000000", UInt_t /*thick*/ = 1, Int_t /*mode*/ = 0) {}
00206    virtual void DrawRectangle(UInt_t /*x*/, UInt_t /*y*/, UInt_t /*w*/, UInt_t /*h*/, 
00207                               const char * /*col*/ = "#000000", UInt_t /*thick*/ = 1) {}
00208    virtual void FillRectangle(const char * /*col*/ = 0, Int_t /*x*/ = 0, Int_t /*y*/ = 0, 
00209                               UInt_t /*width*/ = 0, UInt_t /*height*/ = 0) {}
00210    virtual void DrawPolyLine(UInt_t /*nn*/, TPoint * /*xy*/, const char * /*col*/ = "#000000", 
00211                              UInt_t /*thick*/ = 1, TImage::ECoordMode /*mode*/ = kCoordModeOrigin) {}
00212    virtual void PutPixel(Int_t /*x*/, Int_t /*y*/, const char * /*col*/ = "#000000") {}
00213    virtual void PolyPoint(UInt_t /*npt*/, TPoint * /*ppt*/, const char * /*col*/ = "#000000", 
00214                           TImage::ECoordMode /*mode*/ = kCoordModeOrigin) {}
00215    virtual void DrawSegments(UInt_t /*nseg*/, Segment_t * /*seg*/, const char * /*col*/ = "#000000", UInt_t /*thick*/ = 1) {}
00216    virtual void DrawText(Int_t /*x*/ = 0, Int_t /*y*/ = 0, const char * /*text*/ = "", Int_t /*size*/ = 12, 
00217                          const char * /*color*/ = 0, const char * /*font*/ = "fixed",
00218                          EText3DType /*type*/ = TImage::kPlain, const char * /*fore_file*/ = 0, Float_t /*angle*/ = 0) { }
00219    virtual void DrawText(TText * /*text*/, Int_t /*x*/ = 0, Int_t /*y*/ = 0) { }
00220    virtual void FillPolygon(UInt_t /*npt*/, TPoint * /*ppt*/, const char * /*col*/ = "#000000",
00221                            const char * /*stipple*/ = 0, UInt_t /*w*/ = 16, UInt_t /*h*/ = 16) {}
00222    virtual void FillPolygon(UInt_t /*npt*/, TPoint * /*ppt*/, TImage * /*tile*/) {}
00223    virtual void CropPolygon(UInt_t /*npt*/, TPoint * /*ppt*/) {}
00224    virtual void DrawFillArea(UInt_t /*npt*/, TPoint * /*ppt*/, const char * /*col*/ = "#000000",
00225                            const char * /*stipple*/ = 0, UInt_t /*w*/ = 16, UInt_t /*h*/ = 16) {}
00226    virtual void DrawFillArea(UInt_t /*npt*/, TPoint * /*ppt*/, TImage * /*tile*/) {}
00227    virtual void FillSpans(UInt_t /*npt*/, TPoint * /*ppt*/, UInt_t * /*widths*/,  const char * /*col*/ = "#000000",
00228                          const char * /*stipple*/ = 0, UInt_t /*w*/ = 16, UInt_t /*h*/ = 16) {}
00229    virtual void FillSpans(UInt_t /*npt*/, TPoint * /*ppt*/, UInt_t * /*widths*/, TImage * /*tile*/) {}
00230    virtual void CropSpans(UInt_t /*npt*/, TPoint * /*ppt*/, UInt_t * /*widths*/) {}
00231    virtual void CopyArea(TImage * /*dst*/, Int_t /*xsrc*/, Int_t /*ysrc*/, UInt_t /*w*/, UInt_t /*h*/,
00232                          Int_t /*xdst*/ = 0, Int_t /*ydst*/ = 0, Int_t /*gfunc*/ = 3, EColorChan /*chan*/ = kAllChan) {}
00233    virtual void DrawCellArray(Int_t /*x1*/, Int_t /*y1*/, Int_t /*x2*/, Int_t /*y2*/, Int_t /*nx*/, Int_t /*ny*/, UInt_t * /*ic*/) {}
00234    virtual void FloodFill(Int_t /*x*/, Int_t /*y*/, const char * /*col*/, const char * /*min_col*/, const char * /*max_col*/ = 0) {}
00235    virtual void DrawCubeBezier(Int_t /*x1*/, Int_t /*y1*/, Int_t /*x2*/, Int_t /*y2*/, Int_t /*x3*/, Int_t /*y3*/, const char * /*col*/ = "#000000", UInt_t /*thick*/ = 1) {}
00236    virtual void DrawStraightEllips(Int_t /*x*/, Int_t /*y*/, Int_t /*rx*/, Int_t /*ry*/, const char * /*col*/ = "#000000", Int_t /*thick*/ = 1) {}
00237    virtual void DrawCircle(Int_t /*x*/, Int_t /*y*/, Int_t /*r*/, const char * /*col*/ = "#000000", Int_t /*thick*/ = 1) {}
00238    virtual void DrawEllips(Int_t /*x*/, Int_t /*y*/, Int_t /*rx*/, Int_t /*ry*/, Int_t /*angle*/, const char * /*col*/ = "#000000", Int_t /*thick*/ = 1) {}
00239    virtual void DrawEllips2(Int_t /*x*/, Int_t /*y*/, Int_t /*rx*/, Int_t /*ry*/, Int_t /*angle*/, const char * /*col*/ = "#000000", Int_t /*thick*/ = 1) {}
00240 
00241    virtual void SetEditable(Bool_t /*on*/ = kTRUE) {}
00242    virtual Bool_t IsEditable() const { return kFALSE; }
00243 
00244    virtual UInt_t GetWidth() const { return 0; }
00245    virtual UInt_t GetHeight() const { return 0; }
00246    virtual Bool_t IsValid() const { return kTRUE; }
00247    virtual TImage *GetScaledImage() const { return 0; }
00248 
00249    virtual TArrayL  *GetPixels(Int_t /*x*/= 0, Int_t /*y*/= 0, UInt_t /*w*/ = 0, UInt_t /*h*/ = 0) { return 0; }
00250    virtual TArrayD  *GetArray(UInt_t /*w*/ = 0, UInt_t /*h*/ = 0, TImagePalette * = gWebImagePalette) { return 0; }
00251    virtual Pixmap_t  GetPixmap() { return 0; }
00252    virtual Pixmap_t  GetMask() { return 0; }
00253    virtual UInt_t   *GetArgbArray() { return 0; }
00254    virtual UInt_t   *GetRgbaArray() { return 0; }
00255    virtual Double_t *GetVecArray() { return 0; }
00256    virtual UInt_t   *GetScanline(UInt_t /*y*/) { return 0; }
00257    virtual void      GetImageBuffer(char ** /*buffer*/, int* /*size*/, EImageFileTypes /*type*/ = TImage::kPng) {}
00258    virtual Bool_t    SetImageBuffer(char ** /*buffer*/, EImageFileTypes /*type*/ = TImage::kPng) { return kFALSE; }
00259    virtual void      PaintImage(Drawable_t /*wid*/, Int_t /*x*/, Int_t /*y*/, Int_t /*xsrc*/ = 0, Int_t /*ysrc*/ = 0, UInt_t /*wsrc*/ = 0, UInt_t /*hsrc*/ = 0, Option_t * /*opt*/ = "") { }
00260    virtual void      FromWindow(Drawable_t /*wid*/, Int_t /*x*/ = 0, Int_t /*y*/ = 0, UInt_t /*w*/ = 0, UInt_t /*h*/ = 0) {}
00261    virtual void      FromGLBuffer(UChar_t* /*buf*/, UInt_t /*w*/, UInt_t /*h*/) {}
00262    static EImageFileTypes GetImageFileTypeFromFilename(const char* opt);
00263 
00264    static TImage *Create();
00265    static TImage *Open(const char *file, EImageFileTypes type = kUnknown);
00266    static TImage *Open(char **data);
00267    static TImage *Open(const char *name, const Double_t *imageData, UInt_t width, UInt_t height, TImagePalette *palette);
00268    static TImage *Open(const char *name, const TArrayD &imageData, UInt_t width, TImagePalette *palette = 0);
00269    static TImage *Open(const char *name, const TVectorD &imageData, UInt_t width, TImagePalette *palette = 0);
00270 
00271    TImage    &operator+=(const TImage &i) { Append(&i, "+"); return *this; }
00272    TImage    &operator/=(const TImage &i) { Append(&i, "/"); return *this; }
00273 
00274    ClassDef(TImage,1)  // Abstract image class
00275 };
00276 
00277 
00278 #endif

Generated on Tue Jul 5 14:14:09 2011 for ROOT_528-00b_version by  doxygen 1.5.1