ROOT logo
// @(#)root/graf:$Id$
// Author: Reiner Rohlfs   24/03/02

/*************************************************************************
 * Copyright (C) 2001-2002, Rene Brun, Fons Rademakers and Reiner Rohlfs *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TAttImage
#define ROOT_TAttImage


//////////////////////////////////////////////////////////////////////////
//                                                                      //
//  TAttImage                                                           //
//                                                                      //
//  Image attributes are:                                               //
//    Image Quality (see EImageQuality for the list of qualities)       //
//    Compression defines the compression rate of the color data in the //
//                internal image structure. Speed and memory depends    //
//                on this rate, but not the image display itself        //
//                0: no compression;  100: max compression              //
//    Radio Flag: kTRUE  the x/y radio of the displayed image is always //
//                       identical to the original image                //
//                kFALSE the x and y size of the displayed image depends//
//                       on the size of the pad                         //
//    Palette:    Defines the conversion from a pixel value to the      //
//                screen color                                          //
//                                                                      //
//  This class is used (in general by secondary inheritance)            //
//  by some other classes (image display).                              //
//                                                                      //
//                                                                      //
//  TImagePalette                                                       //
//                                                                      //
//  A class to define a conversion from pixel values to pixel color.    //
//  A Palette is defined by some anchor points. Each anchor point has   //
//  a value between 0 and 1 and a color. An image has to be normalized  //
//  and the values between the anchor points are interpolated.          //
//  All member variables are public and can be directly manipulated.    //
//  In most cases the default operator will be used to create a         //
//  TImagePalette. In this case the member arrays have to be allocated  //
//  by an application and will be deleted in the destructor of this     //
//  class.                                                              //
//                                                                      //
//                                                                      //
//  TPaletteEditor                                                      //
//                                                                      //
//  This class provides a way to edit the palette via a GUI.            //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TObject
#include "TObject.h"
#endif

#ifndef ROOT_Riosfwd
#include "Riosfwd.h"
#endif

class TAttImage;


class TPaletteEditor {

protected:
   TAttImage    *fAttImage;    // image attributes to be edited

public:
   TPaletteEditor(TAttImage *attImage, UInt_t w, UInt_t h);
   virtual ~TPaletteEditor() { }

   virtual void CloseWindow();

   ClassDef(TPaletteEditor, 0)  // Base class for palette editor
};



class TImagePalette : public TObject {

public:
   UInt_t      fNumPoints;   // number of anchor points
   Double_t   *fPoints;      // [fNumPoints] value of each anchor point [0..1]
   UShort_t   *fColorRed;    // [fNumPoints] red color at each anchor point
   UShort_t   *fColorGreen;  // [fNumPoints] green color at each anchor point
   UShort_t   *fColorBlue;   // [fNumPoints] blue color at each anchor point
   UShort_t   *fColorAlpha;  // [fNumPoints] alpha at each anchor point

   TImagePalette();
   TImagePalette(const TImagePalette &palette);
   TImagePalette(UInt_t numPoints);
   TImagePalette(Int_t ncolors, Int_t *colors);
   virtual ~TImagePalette();
   virtual Int_t FindColor(UShort_t r, UShort_t g, UShort_t b);
   virtual Int_t *GetRootColors();

   TImagePalette &operator=(const TImagePalette &palette);

   ClassDef(TImagePalette,1)  // Color Palette for value -> color conversion
};



class TAttImage {

public:
   // Defines level of output quality/speed ratio
   enum EImageQuality {
      kImgDefault = -1,
      kImgPoor    = 0,
      kImgFast    = 1,
      kImgGood    = 2,
      kImgBest    = 3
   };

protected:
   EImageQuality    fImageQuality;       // *OPTION={GetMethod="GetImageQuality";SetMethod="SetImageQuality";Items=(kImgDefault="Default",kImgPoor="Poor",kImgFast="Fast",kImgGood="Good",kImgBest="Best")}*
   UInt_t           fImageCompression;   // compression [0 .. 100] 0: no compression
   Bool_t           fConstRatio;         // keep aspect ratio of image on the screen
   TImagePalette    fPalette;            // color palette for value -> color conversion
   TPaletteEditor  *fPaletteEditor;      //! GUI to edit the color palette
   Bool_t           fPaletteEnabled;     //! kTRUE - palette is drawn on the image

public:
   TAttImage();
   TAttImage(EImageQuality lquality, UInt_t lcompression, Bool_t constRatio);
   virtual ~TAttImage();

   void             Copy(TAttImage &attline) const;
   Bool_t           GetConstRatio() const { return fConstRatio; }
   UInt_t           GetImageCompression() const { return fImageCompression; }
   EImageQuality    GetImageQuality() const { return fImageQuality; }
   virtual const TImagePalette &GetPalette() const { return fPalette; }

   virtual void     ResetAttImage(Option_t *option="");
   virtual void     SaveImageAttributes(ostream &out, const char *name,
                                        EImageQuality qualdef = kImgDefault,
                                        UInt_t comprdef = 0,
                                        Bool_t constRatiodef = kTRUE);
   virtual void     SetConstRatio(Bool_t constRatio = kTRUE); // *TOGGLE*
   virtual void     SetPaletteEnabled(Bool_t on = kTRUE) {  fPaletteEnabled = on; }
   virtual void     SetImageCompression(UInt_t lcompression)
                     { fImageCompression = (lcompression > 100) ? 100 : lcompression; } // *MENU*
   virtual void     SetImageQuality(EImageQuality lquality)
                     { fImageQuality = lquality;} // *SUBMENU*
   virtual void     SetPalette(const TImagePalette *palette);
   virtual void     StartPaletteEditor(); // *MENU*
   virtual void     EditorClosed() { fPaletteEditor = 0; }
   Bool_t           IsPaletteEnabled() const { return fPaletteEnabled; }

   ClassDef(TAttImage,1)  //Image attributes
};


R__EXTERN TImagePalette  *gHistImagePalette;    // palette used in TH2::Draw("col")
R__EXTERN TImagePalette  *gWebImagePalette;     // 6x6x6 colors web palette



#endif
 TAttImage.h:1
 TAttImage.h:2
 TAttImage.h:3
 TAttImage.h:4
 TAttImage.h:5
 TAttImage.h:6
 TAttImage.h:7
 TAttImage.h:8
 TAttImage.h:9
 TAttImage.h:10
 TAttImage.h:11
 TAttImage.h:12
 TAttImage.h:13
 TAttImage.h:14
 TAttImage.h:15
 TAttImage.h:16
 TAttImage.h:17
 TAttImage.h:18
 TAttImage.h:19
 TAttImage.h:20
 TAttImage.h:21
 TAttImage.h:22
 TAttImage.h:23
 TAttImage.h:24
 TAttImage.h:25
 TAttImage.h:26
 TAttImage.h:27
 TAttImage.h:28
 TAttImage.h:29
 TAttImage.h:30
 TAttImage.h:31
 TAttImage.h:32
 TAttImage.h:33
 TAttImage.h:34
 TAttImage.h:35
 TAttImage.h:36
 TAttImage.h:37
 TAttImage.h:38
 TAttImage.h:39
 TAttImage.h:40
 TAttImage.h:41
 TAttImage.h:42
 TAttImage.h:43
 TAttImage.h:44
 TAttImage.h:45
 TAttImage.h:46
 TAttImage.h:47
 TAttImage.h:48
 TAttImage.h:49
 TAttImage.h:50
 TAttImage.h:51
 TAttImage.h:52
 TAttImage.h:53
 TAttImage.h:54
 TAttImage.h:55
 TAttImage.h:56
 TAttImage.h:57
 TAttImage.h:58
 TAttImage.h:59
 TAttImage.h:60
 TAttImage.h:61
 TAttImage.h:62
 TAttImage.h:63
 TAttImage.h:64
 TAttImage.h:65
 TAttImage.h:66
 TAttImage.h:67
 TAttImage.h:68
 TAttImage.h:69
 TAttImage.h:70
 TAttImage.h:71
 TAttImage.h:72
 TAttImage.h:73
 TAttImage.h:74
 TAttImage.h:75
 TAttImage.h:76
 TAttImage.h:77
 TAttImage.h:78
 TAttImage.h:79
 TAttImage.h:80
 TAttImage.h:81
 TAttImage.h:82
 TAttImage.h:83
 TAttImage.h:84
 TAttImage.h:85
 TAttImage.h:86
 TAttImage.h:87
 TAttImage.h:88
 TAttImage.h:89
 TAttImage.h:90
 TAttImage.h:91
 TAttImage.h:92
 TAttImage.h:93
 TAttImage.h:94
 TAttImage.h:95
 TAttImage.h:96
 TAttImage.h:97
 TAttImage.h:98
 TAttImage.h:99
 TAttImage.h:100
 TAttImage.h:101
 TAttImage.h:102
 TAttImage.h:103
 TAttImage.h:104
 TAttImage.h:105
 TAttImage.h:106
 TAttImage.h:107
 TAttImage.h:108
 TAttImage.h:109
 TAttImage.h:110
 TAttImage.h:111
 TAttImage.h:112
 TAttImage.h:113
 TAttImage.h:114
 TAttImage.h:115
 TAttImage.h:116
 TAttImage.h:117
 TAttImage.h:118
 TAttImage.h:119
 TAttImage.h:120
 TAttImage.h:121
 TAttImage.h:122
 TAttImage.h:123
 TAttImage.h:124
 TAttImage.h:125
 TAttImage.h:126
 TAttImage.h:127
 TAttImage.h:128
 TAttImage.h:129
 TAttImage.h:130
 TAttImage.h:131
 TAttImage.h:132
 TAttImage.h:133
 TAttImage.h:134
 TAttImage.h:135
 TAttImage.h:136
 TAttImage.h:137
 TAttImage.h:138
 TAttImage.h:139
 TAttImage.h:140
 TAttImage.h:141
 TAttImage.h:142
 TAttImage.h:143
 TAttImage.h:144
 TAttImage.h:145
 TAttImage.h:146
 TAttImage.h:147
 TAttImage.h:148
 TAttImage.h:149
 TAttImage.h:150
 TAttImage.h:151
 TAttImage.h:152
 TAttImage.h:153
 TAttImage.h:154
 TAttImage.h:155
 TAttImage.h:156
 TAttImage.h:157
 TAttImage.h:158
 TAttImage.h:159
 TAttImage.h:160
 TAttImage.h:161
 TAttImage.h:162
 TAttImage.h:163
 TAttImage.h:164