library: libASImage #include "TASImage.h"

# TASImage

class description - source file - inheritance tree (.ps)

## class TASImage : public TImage

| Inheritance Chart:

`TObject`

<-

`TNamed`

`TAttImage`

<-

`TImage`

<-

`TASImage`

        protected:

          TImage::EImageFileTypes GetFileType(const char* ext)
                    static Bool_t InitVisual()
                             void MapFileTypes(TImage::EImageFileTypes& type, UInt_t& astype, Bool_t toas = kTRUE)
                             void MapQuality(TAttImage::EImageQuality& quality, UInt_t& asquality, Bool_t toas = kTRUE)

        public:

                                 TASImage()
                                 TASImage(const char* file, TImage::EImageFileTypes type = kUnknown)
                                 TASImage(const char* name, const Double_t* imageData, UInt_t width, UInt_t height, TImagePalette* palette = 0)
                                 TASImage(const char* name, const TArrayD& imageData, UInt_t width, TImagePalette* palette = 0)
                                 TASImage(const char* name, const TVectorD& imageData, UInt_t width, TImagePalette* palette = 0)
                                 TASImage(const TASImage& img)
                         virtual ~TASImage()
                  static TClass* Class()
                   virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
                    virtual void Draw(Option_t* option)
                    virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
                    virtual void Flip(Int_t flip = 180)
                    virtual void FromPad(TVirtualPad* pad, Int_t x = 0, Int_t y = 0, UInt_t w = 0, UInt_t h = 0)
                  virtual UInt_t GetHeight() const
                  const ASImage* GetImage() const
                   virtual char* GetObjectInfo(Int_t px, Int_t py) const
                          UInt_t GetScaledHeight() const
                          UInt_t GetScaledWidth() const
          static const ASVisual* GetVisual() const
                  virtual UInt_t GetWidth() const
                 virtual TClass* IsA() const
                  virtual Bool_t IsValid() const
                    virtual void Mirror(Bool_t vert = kTRUE)
                       TASImage& operator=(const TASImage& img)
                    virtual void Paint(Option_t* option)
                    virtual void ReadImage(const char* file, TImage::EImageFileTypes type = kUnknown)
                    virtual void Scale(UInt_t toWidth, UInt_t toHeight)
                    virtual void SetImage(const Double_t* imageData, UInt_t width, UInt_t height, TImagePalette* palette = 0)
                    virtual void SetImage(const TArrayD& imageData, UInt_t width, TImagePalette* palette = 0)
                    virtual void SetImage(const TVectorD& imageData, UInt_t width, TImagePalette* palette = 0)
                    virtual void SetPalette(const TImagePalette* palette)
                    virtual void ShowMembers(TMemberInspector& insp, char* parent)
                    virtual void StartPaletteEditor()
                    virtual void Streamer(TBuffer& b)
                            void StreamerNVirtual(TBuffer& b)
                    virtual void UnZoom()
                    virtual void WriteImage(const char* file, TImage::EImageFileTypes type = kUnknown)
                    virtual void Zoom(UInt_t offX, UInt_t offY, UInt_t width, UInt_t height)

### Data Members

        protected:

                  ASImage* fImage        ! pointer to image structure of original image
                  ASImage* fScaledImage  ! pointer to scaled and zoomed image structure
                  Double_t fMaxValue     max value in image
                  Double_t fMinValue     min value in image
                    UInt_t fZoomOffX     X - offset for zooming in image pixels
                    UInt_t fZoomOffY     Y - offset for zooming im image pixels
                    UInt_t fZoomWidth    width of zoomed image in image pixels
                    UInt_t fZoomHeight   hight of zoomed image in image pixels
                    Bool_t fZoomUpdate   kTRUE: new zooming required
          static ASVisual* fgVisual      pointer to visual structure
             static Bool_t fgInit        global flag to init afterimage only once

## Class Description

     TASImage

     Interface to image processing library using libAfterImage.
     It allows for the reading and writing of images in different
     formats, several image manipulations (scaling, tiling, merging,
     etc.) and displaying in pads.
     The size of the image on the screen does not depend on the original
     size of the image but on the size of the pad. Therefore it is very
     easy to resize the image on the screen by resizing the pad.

     Besides reading an image from a file an image can be defined by a
     two dimensional array of values. A palette defines the color of
     each value.

     The image can be zoomed by defining a rectangle with the mouse.
     The color palette can be modified with a GUI, just select
     StartPaletteEditor() from the context menu.

TASImage()

     Default image ctor.

TASImage(const char *file, EImageFileTypes) : TImage(file)

     Create an image object and read from specified file.
     For more information see description of function ReadImage()
     which is called by this constructor.

TASImage(const char *name, const Double_t *imageData, UInt_t width, UInt_t height, TImagePalette *palette) : TImage(name)

     Creates an image depending on the values of imageData.
     For more information see function SetImage() which is called
     by this constructor.

TASImage(const char *name, const TArrayD &imageData, UInt_t width, TImagePalette *palette) : TImage(name)

     Creates an image depending on the values of imageData. The size
     of the image is width X (imageData.fN / width).
     For more information see function SetImage() which is called by
     this constructor.

TASImage(const char *name, const TVectorD &imageData, UInt_t width, TImagePalette *palette) : TImage(name)

     Creates an image depending on the values of imageData. The size
     of the image is width X (imageData.fN / width).
     For more information see function SetImage() which is called by
     this constructor.

TASImage(const TASImage &img) : TImage(img)

     Image copy ctor.

~TASImage()

     Image dtor, clean up image and visual.

void ReadImage(const char *file, EImageFileTypes /*type*/)

     Read specified image file. The file type is determined by
     the file extension (the type argument is ignored). It will
     attempt to append .gz and then .Z to the filename and find such
     a file. If the filename ends with extension consisting of digits
     only, it will attempt to find the file with this extension stripped
     off. On success this extension will be used to load subimage from
     the file with that number. Subimage is supported only for GIF files.

void WriteImage(const char *file, EImageFileTypes type)

     Write image to specified file. If there is no file extension or
     if the file extension is unknown, the type argument will be used
     to determine the file type. The quality and compression is derived from
     the TAttImage values.
     The size of the image in the file is independent of the actually
     displayed size and zooming factor on the screen. This function
     writes always the original image with its size in the file

TImage::EImageFileTypes GetFileType(const char *ext)

     Return file type depending on specified extension.
     Protected method.

void MapFileTypes(EImageFileTypes &type, UInt_t &astype, Bool_t toas)

     Map file type to/from AfterImage types.
     Protected method.

void MapQuality(EImageQuality &quality, UInt_t &asquality, Bool_t toas)

     Map quality to/from AfterImage quality.
     Protected method.

void SetImage(const Double_t *imageData, UInt_t width, UInt_t height, TImagePalette *palette)

     Deletes the old image and creates a new image depending on the values
     of imageData. The size of the image is width X height.
     The color of each pixel depends on the imageData of the corresponding
     pixel. The palette is used to convert an image value into its color.
     If palette is not defined (palette = 0) a default palette is used.
     Any previously defined zooming is reset.

void SetImage(const TArrayD &imageData, UInt_t width, TImagePalette *palette)

     Deletes the old image and creates a new image depending on the values
     of imageData. The size of the image is width X (imageData.fN / width).
     The color of each pixel depends on the imageData of the corresponding
     pixel. The palette is used to convert an image value into its color.
     If palette is not defined (palette = 0) a default palette is used.
     Any previously defined zooming is reset.

void SetImage(const TVectorD &imageData, UInt_t width, TImagePalette *palette)

     Deletes the old image and creates a new image depending on the values
     of imageData. The size of the image is width X (imageData.fN / width).
     The color of each pixel depends on the imageData of the corresponding
     pixel. The palette is used to convert an image value into its color.
     If palette is not defined (palette = 0) a default palette is used.
     Any previously defined zooming is reset.

void FromPad(TVirtualPad *pad, Int_t x, Int_t y, UInt_t w, UInt_t h)

     Create an image from the given pad, afterwards this image can be
     saved in any of the supported image formats.

void Draw(Option_t *option)

     Draw image. Support the following drawing options:
     "T[x,y[,tint]]" - tile image (use specified offset and tint),
                       e.g. "T100,100,#556655"
                       with this option the zooming is not possible
                       and disabled
     "N"             - display in new canvas (of original image size)
     The default is to display the image in the current gPad.

void Paint(Option_t *option)

     Paint image in current pad. See Draw() function for drawing options.

Int_t DistancetoPrimitive(Int_t px, Int_t py)

     Is the mouse in the image?

void ExecuteEvent(Int_t event, Int_t px, Int_t py)

     Execute mouse events.

char* GetObjectInfo(Int_t px, Int_t py) const

     Get image pixel coordinates and the pixel value at the mouse pointer.

void SetPalette(const TImagePalette *palette)

     Set a new palette to an image. Only images that were created with the
     SetImage() functions can be modified with this function.
     The previously used palette is destroyed.

void Scale(UInt_t toWidth, UInt_t toHeight)

     Scales the original image. The size of the image on the screen does not
     change because it is defined by the size of the pad.
     This function can be used to change the size of an image before writing
     it into a file. The colors of the new pixels are interpolated.
     An image created with the SetImage() functions cannot be modified with
     the function SetPalette() any more after a call of this function!

void Zoom(UInt_t offX, UInt_t offY, UInt_t width, UInt_t height)

     The area of an image displayed in a pad is defined by this function.
     Note: the size on the screen is defined by the size of the pad.
     The original image is not modified by this function.
     If width or height is larger than the original image they are reduced to
     the width and height of the image.
     If the off values are too large (off + width > image width) than the off
     values are decreased. For example: offX = image width - width
     Note: the parameters are always relative to the original image not to the
     size of an already zoomed image.

void UnZoom()

     Un-zooms the image to original size.

void Flip(Int_t flip)

     Flip image in place. Flip is either 90, 180, 270, 180 is default.
     This function manipulates the original image and destroys the
     scaled and zoomed image which will be recreated at the next call of
     the Draw function. If the image is zoomed the zoom - coordinates are
     now relative to the new image.
     This function cannot be used for images which were created with the
     SetImage() functions, because the original pixel values would be
     destroyed.

void Mirror(Bool_t vert)

     Mirror image in place. If vert is true mirror in vertical axis,
     horizontal otherwise. Vertical is default.
     This function manipulates the original image and destroys the
     scaled and zoomed image which will be recreated at the next call of
     the Draw function. If the image is zoomed the zoom - coordinates are
     now relative to the new image.
     This function cannot be used for images which were created with the
     SetImage() functions, because the original pixel values would be
     destroyed.

UInt_t GetWidth() const

     Return width of original image not of the displayed image.
     (Number of image pixels)

UInt_t GetHeight() const

     Return height of original image not of the displayed image.
     (Number of image pixels)

UInt_t GetScaledWidth() const

     Return width of the displayed image not of the original image.
     (Number of screen pixels)

UInt_t GetScaledHeight() const

     Return height of the displayed image not of the original image.
     (Number of screen pixels)

Bool_t InitVisual()

     Static function to initialize the ASVisual.

void StartPaletteEditor()

     Start palette editor.

### Inline Functions

                  TASImage& operator=(const TASImage& img)
                     Bool_t IsValid() const
             const ASImage* GetImage() const
            const ASVisual* GetVisual() const
                    TClass* Class()
                    TClass* IsA() const
                       void ShowMembers(TMemberInspector& insp, char* parent)
                       void Streamer(TBuffer& b)
                       void StreamerNVirtual(TBuffer& b)

Author: Fons Rademakers, Reiner Rohlfs 28/11/2001
Last update: root/asimage:$Name: $:$Id: TASImage.cxx,v 1.7 2004/01/27 08:12:25 brun Exp $
Copyright (C) 1995-2001, Rene Brun, Fons Rademakers and Reiner Rohlfs *