Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TImage.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/graf:$Id$
0002 // Author: Fons Rademakers, Reiner Rohlfs   15/10/2001
0003 
0004 /*************************************************************************
0005  * Copyright (C) 2001-2001, Rene Brun, Fons Rademakers and Reiner Rohlfs *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TImage
0013 #define ROOT_TImage
0014 
0015 
0016 #include "TNamed.h"
0017 
0018 #include "TAttImage.h"
0019 #include "GuiTypes.h"
0020 #include "TVectorDfwd.h"
0021 
0022 class TVirtualPad;
0023 class TArrayD;
0024 class TArrayL;
0025 class TH2D;
0026 class TPoint;
0027 class TText;
0028 
0029 class TImage : public TNamed, public TAttImage {
0030 
0031 friend TImage operator+(const TImage &i1, const TImage &s2);
0032 friend TImage operator/(const TImage &i1, const TImage &s2);
0033 
0034 public:
0035    // Defines image file types
0036    enum EImageFileTypes {
0037       kXpm = 0,
0038       kZCompressedXpm,
0039       kGZCompressedXpm,
0040       kPng,
0041       kJpeg,
0042       kXcf,
0043       kPpm,
0044       kPnm,
0045       kBmp,
0046       kIco,
0047       kCur,
0048       kGif,
0049       kTiff,
0050       kXbm,
0051       kFits,
0052       kTga,
0053       kXml,
0054       kUnknown,
0055       kAnimGif
0056    };
0057 
0058    enum EText3DType {
0059       kPlain = 0,  // regular 2D text
0060       kEmbossed,
0061       kSunken,
0062       kShadeAbove,
0063       kShadeBelow,
0064       kEmbossedThick,
0065       kSunkenThick,
0066       kOutlineAbove,
0067       kOutlineBelow,
0068       kOutlineFull,
0069       k3DTypes
0070    };
0071 
0072    enum ECharType {
0073       kUTF8 = 0,
0074       kChar = 1,
0075       kUnicode = 4
0076    };
0077 
0078    enum ETileType {
0079       kStretch = 0,
0080       kTile,
0081       kStretchY,
0082       kStretchX
0083    };
0084 
0085    enum ECoordMode {
0086       kCoordModeOrigin = 0,
0087       kCoordModePrevious
0088    };
0089 
0090    enum EColorChan {
0091       kRedChan   = BIT(0),
0092       kGreenChan = BIT(1),
0093       kBlueChan  = BIT(2),
0094       kAlphaChan = BIT(3),
0095       kAllChan   = kRedChan | kGreenChan | kBlueChan | kAlphaChan
0096    };
0097 
0098 protected:
0099    TImage(const char *file) : TNamed(file, "") { }
0100    TImage() { }
0101 
0102 public:
0103    TImage(const TImage &img) : TNamed(img), TAttImage(img) { }
0104    TImage &operator=(const TImage &img)
0105             { TNamed::operator=(img); TAttImage::operator=(img); return *this; }
0106    TImage(UInt_t /*w*/, UInt_t /*h*/) : TNamed(), TAttImage() { }
0107 
0108    ~TImage() override { }
0109 
0110    // Cloning
0111            TObject *Clone(const char *) const override { return nullptr; }
0112 
0113    // Input / output
0114    virtual void ReadImage(const char * /*file*/, EImageFileTypes /*type*/ = TImage::kUnknown) {}
0115    virtual void WriteImage(const char * /*file*/, EImageFileTypes /*type*/ = TImage::kUnknown)  {}
0116    virtual void SetImage(const Double_t * /*imageData*/, UInt_t /*width*/, UInt_t /*height*/, TImagePalette * /*palette*/ = nullptr) {}
0117    virtual void SetImage(const TArrayD & /*imageData*/, UInt_t /*width*/, TImagePalette * /*palette*/ = nullptr) {}
0118    virtual void SetImage(const TVectorD & /*imageData*/, UInt_t /*width*/, TImagePalette * /*palette*/ = nullptr) {}
0119    virtual void SetImage(Pixmap_t /*pxm*/, Pixmap_t /*mask*/ = 0) {}
0120 
0121    // Create an image from the given pad. (See TASImage::FromPad)
0122    virtual void FromPad(TVirtualPad * /*pad*/, Int_t /*x*/ = 0, Int_t /*y*/ = 0, UInt_t /*w*/ = 0, UInt_t /*h*/ = 0) {}
0123 
0124    // Restore the image original size. (See TASImage::UnZoom)
0125    virtual void UnZoom() {}
0126 
0127    // Zoom the image. (See TASImage::Zoom)
0128    virtual void Zoom(UInt_t /*offX*/, UInt_t /*offY*/, UInt_t /*width*/, UInt_t /*height*/) {}
0129 
0130    // Flip the image by a multiple of 90 degrees. (See TASImage::Flip)
0131    virtual void Flip(Int_t /*flip*/ = 180) {}
0132 
0133    // Converts image to Gray. (See TASImage::Gray)
0134    virtual void Gray(Bool_t /*on*/ = kTRUE) {}
0135    virtual Bool_t IsGray() const { return kFALSE; }
0136 
0137    // Mirror the image. (See TASImage::Mirror)
0138    virtual void Mirror(Bool_t /*vert*/ = kTRUE) {}
0139 
0140    // Scale the image. (See TASImage::Scale)
0141    virtual void Scale(UInt_t /*width*/, UInt_t /*height*/) {}
0142 
0143    // Slice the image. (See TASImage::Slice)
0144    virtual void Slice(UInt_t /*xStart*/, UInt_t /*xEnd*/, UInt_t /*yStart*/,  UInt_t /*yEnd*/,
0145                       UInt_t /*toWidth*/, UInt_t /*toHeight*/) {}
0146 
0147    // Tile the image. (See TASImage::Tile)
0148    virtual void Tile(UInt_t /*width*/, UInt_t /*height*/) {}
0149 
0150    // Crop the image. (See TASImage::Crop)
0151    virtual void Crop(Int_t /*x*/ = 0, Int_t /*y*/ = 0, UInt_t /*width*/ = 0, UInt_t /*height*/ = 0) {}
0152 
0153    // Enlarge image. (See TASImage::Pad)
0154    virtual void Pad(const char * /*color*/ = "#FFFFFFFF", UInt_t /*left*/ = 0,
0155                    UInt_t /*right*/ = 0, UInt_t /*top*/ = 0, UInt_t /*bottom*/ = 0) {}
0156 
0157    // Gaussian blurr. (See TASImage::Blur)
0158    virtual void Blur(Double_t /*horizontal*/ = 3, Double_t /*vertical*/ = 3) { }
0159 
0160    // Reduces colordepth of an image. (See TASImage::Vectorize)
0161    virtual Double_t *Vectorize(UInt_t /*max_colors*/ = 256, UInt_t /*dither*/ = 4, Int_t /*opaque_threshold*/ = 0) { return nullptr; }
0162 
0163    // (See TASImage::HSV)
0164    virtual void HSV(UInt_t /*hue*/ = 0, UInt_t /*radius*/ = 360, Int_t /*H*/ = 0, Int_t /*S*/ = 0, Int_t /*V*/ = 0,
0165                     Int_t /*x*/ = 0, Int_t /*y*/ = 0, UInt_t /*width*/ = 0, UInt_t /*height*/ = 0) {}
0166 
0167    // Render multipoint gradient inside a rectangle. (See TASImage::Gradient)
0168    virtual void Gradient(UInt_t /*angle*/ = 0, const char * /*colors*/ = "#FFFFFF #000000", const char * /*offsets*/ = nullptr,
0169                          Int_t /*x*/ = 0, Int_t /*y*/ = 0, UInt_t /*width*/ = 0, UInt_t /*height*/ = 0) {}
0170 
0171    // Merge two images. (See TASImage::Merge)
0172    virtual void Merge(const TImage * /*im*/, const char * /*op*/ = "alphablend", Int_t /*x*/ = 0, Int_t /*y*/ = 0) {}
0173 
0174    // Append image. (See TASImage::Append)
0175    virtual void Append(const TImage * /*im*/, const char * /*option*/ = "+", const char * /*color*/ = "#00000000") {}
0176 
0177    // Bevel effect. (See TASImage::Bevel)
0178    virtual void Bevel(Int_t /*x*/ = 0, Int_t /*y*/ = 0, UInt_t /*width*/ = 0, UInt_t /*height*/ = 0,
0179                       const char * /*hi*/ = "#ffdddddd", const char * /*lo*/ = "#ff555555",
0180                       UShort_t /*thick*/ = 1, Bool_t /*pressed*/ = kFALSE) {}
0181 
0182    virtual void BeginPaint(Bool_t /*fast*/ = kTRUE) {}
0183    virtual void EndPaint() {}
0184    virtual void DrawLine(UInt_t /*x1*/, UInt_t /*y1*/, UInt_t /*x2*/, UInt_t /*y2*/,
0185                          const char * /*col*/ = "#000000", UInt_t /*thick*/ = 1) {}
0186    virtual void DrawDashLine(UInt_t /*x1*/, UInt_t /*y1*/, UInt_t /*x2*/, UInt_t /*y2*/, UInt_t /*nDash*/,
0187                              const char * /*pDash*/, const char * /*col*/ = "#000000", UInt_t /*thick*/ = 1) {}
0188    virtual void DrawBox(Int_t /*x1*/, Int_t /*y1*/, Int_t /*x2*/, Int_t /*y2*/,
0189                          const char * /*col*/ = "#000000", UInt_t /*thick*/ = 1, Int_t /*mode*/ = 0) {}
0190    virtual void DrawRectangle(UInt_t /*x*/, UInt_t /*y*/, UInt_t /*w*/, UInt_t /*h*/,
0191                               const char * /*col*/ = "#000000", UInt_t /*thick*/ = 1) {}
0192    virtual void FillRectangle(const char * /*col*/ = nullptr, Int_t /*x*/ = 0, Int_t /*y*/ = 0,
0193                               UInt_t /*width*/ = 0, UInt_t /*height*/ = 0) {}
0194    virtual void DrawPolyLine(UInt_t /*nn*/, TPoint * /*xy*/, const char * /*col*/ = "#000000",
0195                              UInt_t /*thick*/ = 1, TImage::ECoordMode /*mode*/ = kCoordModeOrigin) {}
0196    virtual void PutPixel(Int_t /*x*/, Int_t /*y*/, const char * /*col*/ = "#000000") {}
0197    virtual void PolyPoint(UInt_t /*npt*/, TPoint * /*ppt*/, const char * /*col*/ = "#000000",
0198                           TImage::ECoordMode /*mode*/ = kCoordModeOrigin) {}
0199    virtual void DrawSegments(UInt_t /*nseg*/, Segment_t * /*seg*/, const char * /*col*/ = "#000000", UInt_t /*thick*/ = 1) {}
0200    virtual void DrawText(Int_t /*x*/ = 0, Int_t /*y*/ = 0, const char * /*text*/ = "", Int_t /*size*/ = 12,
0201                          const char * /*color*/ = nullptr, const char * /*font*/ = "fixed",
0202                          EText3DType /*type*/ = TImage::kPlain, const char * /*fore_file*/ = nullptr, Float_t /*angle*/ = 0) { }
0203    virtual void DrawText(TText * /*text*/, Int_t /*x*/ = 0, Int_t /*y*/ = 0) { }
0204    virtual void FillPolygon(UInt_t /*npt*/, TPoint * /*ppt*/, const char * /*col*/ = "#000000",
0205                            const char * /*stipple*/ = nullptr, UInt_t /*w*/ = 16, UInt_t /*h*/ = 16) {}
0206    virtual void FillPolygon(UInt_t /*npt*/, TPoint * /*ppt*/, TImage * /*tile*/) {}
0207    virtual void CropPolygon(UInt_t /*npt*/, TPoint * /*ppt*/) {}
0208    virtual void DrawFillArea(UInt_t /*npt*/, TPoint * /*ppt*/, const char * /*col*/ = "#000000",
0209                            const char * /*stipple*/ = nullptr, UInt_t /*w*/ = 16, UInt_t /*h*/ = 16) {}
0210    virtual void DrawFillArea(UInt_t /*npt*/, TPoint * /*ppt*/, TImage * /*tile*/) {}
0211    virtual void FillSpans(UInt_t /*npt*/, TPoint * /*ppt*/, UInt_t * /*widths*/,  const char * /*col*/ = "#000000",
0212                          const char * /*stipple*/ = nullptr, UInt_t /*w*/ = 16, UInt_t /*h*/ = 16) {}
0213    virtual void FillSpans(UInt_t /*npt*/, TPoint * /*ppt*/, UInt_t * /*widths*/, TImage * /*tile*/) {}
0214    virtual void CropSpans(UInt_t /*npt*/, TPoint * /*ppt*/, UInt_t * /*widths*/) {}
0215    virtual void CopyArea(TImage * /*dst*/, Int_t /*xsrc*/, Int_t /*ysrc*/, UInt_t /*w*/, UInt_t /*h*/,
0216                          Int_t /*xdst*/ = 0, Int_t /*ydst*/ = 0, Int_t /*gfunc*/ = 3, EColorChan /*chan*/ = kAllChan) {}
0217    virtual void DrawCellArray(Int_t /*x1*/, Int_t /*y1*/, Int_t /*x2*/, Int_t /*y2*/, Int_t /*nx*/, Int_t /*ny*/, UInt_t * /*ic*/) {}
0218    virtual void FloodFill(Int_t /*x*/, Int_t /*y*/, const char * /*col*/, const char * /*min_col*/, const char * /*max_col*/ = nullptr) {}
0219    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) {}
0220    virtual void DrawStraightEllips(Int_t /*x*/, Int_t /*y*/, Int_t /*rx*/, Int_t /*ry*/, const char * /*col*/ = "#000000", Int_t /*thick*/ = 1) {}
0221    virtual void DrawCircle(Int_t /*x*/, Int_t /*y*/, Int_t /*r*/, const char * /*col*/ = "#000000", Int_t /*thick*/ = 1) {}
0222    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) {}
0223    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) {}
0224 
0225    virtual void SetEditable(Bool_t /*on*/ = kTRUE) {}
0226    virtual Bool_t IsEditable() const { return kFALSE; }
0227 
0228    virtual UInt_t GetWidth() const { return 0; }
0229    virtual UInt_t GetHeight() const { return 0; }
0230    virtual Bool_t IsValid() const { return kTRUE; }
0231    virtual TImage *GetScaledImage() const { return nullptr; }
0232 
0233    virtual TArrayL  *GetPixels(Int_t /*x*/= 0, Int_t /*y*/= 0, UInt_t /*w*/ = 0, UInt_t /*h*/ = 0) { return nullptr; }
0234    virtual TArrayD  *GetArray(UInt_t /*w*/ = 0, UInt_t /*h*/ = 0, TImagePalette * = gWebImagePalette) { return nullptr; }
0235    virtual Pixmap_t  GetPixmap() { return 0; }
0236    virtual Pixmap_t  GetMask() { return 0; }
0237    virtual UInt_t   *GetArgbArray() { return nullptr; }
0238    virtual UInt_t   *GetRgbaArray() { return nullptr; }
0239    virtual Double_t *GetVecArray() { return nullptr; }
0240    virtual UInt_t   *GetScanline(UInt_t /*y*/) { return nullptr; }
0241    virtual void      GetImageBuffer(char ** /*buffer*/, int* /*size*/, EImageFileTypes /*type*/ = TImage::kPng) {}
0242    virtual Bool_t    SetImageBuffer(char ** /*buffer*/, EImageFileTypes /*type*/ = TImage::kPng) { return kFALSE; }
0243    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*/ = "") { }
0244    virtual void      FromWindow(Drawable_t /*wid*/, Int_t /*x*/ = 0, Int_t /*y*/ = 0, UInt_t /*w*/ = 0, UInt_t /*h*/ = 0) {}
0245    virtual void      FromGLBuffer(UChar_t* /*buf*/, UInt_t /*w*/, UInt_t /*h*/) {}
0246    static EImageFileTypes GetImageFileTypeFromFilename(const char* opt);
0247 
0248    static TImage *Create();
0249    static TImage *Open(const char *file, EImageFileTypes type = kUnknown);
0250    static TImage *Open(char **data);
0251    static TImage *Open(const char *name, const Double_t *imageData, UInt_t width, UInt_t height, TImagePalette *palette);
0252    static TImage *Open(const char *name, const TArrayD &imageData, UInt_t width, TImagePalette *palette = nullptr);
0253    static TImage *Open(const char *name, const TVectorD &imageData, UInt_t width, TImagePalette *palette = nullptr);
0254 
0255    TImage    &operator+=(const TImage &i) { Append(&i, "+"); return *this; }
0256    TImage    &operator/=(const TImage &i) { Append(&i, "/"); return *this; }
0257 
0258            void  ls(Option_t *option="") const override;
0259 
0260    ClassDefOverride(TImage,1)  // Abstract image class
0261 };
0262 
0263 
0264 #endif