31 class TASImage :
public TImage {
34 enum { kNoZoom = 0, kZoom = 1, kZoomOps = -1 };
35 enum { kReadWritePNG, kReadWriteVector };
37 void DrawVLine(UInt_t x, UInt_t y1, UInt_t y2, UInt_t col, UInt_t thick);
38 void DrawHLine(UInt_t y, UInt_t x1, UInt_t x2, UInt_t col, UInt_t thick);
39 void DrawLineInternal(UInt_t x1, UInt_t y1, UInt_t x2, UInt_t y2, UInt_t col, UInt_t thick);
40 void DrawWideLine(UInt_t x1, UInt_t y1, UInt_t x2, UInt_t y2, UInt_t col, UInt_t thick);
41 void DrawDashHLine(UInt_t y, UInt_t x1, UInt_t x2, UInt_t nDash,
const char *pDash, UInt_t col, UInt_t thick);
42 void DrawDashVLine(UInt_t x, UInt_t y1, UInt_t y2, UInt_t nDash,
const char *pDash, UInt_t col, UInt_t thick);
43 void DrawDashZLine(UInt_t x1, UInt_t y1, UInt_t x2, UInt_t y2, UInt_t nDash,
const char *pDash, UInt_t col);
44 void DrawDashZTLine(UInt_t x1, UInt_t y1, UInt_t x2, UInt_t y2, UInt_t nDash,
const char *pDash, UInt_t col, UInt_t thick);
45 Bool_t GetPolygonSpans(UInt_t npt, TPoint *ppt, UInt_t *nspans, TPoint **firstPoint, UInt_t **firstWidth);
46 void GetFillAreaSpans(UInt_t npt, TPoint *ppt, UInt_t *nspans, TPoint **firstPoint, UInt_t **firstWidth);
47 inline Int_t Idx(Int_t idx);
48 void FillRectangleInternal(UInt_t col, Int_t x, Int_t y, UInt_t width, UInt_t height);
49 void DrawTextTTF(Int_t x, Int_t y,
const char *text, Int_t size, UInt_t color,
const char *font_name, Float_t angle);
50 void DrawGlyph(
void *bitmap, UInt_t color, Int_t x, Int_t y);
52 void CreateThumbnail();
54 const char *TypeFromMagicNumber(
const char *file);
58 TASImage *fScaledImage;
70 static THashTable *fgPlugList;
72 static ASVisual *fgVisual;
75 EImageFileTypes GetFileType(
const char *ext);
76 void MapFileTypes(EImageFileTypes &type, UInt_t &astype, Bool_t toas = kTRUE);
77 void MapQuality(EImageQuality &quality, UInt_t &asquality, Bool_t toas = kTRUE);
79 static Bool_t InitVisual();
83 TASImage(UInt_t w, UInt_t h);
84 TASImage(
const char *file, EImageFileTypes type = kUnknown);
85 TASImage(
const char *name,
const Double_t *imageData, UInt_t width, UInt_t height, TImagePalette *palette = 0);
86 TASImage(
const char *name,
const TArrayD &imageData, UInt_t width, TImagePalette *palette = 0);
87 TASImage(
const char *name,
const TVectorD &imageData, UInt_t width, TImagePalette *palette = 0);
88 TASImage(
const TASImage &img);
89 TASImage &operator=(
const TASImage &img);
92 TObject *Clone(
const char *newname)
const;
94 void SetEditable(Bool_t on = kTRUE) { fEditable = on; }
95 Bool_t IsEditable()
const {
return fEditable; }
96 void Browse(TBrowser *);
97 void SetTitle(
const char *title=
"");
98 const char *GetTitle()
const;
99 const char *GetIconName()
const {
return GetTitle(); }
102 void FromPad(TVirtualPad *pad, Int_t x = 0, Int_t y = 0,
103 UInt_t w = 0, UInt_t h = 0);
104 void Draw(Option_t *option =
"");
105 void Paint(Option_t *option =
"");
106 Int_t DistancetoPrimitive(Int_t px, Int_t py);
107 void ExecuteEvent(Int_t event, Int_t px, Int_t py);
108 char *GetObjectInfo(Int_t px, Int_t py)
const;
111 void SetPalette(
const TImagePalette *palette);
112 void Zoom(UInt_t offX, UInt_t offY, UInt_t width, UInt_t height);
114 void Flip(Int_t flip = 180);
115 void Mirror(Bool_t vert = kTRUE);
116 void Scale(UInt_t width, UInt_t height);
117 void Slice(UInt_t xStart, UInt_t xEnd, UInt_t yStart, UInt_t yEnd,
118 UInt_t toWidth, UInt_t toHeight);
119 void Tile(UInt_t width, UInt_t height);
120 void Crop(Int_t x = 0, Int_t y = 0, UInt_t width = 0, UInt_t height = 0);
121 void Pad(
const char *color =
"#00FFFFFF", UInt_t left = 0,
122 UInt_t right = 0, UInt_t top = 0, UInt_t bottom = 0);
123 void Blur(Double_t hr = 3, Double_t vr = 3);
124 Double_t *Vectorize(UInt_t max_colors = 256, UInt_t dither = 4, Int_t opaque_threshold = 1);
125 void Gray(Bool_t on = kTRUE);
126 void StartPaletteEditor();
127 void HSV(UInt_t hue = 0, UInt_t radius = 360, Int_t H = 0, Int_t S = 0, Int_t V = 0,
128 Int_t x = 0, Int_t y = 0, UInt_t width = 0, UInt_t height = 0);
129 void Merge(
const TImage *im,
const char *op =
"alphablend", Int_t x = 0, Int_t y = 0);
130 void Append(
const TImage *im,
const char * option =
"+",
const char *color =
"#00000000");
131 void Gradient(UInt_t angle = 0,
const char *colors =
"#FFFFFF #000000",
const char *offsets = 0,
132 Int_t x = 0, Int_t y = 0, UInt_t width = 0, UInt_t height = 0);
133 void Bevel(Int_t x = 0, Int_t y = 0, UInt_t width = 0, UInt_t height = 0,
const char *hi =
"#ffdddddd",
134 const char *lo =
"#ff555555", UShort_t thick = 1, Bool_t pressed = kFALSE);
135 void DrawText(Int_t x = 0, Int_t y = 0,
const char *text =
"", Int_t size = 12,
136 const char *color = 0,
const char *font =
"fixed", EText3DType type = TImage::kPlain,
137 const char *fore_file = 0, Float_t angle = 0);
138 void DrawText(TText *text, Int_t x = 0, Int_t y = 0);
141 void BeginPaint(Bool_t fast = kTRUE);
143 void DrawLine(UInt_t x1, UInt_t y1, UInt_t x2, UInt_t y2,
const char *col =
"#000000", UInt_t thick = 1);
144 void DrawDashLine(UInt_t x1, UInt_t y1, UInt_t x2, UInt_t y2, UInt_t nDash,
const char *pDash,
const char *col =
"#000000", UInt_t thick = 1);
145 void DrawBox(Int_t x1, Int_t y1, Int_t x2, Int_t y2,
const char *col =
"#000000", UInt_t thick = 1, Int_t mode = 0);
146 void DrawRectangle(UInt_t x, UInt_t y, UInt_t w, UInt_t h,
const char *col =
"#000000", UInt_t thick = 1);
147 void FillRectangle(
const char *col = 0, Int_t x = 0, Int_t y = 0, UInt_t width = 0, UInt_t height = 0);
148 void DrawPolyLine(UInt_t nn, TPoint *xy,
const char *col =
"#000000", UInt_t thick = 1, TImage::ECoordMode mode = kCoordModeOrigin);
149 void PutPixel(Int_t x, Int_t y,
const char *col =
"#000000");
150 void PolyPoint(UInt_t npt, TPoint *ppt,
const char *col =
"#000000", TImage::ECoordMode mode = kCoordModeOrigin);
151 void DrawSegments(UInt_t nseg, Segment_t *seg,
const char *col =
"#000000", UInt_t thick = 1);
152 void FillPolygon(UInt_t npt, TPoint *ppt,
const char *col =
"#000000",
const char *stipple = 0, UInt_t w = 16, UInt_t h = 16);
153 void FillPolygon(UInt_t npt, TPoint *ppt, TImage *tile);
154 void CropPolygon(UInt_t npt, TPoint *ppt);
155 void DrawFillArea(UInt_t npt, TPoint *ppt,
const char *col =
"#000000",
const char *stipple = 0, UInt_t w = 16, UInt_t h = 16);
156 void DrawFillArea(UInt_t npt, TPoint *ppt, TImage *tile);
157 void FillSpans(UInt_t npt, TPoint *ppt, UInt_t *widths,
const char *col =
"#000000",
const char *stipple = 0, UInt_t w = 16, UInt_t h = 16);
158 void FillSpans(UInt_t npt, TPoint *ppt, UInt_t *widths, TImage *tile);
159 void CropSpans(UInt_t npt, TPoint *ppt, UInt_t *widths);
160 void CopyArea(TImage *dst, Int_t xsrc, Int_t ysrc, UInt_t w, UInt_t h, Int_t xdst = 0, Int_t ydst = 0, Int_t gfunc = 3, EColorChan chan = kAllChan);
161 void DrawCellArray(Int_t x1, Int_t y1, Int_t x2, Int_t y2, Int_t nx, Int_t ny, UInt_t *ic);
162 void FloodFill(Int_t x, Int_t y,
const char *col,
const char *min_col,
const char *max_col = 0);
163 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);
164 void DrawStraightEllips(Int_t x, Int_t y, Int_t rx, Int_t ry,
const char *col =
"#000000", Int_t thick = 1);
165 void DrawCircle(Int_t x, Int_t y, Int_t r,
const char *col =
"#000000", Int_t thick = 1);
166 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);
167 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);
170 void ReadImage(
const char *file, EImageFileTypes type = TImage::kUnknown);
171 void WriteImage(
const char *file, EImageFileTypes type = TImage::kUnknown);
172 void SetImage(
const Double_t *imageData, UInt_t width, UInt_t height, TImagePalette *palette = 0);
173 void SetImage(
const TArrayD &imageData, UInt_t width, TImagePalette *palette = 0);
174 void SetImage(
const TVectorD &imageData, UInt_t width, TImagePalette *palette = 0);
175 void SetImage(Pixmap_t pxm, Pixmap_t mask = 0);
176 void FromWindow(Drawable_t wid, Int_t x = 0, Int_t y = 0, UInt_t w = 0, UInt_t h = 0);
177 void FromGLBuffer(UChar_t* buf, UInt_t w, UInt_t h);
180 UInt_t GetWidth()
const;
181 UInt_t GetHeight()
const;
182 UInt_t GetScaledWidth()
const;
183 UInt_t GetScaledHeight()
const;
184 Bool_t IsValid()
const {
return fImage ? kTRUE : kFALSE; }
185 Bool_t IsGray()
const {
return fIsGray; }
186 ASImage *GetImage()
const {
return fImage; }
187 void SetImage(ASImage *image) { DestroyImage(); fImage = image; }
188 TImage *GetScaledImage()
const {
return fScaledImage; }
189 Pixmap_t GetPixmap();
191 TArrayL *GetPixels(Int_t x = 0, Int_t y = 0, UInt_t w = 0, UInt_t h = 0);
192 TArrayD *GetArray(UInt_t w = 0, UInt_t h = 0, TImagePalette *pal = gWebImagePalette);
193 UInt_t *GetArgbArray();
194 UInt_t *GetRgbaArray();
195 Double_t *GetVecArray();
196 UInt_t *GetScanline(UInt_t y);
197 void GetImageBuffer(
char **buffer,
int *size, EImageFileTypes type = TImage::kPng);
198 void GetZoomPosition(UInt_t &x, UInt_t &y, UInt_t &w, UInt_t &h)
const;
199 Bool_t SetImageBuffer(
char **buffer, EImageFileTypes type = TImage::kPng);
200 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 =
"");
201 void SetPaletteEnabled(Bool_t on = kTRUE);
202 void SavePrimitive(std::ostream &out, Option_t *option =
"");
204 static const ASVisual *GetVisual();
205 static UInt_t AlphaBlend(UInt_t bot, UInt_t top);
206 static void Image2Drawable(ASImage *im, 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 =
"");
209 Bool_t SetJpegDpi(
const char *name, UInt_t dpi = 72);