60 # include <ft2build.h>
61 # include FT_FREETYPE_H
87 #include "RConfigure.h"
92 # include <X11/Xlib.h>
95 # include "Windows4root.h"
99 # define X_DISPLAY_MISSING 1
101 # include <afterbase.h>
103 # include <win32/config.h>
104 # include <win32/afterbase.h>
105 # define X_DISPLAY_MISSING 1
107 # include <afterimage.h>
113 #include <fontconfig/fontconfig.h>
134 #if defined(__GNUC__) && __GNUC__ >= 4 && ((__GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ >= 1) || (__GNUC_MINOR__ >= 3)) && !__INTEL_COMPILER
135 #pragma GCC diagnostic ignored "-Wstrict-aliasing"
156 #define _alphaBlend(bot, top) {\
157 __argb32__ *T = (__argb32__*)(top);\
158 __argb32__ *B = (__argb32__*)(bot);\
163 B->a = ((B->a*aa)>>8) + T->a;\
164 B->r = (B->r*aa + T->r*T->a)>>8;\
165 B->g = (B->g*aa + T->g*T->a)>>8;\
166 B->b = (B->b*aa + T->b*T->a)>>8;\
180 destroy_asimage(&fImage);
183 if (fIsGray && fGrayImage) {
184 destroy_asimage(&fGrayImage);
233 fImage = create_asimage(w ? w : 20, h ? h : 20, 0);
259 SetImage(imageData, width, height, palette);
272 SetImage(imageData, width, palette);
285 SetImage(imageData, width, palette);
300 if (img.
fImage->alt.vector) {
303 memcpy(
fImage->alt.vector, img.
fImage->alt.vector, size);
321 if (
this != &img && img.
IsValid()) {
330 if (img.
fImage->alt.vector) {
333 memcpy(
fImage->alt.vector, img.
fImage->alt.vector, size);
380 const char *delim =
":";
382 const char *delim =
";";
384 while (icon_path.
Tokenize(token, from, delim) && cnt < 6) {
400 FILE *fp = fopen(file,
"rb");
401 const char *ret =
"";
405 if (!fread(&magic, 1, 1, fp)) {
413 if (!fread(&magic, 1, 1, fp)) {
417 if (!fread(&magic, 1, 1, fp)) {
422 ret = (magic == 1) ?
"ico" :
"cur";
427 if (!fread(&magic, 1, 1, fp)) {
432 if (magic == 0x21) ret =
"ps";
433 else if (magic == 0x50) ret =
"pdf";
483 Warning(
"Scale",
"Visual not initiated");
487 Bool_t xpm = filename && (filename[0] ==
'/' &&
488 filename[1] ==
'*') && filename[2] ==
' ';
500 set_output_threshold(0);
502 static ASImageImportParams iparams;
506 iparams.filter = SCL_DO_ALL;
507 iparams.gamma = SCREEN_GAMMA;
508 iparams.gamma_table =
NULL;
510 iparams.format = ASA_ASImage;
512 iparams.subimage = 0;
513 iparams.return_animation_delay = -1;
517 if (filename) dot = strrchr(filename,
'.');
530 iparams.subimage = ext.
Atoi();
532 ext = strrchr(fname.
Data(),
'.') + 1;
535 image = file2ASImage_extra(fname.
Data(), &iparams);
547 unsigned char *bitmap = 0;
553 if (!handler || ((handler->
LoadPlugin() == -1))) {
572 image = bitmap2asimage(bitmap, w, h, 0, 0);
652 Error(
"WriteImage",
"no image loaded");
656 if (!file || !*file) {
657 Error(
"WriteImage",
"no file name specified");
662 if ((s = strrchr(file,
'.'))) {
666 Error(
"WriteImage",
"cannot determine a valid file type");
674 Error(
"WriteImage",
"not a valid file type was specified");
680 ASImageFileTypes atype = (ASImageFileTypes)mytype;
688 static ASImageExportParams parms;
693 parms.xpm.type = atype;
694 parms.xpm.flags = EXPORT_ALPHA;
695 parms.xpm.dither = 4;
696 parms.xpm.opaque_threshold = 127;
697 parms.xpm.max_colors = 512;
700 ASImage2bmp(im, fname.
Data(), 0);
703 ASImage2xcf(im, fname.
Data(), 0);
706 parms.png.type = atype;
707 parms.png.flags = EXPORT_ALPHA;
711 parms.jpeg.type = atype;
712 parms.jpeg.flags = 0;
713 parms.jpeg.quality = aquality;
716 parms.gif.type = atype;
717 parms.gif.flags = EXPORT_ALPHA;
718 parms.gif.dither = 0;
719 parms.gif.opaque_threshold = 0;
723 parms.gif.type = atype;
724 parms.gif.flags = EXPORT_ALPHA | EXPORT_APPEND;
725 parms.gif.dither = 0;
726 parms.gif.opaque_threshold = 0;
727 parms.gif.animate_repeats = 0;
740 parms.gif.flags |= EXPORT_ANIMATION_REPEATS;
741 parms.gif.animate_repeats = 0;
742 }
else if(sufix==
"") {
759 parms.gif.flags |= EXPORT_ANIMATION_REPEATS;
760 parms.gif.animate_repeats = atoi(s);
769 parms.gif.flags |= EXPORT_ANIMATION_REPEATS;
770 parms.gif.animate_repeats = 0;
777 delay = atoi(sDelay);
778 parms.gif.flags |= EXPORT_ANIMATION_REPEATS;
779 parms.gif.animate_repeats = atoi(sRepeats);
781 Error(
"WriteImage",
"gif suffix %s not yet supported", s);
785 parms.gif.animate_delay = delay;
787 int i1 = fname.
Index(
"gif+");
789 fname = fname(0, i1 + 3);
792 Error(
"WriteImage",
"unexpected gif extension structure %s", fname.
Data());
798 parms.tiff.type = atype;
799 parms.tiff.flags = EXPORT_ALPHA;
800 parms.tiff.rows_per_strip = 0;
801 parms.tiff.compression_type = aquality <= 50 ? TIFF_COMPRESSION_JPEG :
802 TIFF_COMPRESSION_NONE;
803 parms.tiff.jpeg_quality = 100;
804 parms.tiff.opaque_threshold = 0;
807 Error(
"WriteImage",
"file type %s not yet supported", s);
811 if (!ASImage2file(im, 0, fname.
Data(), atype, &parms)) {
812 Error(
"WriteImage",
"error writing file %s", file);
830 if (s ==
"jpg" || s ==
"jpeg")
869 astype = ASIT_Xpm;
break;
871 astype = ASIT_ZCompressedXpm;
break;
873 astype = ASIT_GZCompressedXpm;
break;
875 astype = ASIT_Png;
break;
877 astype = ASIT_Jpeg;
break;
879 astype = ASIT_Xcf;
break;
881 astype = ASIT_Ppm;
break;
883 astype = ASIT_Pnm;
break;
885 astype = ASIT_Bmp;
break;
887 astype = ASIT_Ico;
break;
889 astype = ASIT_Cur;
break;
891 astype = ASIT_Gif;
break;
893 astype = ASIT_Gif;
break;
895 astype = ASIT_Tiff;
break;
897 astype = ASIT_Xbm;
break;
899 astype = ASIT_Targa;
break;
901 astype = ASIT_XMLScript;
break;
903 astype = ASIT_Unknown;
909 case ASIT_ZCompressedXpm:
911 case ASIT_GZCompressedXpm:
954 asquality = 25;
break;
956 asquality = 75;
break;
958 asquality = 50;
break;
960 asquality = 100;
break;
966 if (asquality > 0 && asquality <= 25)
968 if (asquality > 26 && asquality <= 50)
970 if (asquality > 51 && asquality <= 75)
972 if (asquality > 76 && asquality <= 100)
992 Warning(
"SetImage",
"Visual not initiated");
1002 for (
Int_t pixel = 1; pixel <
Int_t(width * height); pixel++) {
1010 ASVectorPalette asPalette;
1014 for (col = 0; col < 4; col++)
1015 asPalette.channels[col] =
new UShort_t[asPalette.npoints];
1022 asPalette.points =
new Double_t[asPalette.npoints];
1023 for (Int_t point = 0; point <
Int_t(asPalette.npoints); point++)
1027 height, &asPalette, ASA_ASImage,
1030 delete [] asPalette.points;
1031 for (col = 0; col < 4; col++)
1032 delete [] asPalette.channels[col];
1076 Error(
"FromPad",
"pad cannot be 0");
1081 Warning(
"FromPad",
"Visual not initiated");
1091 if (
gROOT->IsBatch()) {
1099 if (itmp && itmp->
fImage) {
1108 if (itmp && itmp->
fImage && (itmp !=
this)) {
1110 if (itmp->
fImage->alt.argb32) {
1112 fImage->alt.argb32 = (ARGB32*)safemalloc(sz*
sizeof(ARGB32));
1113 memcpy(
fImage->alt.argb32, itmp->
fImage->alt.argb32, sz*4);
1143 static int x11 = -1;
1144 if (x11 < 0) x11 =
gVirtualX->InheritsFrom(
"TGX11");
1149 unsigned char *bits =
gVirtualX->GetColorBits(wd, 0, 0, w, h);
1154 fImage = bitmap2asimage(bits, w, h, 0, 0);
1175 Error(
"Draw",
"no image set");
1188 w =
Int_t(w*cx) + 4;
1189 h =
Int_t(h*cx) + 28;
1193 rname =
"new TCanvas(\"" + rname +
Form(
"\", %d, %d);", w, h);
1194 gROOT->ProcessLineFast(rname.Data());
1203 gPad->Range(-left / (1.0 - left - right),
1204 -bottom / (1.0 - top - bottom),
1205 1 + right / (1.0 - left - right),
1206 1 + top / ( 1.0 - top - bottom));
1207 gPad->RangeAxis(0, 0, 1, 1);
1230 wsrc = wsrc ? wsrc : im->width;
1231 hsrc = hsrc ? hsrc : im->height;
1233 static int x11 = -1;
1234 if (x11 < 0) x11 =
gVirtualX->InheritsFrom(
"TGX11");
1241 UInt_t ww = wsrc - ow + (ow ? 8 : 0);
1248 char *bits =
new char[ww*hh];
1250 ASImageDecoder *imdec = start_image_decoding(
fgVisual, im, SCL_DO_ALPHA,
1251 xsrc, ysrc, ww, 0, 0);
1253 for (yy = 0; yy < hh; yy++) {
1254 imdec->decode_image_scanline(imdec);
1255 CARD32 *
a = imdec->buffer.alpha;
1257 for (xx = 0; xx < ww; xx++) {
1272 stop_image_decoding(&imdec);
1275 (
const char *)bits, ww, hh);
1293 if (x11 && (!
gPad ||
gPad->GetGLDevice() == -1)) {
1294 asimage2drawable(
fgVisual, wid, im, (GC)gc, xsrc, ysrc, x, y, wsrc, hsrc, 1);
1297 unsigned char *bits = (
unsigned char *)im->alt.argb32;
1299 img = tile_asimage(
fgVisual, im, xsrc, ysrc, wsrc, hsrc,
1300 0, ASA_ARGB32, 0, ASIMAGE_QUALITY_DEFAULT);
1302 bits = (
unsigned char *)img->alt.argb32;
1309 if (
gPad &&
gPad->GetGLDevice() != -1) {
1311 painter->DrawPixels(bits, wsrc, hsrc, x, y, !option.
Contains(
"opaque"));
1319 gVirtualX->CopyArea(pic, wid, gc, 0, 0, wsrc, hsrc, x, y);
1326 destroy_asimage(&img);
1350 xsrc, ysrc, wsrc, hsrc, opt);
1369 Error(
"Paint",
"no image set");
1374 Warning(
"Paint",
"Visual not initiated");
1378 Int_t tile_x = 0, tile_y = 0;
1379 CARD32 tile_tint = 0;
1388 if (sscanf(opt.
Data() + opt.
Index(
"t"),
"t%d,%d,%s", &tile_x, &tile_y,
1391 if (parse_argb_color(stint, (CARD32*)&tile_tint) == stint)
1394 Error(
"Paint",
"tile option error");
1402 if (!
fImage->alt.vector) {
1415 to_h = (
Int_t)(to_h * (1.0 -
gPad->GetBottomMargin() -
gPad->GetTopMargin() ) + 0.5);
1416 to_w = (
Int_t)(to_w * (1.0 -
gPad->GetLeftMargin() -
gPad->GetRightMargin() ) + 0.5);
1419 if ((to_w < 25 || to_h < 25) && !expand) {
1420 Error(
"Paint",
"pad too small to display an image");
1432 Int_t pal_Ax = to_w +
gPad->UtoAbsPixel(
gPad->GetLeftMargin()) +
1433 (
gPad->UtoAbsPixel(
gPad->GetRightMargin()) / 10);
1435 Int_t pal_x = to_w +
gPad->UtoPixel(
gPad->GetLeftMargin()) +
1436 (
gPad->UtoPixel(
gPad->GetRightMargin()) / 10);
1441 ASImage *grad_im = 0;
1449 grad.type = GRADIENT_Top2Bottom;
1450 grad.color =
new ARGB32[grad.npoints];
1451 grad.offset =
new double[grad.npoints];
1454 Int_t oldPt = grad.npoints -
pt -1;
1455 grad.offset[
pt] = 1 - pal.
fPoints[oldPt];
1456 grad.color[
pt] = (((ARGB32)(pal.
fColorBlue[oldPt] & 0xff00)) >> 8) |
1458 (((ARGB32)(pal.
fColorRed[oldPt] & 0xff00)) << 8) |
1459 (((ARGB32)(pal.
fColorAlpha[oldPt] & 0xff00)) << 16);
1463 pal_h, SCL_DO_COLOR,
1466 delete [] grad.color;
1467 delete [] grad.offset;
1475 to_w, to_h, tile_tint, ASA_ASImage,
1502 ASImage *tmpImage = 0;
1513 destroy_asimage(&tmpImage);
1528 Error(
"Paint",
"image could not be rendered to display");
1532 int tox = expand ? 0 : int(
gPad->UtoPixel(1.) *
gPad->GetLeftMargin());
1533 int toy = expand ? 0 : int(
gPad->VtoPixel(0.) *
gPad->GetTopMargin());
1535 if (!
gROOT->IsBatch()) {
1550 axis.
PaintAxis(pal_Xpos,
gPad->PixeltoY(pal_Ay + pal_h - 1),
1551 pal_Xpos,
gPad->PixeltoY(pal_Ay),
1552 min, max, ndiv,
"+LU");
1557 pal_Xpos,
gPad->AbsPixeltoY(pal_Ay + 1),
1558 min, max, ndiv,
"+L");
1568 gPad->XtoAbsPixel(0),
gPad->YtoAbsPixel(1));
1573 dump->
Merge(&tgrad,
"alphablend", pal_Ax, pal_Ay);
1583 pal_Xpos,
gPad->AbsPixeltoY(pal_Ay + 1),
1584 min, max, ndiv,
"+L");
1588 Warning(
"Paint",
"PDF not implemented yet");
1591 Warning(
"Paint",
"SVG not implemented yet");
1611 x2 = x1+dx/image->width;
1613 y2 = y1+dy/image->height;
1615 x1 =
gPad->GetX1()+dx*
gPad->GetLeftMargin();
1616 x2 = x1+(dx*(1-
gPad->GetRightMargin()-
gPad->GetLeftMargin()))/image->width;
1617 y1 =
gPad->GetY2()-dy*
gPad->GetTopMargin();
1618 y2 = y1+(dy*(1-
gPad->GetTopMargin()-
gPad->GetBottomMargin()))/image->height;
1623 ASImageDecoder *imdec = start_image_decoding(
fgVisual, image, SCL_DO_ALL,
1624 0, 0, image->width, image->height, 0);
1626 for (
Int_t yt = 0; yt < (
Int_t)image->height; yt++) {
1627 imdec->decode_image_scanline(imdec);
1628 for (
Int_t xt = 0; xt < (
Int_t)image->width; xt++)
1630 imdec->buffer.green[xt],
1631 imdec->buffer.blue[xt]);
1633 stop_image_decoding(&imdec);
1638 Double_t xconv = (
gPad->AbsPixeltoX(pal_Ax + pal_w) -
gPad->AbsPixeltoX(pal_Ax)) / grad_im->width;
1639 Double_t yconv = (
gPad->AbsPixeltoY(pal_Ay - pal_h) -
gPad->AbsPixeltoY(pal_Ay)) / grad_im->height;
1640 x1 =
gPad->AbsPixeltoX(pal_Ax);
1642 y2 =
gPad->AbsPixeltoY(pal_Ay);
1647 imdec = start_image_decoding(
fgVisual, grad_im, SCL_DO_ALL,
1648 0, 0, grad_im->width, grad_im->height, 0);
1650 for (
Int_t yt = 0; yt < (
Int_t)grad_im->height; yt++) {
1651 imdec->decode_image_scanline(imdec);
1652 for (
Int_t xt = 0; xt < (
Int_t)grad_im->width; xt++)
1654 imdec->buffer.green[xt],
1655 imdec->buffer.blue[xt]);
1658 stop_image_decoding(&imdec);
1669 pal_Xpos,
gPad->AbsPixeltoY(pal_Ay + 1),
1670 min, max, ndiv,
"+L");
1676 destroy_asimage(&grad_im);
1685 Int_t pxl, pyl, pxt, pyt;
1692 if (px1 < px2) {pxl = px1; pxt = px2;}
1693 else {pxl = px2; pxt = px1;}
1694 if (py1 < py2) {pyl = py1; pyt = py2;}
1695 else {pyl = py2; pyt = py1;}
1697 if ((px > pxl && px < pxt) && (py > pyl && py < pyt))
1708 static TBox *ZoomBox;
1713 gPad->ExecuteEvent(event, px, py);
1719 static Int_t px1old, py1old, px2old, py2old;
1720 static Int_t px1, py1, px2, py2, pxl, pyl, pxt, pyt;
1731 if (imgX < 0) px = px - imgX;
1732 if (imgY < 0) py = py - imgY;
1737 if (imgX >= (
int)image->width) px = px - imgX + image->width - 1;
1738 if (imgY >= (
int)image->height) py = py - imgY + image->height - 1;
1743 px1 =
gPad->XtoAbsPixel(
gPad->GetX1());
1744 py1 =
gPad->YtoAbsPixel(
gPad->GetY1());
1745 px2 =
gPad->XtoAbsPixel(
gPad->GetX2());
1746 py2 =
gPad->YtoAbsPixel(
gPad->GetY2());
1747 px1old = px; py1old = py;
1769 ZoomBox =
new TBox(pxl, pyl, pxt, pyt);
1771 ZoomBox->
Draw(
"l*");
1790 Int_t imgX1 = px1old -
gPad->XtoAbsPixel(0);
1791 Int_t imgY1 = py1old -
gPad->YtoAbsPixel(1);
1792 Int_t imgX2 = px -
gPad->XtoAbsPixel(0);
1793 Int_t imgY2 = py -
gPad->YtoAbsPixel(1);
1795 imgY1 = image->height - 1 - imgY1;
1796 imgY2 = image->height - 1 - imgY2;
1802 Zoom((imgX1 < imgX2) ? imgX1 : imgX2, (imgY1 < imgY2) ? imgY1 : imgY2,
1821 static char info[64];
1827 px -=
gPad->XtoAbsPixel(0);
1828 py -=
gPad->YtoAbsPixel(1);
1831 if (px < 0 || py < 0)
return info;
1835 if (px >= (
int)image->width || py >= (
int)image->height)
1838 py = image->height - 1 - py;
1845 if (
fImage->alt.vector) {
1846 snprintf(info,64,
"x: %d y: %d %.5g",
1849 snprintf(info,64,
"x: %d y: %d", px, py);
1865 Warning(
"SetPalette",
"Visual not initiated");
1870 Warning(
"SetPalette",
"Image not valid");
1874 if (
fImage->alt.vector == 0)
1880 ASVectorPalette asPalette;
1882 asPalette.channels[0] =
new CARD16 [asPalette.npoints];
1883 asPalette.channels[1] =
new CARD16 [asPalette.npoints];
1884 asPalette.channels[2] =
new CARD16 [asPalette.npoints];
1885 asPalette.channels[3] =
new CARD16 [asPalette.npoints];
1891 asPalette.points =
new double[asPalette.npoints];
1892 for (
Int_t point = 0; point <
Int_t(asPalette.npoints); point++)
1898 delete [] asPalette.points;
1899 for (Int_t col = 0; col < 4; col++)
1900 delete [] asPalette.channels[col];
1919 Warning(
"Scale",
"Image not initiated");
1924 Warning(
"Scale",
"Visual not initiated");
1932 if (toWidth > 30000)
1934 if (toHeight > 30000)
1937 ASImage *img = scale_asimage(
fgVisual,
fImage, toWidth, toHeight,
1954 Warning(
"Scale",
"Image not initiated");
1959 Warning(
"Scale",
"Visual not initiated");
1967 if (toWidth > 30000)
1969 if (toHeight > 30000)
1973 yStart, yEnd, toWidth, toHeight,
1989 Warning(
"Tile",
"Image not initiated");
1994 Warning(
"Tile",
"Visual not initiated");
2002 if (toWidth > 30000)
2004 if (toHeight > 30000)
2007 ASImage *img = tile_asimage(
fgVisual,
fImage, 0, 0, toWidth, toHeight, 0,
2029 Warning(
"Zoom",
"Image not valid");
2051 Warning(
"UnZoom",
"Image not valid");
2079 Warning(
"Flip",
"Image not valid");
2083 Warning(
"Flip",
"Visual not initiated");
2087 if (
fImage->alt.vector) {
2088 Warning(
"Flip",
"flip does not work for data images");
2092 Int_t rflip = flip/90;
2126 Warning(
"Mirror",
"Image not valid");
2131 Warning(
"Mirror",
"Visual not initiated");
2135 if (
fImage->alt.vector) {
2136 Warning(
"Mirror",
"mirror does not work for data images");
2208 if (inbatch && !noX) {
2220 fgVisual = create_asvisual(0, 0, 0, 0);
2227 fgVisual = create_asvisual(0, 0, 0, 0);
2230 disp = (Display*)
gVirtualX->GetDisplay();
2233 Visual *vis = (Visual*)
gVirtualX->GetVisual();
2236 if (vis == 0 || cmap == 0) {
2237 fgVisual = create_asvisual(0, 0, 0, 0);
2239 fgVisual = create_asvisual_for_id(disp, screen, depth,
2240 XVisualIDFromVisual(vis), cmap, 0);
2244 fgVisual = create_asvisual(0, 0, 0, 0);
2257 Warning(
"StartPaletteEditor",
"Image not valid");
2260 if (
fImage->alt.vector == 0) {
2261 Warning(
"StartPaletteEditor",
"palette can be modified only for data images");
2276 Warning(
"GetPixmap",
"Visual not initiated");
2284 static int x11 = -1;
2285 if (x11 < 0) x11 =
gVirtualX->InheritsFrom(
"TGX11");
2291 if (!
fImage->alt.argb32) {
2294 ret =
gVirtualX->CreatePixmapFromData((
unsigned char*)
fImage->alt.argb32,
2310 Warning(
"GetMask",
"Visual not initiated");
2317 Warning(
"GetMask",
"No image");
2322 UInt_t ow = img->width%8;
2323 UInt_t ww = img->width - ow + (ow ? 8 : 0);
2330 char *bits =
new char[ww*hh];
2332 ASImageDecoder *imdec = start_image_decoding(
fgVisual, img, SCL_DO_ALPHA,
2339 for (y = 0; y < hh; y++) {
2340 imdec->decode_image_scanline(imdec);
2341 CARD32 *
a = imdec->buffer.alpha;
2343 for (x = 0; x < ww; x++) {
2357 stop_image_decoding(&imdec);
2358 pxmap =
gVirtualX->CreateBitmap(
gVirtualX->GetDefaultRootWindow(), (
const char *)bits,
2370 Warning(
"SetImage",
"Visual not initiated");
2380 gVirtualX->GetWindowSize(pxm, xy, xy, w, h);
2384 static int x11 = -1;
2385 if (x11 < 0) x11 =
gVirtualX->InheritsFrom(
"TGX11");
2390 unsigned char *bits =
gVirtualX->GetColorBits(pxm, 0, 0, w, h);
2397 fImage = bitmap2asimage(bits, w, h, 0, 0);
2401 unsigned char *mask_bits =
gVirtualX->GetColorBits(mask, 0, 0, w, h);
2402 fImage = bitmap2asimage(bits, w, h, 0, mask_bits);
2403 delete [] mask_bits;
2414 Warning(
"GetPixels",
"Wrong Image");
2419 ASImageDecoder *imdec;
2421 width = !width ? img->width : width;
2422 height = !height ? img->height : height;
2433 if ((x >= (
int)img->width) || (y >= (
int)img->height)) {
2437 if ((
int)(x + width) > (
int)img->width) {
2438 width = img->width -
x;
2441 if ((
int)(y + height) > (
int)img->height) {
2442 height = img->height -
y;
2445 if ((imdec = start_image_decoding(0,
fImage, SCL_DO_ALL, 0, y,
2446 img->width, height, 0)) == 0) {
2447 Warning(
"GetPixels",
"Failed to create image decoder");
2457 for (
UInt_t k = 0; k < height; k++) {
2458 imdec->decode_image_scanline(imdec);
2460 for (
UInt_t i = 0; i < width; ++i) {
2461 if ((r == (
Int_t)imdec->buffer.red[i]) &&
2462 (g == (
Int_t)imdec->buffer.green[i]) &&
2463 (b == (
Int_t)imdec->buffer.blue[i])) {
2465 r = (
Int_t)imdec->buffer.red[i];
2466 g = (
Int_t)imdec->buffer.green[i];
2467 b = (
Int_t)imdec->buffer.blue[i];
2470 ret->
AddAt(p, k*width + i);
2474 stop_image_decoding(&imdec);
2486 Warning(
"GetVecArray",
"Bad Image");
2489 if (
fImage->alt.vector) {
2490 return fImage->alt.vector;
2508 Warning(
"GetArray",
"Bad Image");
2514 if (
fImage->alt.vector) {
2519 ASImageDecoder *imdec;
2521 w = w ? w :
fImage->width;
2522 h = h ? h :
fImage->height;
2530 if ((imdec = start_image_decoding(0, img, SCL_DO_ALL, 0, 0,
2531 img->width, 0, 0)) == 0) {
2532 Warning(
"GetArray",
"Failed to create image decoder");
2543 for (
UInt_t k = 0; k <
h; k++) {
2544 imdec->decode_image_scanline(imdec);
2546 for (
UInt_t i = 0; i < w; ++i) {
2547 if ((r == imdec->buffer.red[i]) &&
2548 (g == imdec->buffer.green[i]) &&
2549 (b == imdec->buffer.blue[i])) {
2551 r = imdec->buffer.red[i];
2552 g = imdec->buffer.green[i];
2553 b = imdec->buffer.blue[i];
2554 if (palette) p = palette->
FindColor(r, g, b);
2556 v = palette ? palette->
fPoints[p] :
Double_t((r << 16) + (g << 8) + b)/0xFFFFFF;
2557 ret->
AddAt(v, (h-k-1)*w + i);
2561 stop_image_decoding(&imdec);
2584 const char *color,
const char *font_name,
2587 UInt_t width=0, height=0;
2588 ARGB32 text_color = ARGB32_Black;
2589 ASImage *fore_im = 0;
2590 ASImage *text_im = 0;
2594 Warning(
"DrawText",
"Visual not initiated");
2606 FcPattern *pat, *match;
2609 pat = FcPatternCreate ();
2611 if (strcmp(basename,
"timesi.ttf") == 0 ||
2612 strcmp(basename,
"FreeSerifItalic.otf") == 0) {
2613 FcPatternAddString (pat, FC_FAMILY, (
const FcChar8*)
"freeserif");
2614 FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
2615 FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
2617 else if (strcmp(basename,
"timesbd.ttf") == 0 ||
2618 strcmp(basename,
"FreeSerifBold.otf") == 0) {
2619 FcPatternAddString (pat, FC_FAMILY, (
const FcChar8*)
"freeserif");
2620 FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
2621 FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
2623 else if (strcmp(basename,
"timesbi.ttf") == 0 ||
2624 strcmp(basename,
"FreeSerifBoldItalic.otf") == 0) {
2625 FcPatternAddString (pat, FC_FAMILY, (
const FcChar8*)
"freeserif");
2626 FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
2627 FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
2629 else if (strcmp(basename,
"arial.ttf") == 0 ||
2630 strcmp(basename,
"FreeSans.otf") == 0) {
2631 FcPatternAddString (pat, FC_FAMILY, (
const FcChar8*)
"freesans");
2632 FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
2633 FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
2635 else if (strcmp(basename,
"ariali.ttf") == 0 ||
2636 strcmp(basename,
"FreeSansOblique.otf") == 0) {
2637 FcPatternAddString (pat, FC_FAMILY, (
const FcChar8*)
"freesans");
2638 FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
2639 FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
2641 else if (strcmp(basename,
"arialbd.ttf") == 0 ||
2642 strcmp(basename,
"FreeSansBold.otf") == 0) {
2643 FcPatternAddString (pat, FC_FAMILY, (
const FcChar8*)
"freesans");
2644 FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
2645 FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
2647 else if (strcmp(basename,
"arialbi.ttf") == 0 ||
2648 strcmp(basename,
"FreeSansBoldOblique.otf") == 0) {
2649 FcPatternAddString (pat, FC_FAMILY, (
const FcChar8*)
"freesans");
2650 FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
2651 FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
2653 else if (strcmp(basename,
"cour.ttf") == 0 ||
2654 strcmp(basename,
"FreeMono.otf") == 0) {
2655 FcPatternAddString (pat, FC_FAMILY, (
const FcChar8*)
"freemono");
2656 FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
2657 FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
2659 else if (strcmp(basename,
"couri.ttf") == 0 ||
2660 strcmp(basename,
"FreeMonoOblique.otf") == 0) {
2661 FcPatternAddString (pat, FC_FAMILY, (
const FcChar8*)
"freemono");
2662 FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
2663 FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
2665 else if (strcmp(basename,
"courbd.ttf") == 0 ||
2666 strcmp(basename,
"FreeMonoBold.otf") == 0) {
2667 FcPatternAddString (pat, FC_FAMILY, (
const FcChar8*)
"freemono");
2668 FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
2669 FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
2671 else if (strcmp(basename,
"courbi.ttf") == 0 ||
2672 strcmp(basename,
"FreeMonoBoldOblique.otf") == 0) {
2673 FcPatternAddString (pat, FC_FAMILY, (
const FcChar8*)
"freemono");
2674 FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_BOLD);
2675 FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
2677 else if (strcmp(basename,
"symbol.ttf") == 0) {
2678 FcPatternAddString (pat, FC_FAMILY, (
const FcChar8*)
"symbol");
2679 FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
2680 FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
2682 else if (strcmp(basename,
"times.ttf") == 0 ||
2683 strcmp(basename,
"FreeSerif.otf") == 0) {
2684 FcPatternAddString (pat, FC_FAMILY, (
const FcChar8*)
"freeserif");
2685 FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
2686 FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
2688 else if (strcmp(basename,
"wingding.ttf") == 0) {
2689 FcPatternAddString (pat, FC_FAMILY, (
const FcChar8*)
"dingbats");
2690 FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
2691 FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
2693 else if (strcmp(basename,
"BlackChancery.ttf") == 0) {
2694 FcPatternAddString (pat, FC_FAMILY, (
const FcChar8*)
"urwchanceryl");
2695 FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
2696 FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ITALIC);
2699 Warning(
"DrawText",
"cannot find a font %s", font_name);
2700 FcPatternAddString (pat, FC_FAMILY, (
const FcChar8*)
"freemono");
2701 FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_REGULAR);
2702 FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN);
2705 FcConfigSubstitute (
NULL, pat, FcMatchPattern);
2706 FcDefaultSubstitute (pat);
2707 match = FcFontMatch (
NULL, pat, &result);
2708 FcPatternGetString (match, FC_FILE, 0, (FcChar8**)&ttfnt);
2709 FcPatternGetInteger (match, FC_INDEX, 0, &ttindex);
2713 FcPatternDestroy (match);
2714 FcPatternDestroy (pat);
2721 parse_argb_color(color, &text_color);
2734 Warning(
"DrawText",
"cannot create Font Manager");
2738 ASFont *font = get_asfont(
gFontManager, fn.
Data(), ttindex, size, ASF_GuessWho);
2741 Warning(
"DrawText",
"cannot find a font %s", font_name);
2745 get_text_size(text, font, (ASText3DType)type, &width, &height);
2748 fImage = create_asimage(width, height, 0);
2752 text_im = draw_text(text, font, (ASText3DType)type, 0);
2757 ASImage *tmp = file2ASImage(fore_file, 0xFFFFFFFF, SCREEN_GAMMA, 0, 0);
2759 if ((tmp->width != width) || (tmp->height != height)) {
2760 fore_im = tile_asimage(
fgVisual, tmp, 0, 0, width, height, 0,
2763 destroy_asimage(&tmp);
2770 move_asimage_channel(fore_im, IC_ALPHA, text_im, IC_ALPHA);
2771 destroy_asimage(&text_im);
2779 ASImage *rendered_im;
2780 ASImageLayer layers[2];
2782 init_image_layers(&(layers[0]), 2);
2783 fore_im->back_color = text_color;
2784 layers[0].im = rimg;
2785 layers[0].dst_x = 0;
2786 layers[0].dst_y = 0;
2787 layers[0].clip_width = rimg->width;
2788 layers[0].clip_height = rimg->height;
2789 layers[0].bevel = 0;
2790 layers[1].im = fore_im;
2791 layers[1].dst_x =
x;
2792 layers[1].dst_y =
y;
2793 layers[1].clip_width = fore_im->width;
2794 layers[1].clip_height = fore_im->height;
2796 rendered_im = merge_layers(
fgVisual, &(layers[0]), 2, rimg->width, rimg->height,
2799 destroy_asimage(&fore_im);
2832 Warning(
"Merge",
"Visual not initiated");
2836 ASImage *rendered_im;
2837 ASImageLayer layers[2];
2839 init_image_layers(&(layers[0]), 2);
2841 layers[0].dst_x = 0;
2842 layers[0].dst_y = 0;
2843 layers[0].clip_width =
fImage->width;
2844 layers[0].clip_height =
fImage->height;
2845 layers[0].bevel = 0;
2846 layers[1].im = ((
TASImage*)im)->fImage;
2847 layers[1].dst_x =
x;
2848 layers[1].dst_y =
y;
2849 layers[1].clip_width = im->
GetWidth();
2850 layers[1].clip_height = im->
GetHeight();
2851 layers[1].merge_scanlines = blend_scanlines_name2func(op ? op :
"add");
2869 Warning(
"Blur",
"Visual not initiated");
2874 fImage = create_asimage(100, 100, 0);
2877 Warning(
"Blur",
"Failed to create image");
2884 ASImage *rendered_im = blur_asimage_gauss(
fgVisual,
fImage, hr > 0 ? hr : 3,
2885 vr > 0 ? vr : 3, SCL_DO_ALL,
2898 Warning(
"Clone",
"Image not initiated");
2905 Warning(
"Clone",
"Failed to create image");
2921 if (
fImage->alt.argb32) {
2923 im->
fImage->alt.argb32 = (ARGB32*)safemalloc(sz*
sizeof(ARGB32));
2924 memcpy(im->
fImage->alt.argb32,
fImage->alt.argb32, sz *
sizeof(ARGB32));
2944 Warning(
"Vectorize",
"Visual not initiated");
2949 fImage = create_asimage(100, 100, 0);
2952 Warning(
"Vectorize",
"Failed to create image");
2963 dither = dither > 7 ? 7 : dither;
2965 res = colormap_asimage(
fImage, &cmap, max_colors, dither, opaque_threshold);
2977 g = INDEX_SHIFT_GREEN(cmap.entries[res[i]].green);
2978 b = INDEX_SHIFT_BLUE(cmap.entries[res[i]].blue);
2979 r = INDEX_SHIFT_RED(cmap.entries[res[i]].red);
2981 v = MAKE_INDEXED_COLOR24(r,g,
b);
2991 for (
UInt_t j = 0; j < cmap.count; j++) {
2992 g = INDEX_SHIFT_GREEN(cmap.entries[j].green);
2993 b = INDEX_SHIFT_BLUE(cmap.entries[j].blue);
2994 r = INDEX_SHIFT_RED(cmap.entries[j].red);
2995 v = MAKE_INDEXED_COLOR24(r,g,
b);
2997 v = (v>>12) & 0x0FFF;
3000 pal->
fColorRed[j] = cmap.entries[j].red << 8;
3002 pal->
fColorBlue[j] = cmap.entries[j].blue << 8;
3006 destroy_colormap(&cmap,
kTRUE);
3009 fImage->alt.vector = vec;
3011 if (res)
delete res;
3057 Warning(
"HSV",
"Visual not initiated");
3062 fImage = create_asimage(width ? width : 20, height ? height : 20, 0);
3065 Warning(
"HSV",
"Failed to create image");
3074 width = !width ?
fImage->width : width;
3075 height = !height ?
fImage->height : height;
3077 ASImage *rendered_im = 0;
3080 rendered_im = adjust_asimage_hsv(
fgVisual,
fImage, x, y, width, height,
3081 hue, radius, H, S, V, ASA_ASImage, 100,
3082 ASIMAGE_QUALITY_TOP);
3085 Warning(
"HSV",
"Failed to create rendered image");
3120 Warning(
"Gradient",
"Visual not initiated");
3124 ASImage *rendered_im = 0;
3125 ASGradient gradient;
3127 int reverse = 0, npoints1 = 0, npoints2 = 0;
3134 if ((angle > 2 * 180 * 15 / 16) || (angle < 2 * 180 * 1 / 16)) {
3135 gradient.type = GRADIENT_Left2Right;
3136 }
else if (angle < 2 * 180 * 3 / 16) {
3137 gradient.type = GRADIENT_TopLeft2BottomRight;
3138 }
else if (angle < 2 * 180 * 5 / 16) {
3139 gradient.type = GRADIENT_Top2Bottom;
3140 }
else if (angle < 2 * 180 * 7 / 16) {
3141 gradient.type = GRADIENT_BottomLeft2TopRight; reverse = 1;
3142 }
else if (angle < 2 * 180 * 9 / 16) {
3143 gradient.type = GRADIENT_Left2Right; reverse = 1;
3144 }
else if (angle < 2 * 180 * 11 / 16) {
3145 gradient.type = GRADIENT_TopLeft2BottomRight; reverse = 1;
3146 }
else if (angle < 2 * 180 * 13 / 16) {
3147 gradient.type = GRADIENT_Top2Bottom; reverse = 1;
3149 gradient.type = GRADIENT_BottomLeft2TopRight;
3152 for (p = (
char*)colors; isspace((
int)*p); p++) { }
3154 for (npoints1 = 0; *p; npoints1++) {
3156 for ( ; *p && !isspace((
int)*p); p++) { }
3158 for ( ; isspace((
int)*p); p++) { }
3161 for (p = (
char*)offsets; isspace((
int)*p); p++) { }
3163 for (npoints2 = 0; *p; npoints2++) {
3165 for ( ; *p && !isspace((
int)*p); p++) { }
3167 for ( ; isspace((
int)*p); p++) { }
3172 if (offsets && (npoints1 > npoints2)) npoints1 = npoints2;
3181 gradient.color =
new ARGB32[npoints1];
3182 gradient.offset =
new double[npoints1];
3184 for (p = (
char*)
colors; isspace((
int)*p); p++) { }
3186 for (npoints1 = 0; *p; ) {
3190 for ( ; *p && !isspace((
int)*p); p++) { }
3192 for ( ; isspace((
int)*p); p++) { }
3194 col = str(pb - colors, p - pb);
3196 if (parse_argb_color(col.
Data(), gradient.color + npoints1) != col) {
3199 Warning(
"Gradient",
"Failed to parse color [%s] - defaulting to black", pb);
3204 for (p = (
char*)offsets; isspace((
int)*p); p++) { }
3206 for (npoints2 = 0; *p; ) {
3210 for ( ; *p && !isspace((
int)*p); p++) { }
3213 gradient.offset[npoints2] = strtod(pb, &pb);
3215 if (pb == p) npoints2++;
3217 for ( ; isspace((
int)*p); p++) { }
3220 for (npoints2 = 0; npoints2 < npoints1; npoints2++) {
3221 gradient.offset[npoints2] = (double)npoints2 / (npoints1 - 1);
3224 gradient.npoints = npoints1;
3226 if (npoints2 && (gradient.npoints > npoints2)) {
3227 gradient.npoints = npoints2;
3230 for (i = 0; i < gradient.npoints/2; i++) {
3231 int i2 = gradient.npoints - 1 - i;
3232 ARGB32 c = gradient.color[i];
3233 double o = gradient.offset[i];
3234 gradient.color[i] = gradient.color[i2];
3235 gradient.color[i2] = c;
3236 gradient.offset[i] = gradient.offset[i2];
3237 gradient.offset[i2] = o;
3239 for (i = 0; i < gradient.npoints; i++) {
3240 gradient.offset[i] = 1.0 - gradient.offset[i];
3243 rendered_im = make_gradient(
fgVisual, &gradient, width, height, SCL_DO_ALL,
3246 delete [] gradient.color;
3247 delete [] gradient.offset;
3251 Warning(
"Gradient",
"Failed to create gradient image");
3260 ASImageLayer layers[2];
3262 init_image_layers(&(layers[0]), 2);
3264 layers[0].dst_x = 0;
3265 layers[0].dst_y = 0;
3266 layers[0].clip_width =
fImage->width;
3267 layers[0].clip_height =
fImage->height;
3268 layers[0].bevel = 0;
3269 layers[1].im = rendered_im;
3270 layers[1].dst_x =
x;
3271 layers[1].dst_y =
y;
3272 layers[1].clip_width = width;
3273 layers[1].clip_height = height;
3274 layers[1].merge_scanlines = alphablend_scanlines;
3279 Warning(
"Gradient",
"Failed to create merged image");
3283 destroy_asimage(&rendered_im);
3298 cmp = (cmp * 12) / 10;
3300 return (cmp > 255) ? 255 : cmp;
3321 return (background >> 1) & 0x7F7F7F7F;
3332 a = ARGB32_ALPHA8(foreground) + ARGB32_ALPHA8(background);
3334 r = ARGB32_RED8(foreground) + ARGB32_RED8(background);
3336 g = ARGB32_GREEN8(foreground) + ARGB32_GREEN8(background);
3338 b = ARGB32_BLUE8(foreground) + ARGB32_BLUE8(background);
3341 return MAKE_ARGB32(a, r, g, b);
3357 const char *hi_color,
const char *lo_color,
UShort_t thick,
3361 Warning(
"Bevel",
"Visual not initiated");
3368 ARGB32
hi=ARGB32_White, lo=ARGB32_White;
3369 parse_argb_color(hi_color, &hi);
3370 parse_argb_color(lo_color, &lo);
3373 bevel.lo_color =
hi;
3375 bevel.hi_color = lo;
3378 bevel.hi_color =
hi;
3380 bevel.lo_color = lo;
3385 int extra_hilite = 2;
3386 bevel.left_outline = bevel.top_outline = bevel.right_outline = bevel.bottom_outline = thick;
3387 bevel.left_inline = bevel.top_inline = bevel.right_inline = bevel.bottom_inline = extra_hilite + 1;
3389 if (bevel.top_outline > 1) {
3390 bevel.top_inline += bevel.top_outline - 1;
3393 if (bevel.left_outline > 1) {
3394 bevel.left_inline += bevel.left_outline - 1;
3397 if (bevel.right_outline > 1) {
3398 bevel.right_inline += bevel.right_outline - 1;
3401 if (bevel.bottom_outline > 1) {
3402 bevel.bottom_inline += bevel.bottom_outline - 1;
3406 ARGB32
fill = ((hi>>24) != 0xff) || ((lo>>24) != 0xff) ? bevel.hilo_color : (bevel.hilo_color | 0xff000000);
3409 fImage = create_asimage(width ? width : 20, height ? height : 20, 0);
3412 Warning(
"Bevel",
"Failed to create image");
3421 width = !width ?
fImage->width : width;
3422 height = !height ?
fImage->height : height;
3424 ASImageLayer layers[2];
3425 init_image_layers(&(layers[0]), 2);
3428 layers[0].dst_x = 0;
3429 layers[0].dst_y = 0;
3430 layers[0].clip_width =
fImage->width;
3431 layers[0].clip_height =
fImage->height;
3432 layers[0].bevel = 0;
3434 UInt_t w = width - (bevel.left_outline + bevel.right_outline);
3435 UInt_t h = height - (bevel.top_outline + bevel.bottom_outline);
3436 ASImage *bevel_im = create_asimage(w, h, 0);
3439 Warning(
"Bevel",
"Failed to create bevel image");
3443 layers[1].im = bevel_im;
3444 fill_asimage(
fgVisual, bevel_im, 0, 0, w, h, fill);
3446 layers[1].dst_x =
x;
3447 layers[1].dst_y =
y;
3448 layers[1].clip_width = width;
3449 layers[1].clip_height = height;
3450 layers[1].bevel = &bevel;
3451 layers[1].merge_scanlines = alphablend_scanlines;
3455 destroy_asimage(&bevel_im);
3458 Warning(
"Bevel",
"Failed to image");
3478 Warning(
"Pad",
"Visual not initiated");
3483 fImage = create_asimage(100, 100, 0);
3486 Warning(
"Pad",
"Failed to create image");
3495 ARGB32 color = ARGB32_White;
3496 parse_argb_color(col, &color);
3507 Warning(
"Pad",
"Failed to create output image");
3524 Warning(
"Crop",
"Visual not initiated");
3536 width = x + width >
fImage->width ?
fImage->width - x : width;
3537 height = y + height >
fImage->height ?
fImage->height - y : height;
3539 if ((width ==
fImage->width) && (height ==
fImage->height)) {
3540 Warning(
"Crop",
"input size larger than image");
3543 ASImageDecoder *imdec = start_image_decoding(
fgVisual,
fImage, SCL_DO_ALL,
3544 x, y, width, height, 0);
3547 Warning(
"Crop",
"Failed to start image decoding");
3551 ASImage *img = create_asimage(width, height, 0);
3555 Warning(
"Crop",
"Failed to create image");
3559 ASImageOutput *imout = start_image_output(
fgVisual, img, ASA_ASImage,
3563 Warning(
"Crop",
"Failed to start image output");
3564 destroy_asimage(&img);
3565 if (imdec)
delete [] imdec;
3573 for (
UInt_t i = 0; i < height; i++) {
3574 imdec->decode_image_scanline(imdec);
3575 imout->output_image_scanline(imout, &(imdec->buffer), 1);
3578 stop_image_decoding(&imdec);
3579 stop_image_output(&imout);
3603 Warning(
"Append",
"Visual not initiated");
3620 Merge(im,
"alphablend", width, 0);
3621 }
else if (opt ==
"/") {
3623 Merge(im,
"alphablend", 0, height);
3642 Warning(
"BeginPaint",
"Visual not initiated");
3657 0, ASA_ARGB32, 0, ASIMAGE_QUALITY_DEFAULT);
3660 Warning(
"BeginPaint",
"Failed to create image");
3674 Warning(
"EndPaint",
"no image");
3678 if (!
fImage->alt.argb32)
return;
3681 0, ASA_ASImage, 0, ASIMAGE_QUALITY_DEFAULT);
3684 Warning(
"EndPaint",
"Failed to create image");
3701 Warning(
"GetArgbArray",
"no image");
3708 if (!img->alt.argb32) {
3718 return (
UInt_t *)img->alt.argb32;
3729 Warning(
"GetRgbaArray",
"no image");
3736 if (!img->alt.argb32) {
3754 for (i = 0; i < img->height; i++) {
3755 for (j = 0; j < img->width; j++) {
3757 argb = img->alt.argb32[idx];
3759 rgb = argb & 0x00ffffff;
3760 rgba = (rgb << 8) + a;
3775 Warning(
"GetScanline",
"no image");
3780 CARD32 *ret =
new CARD32[img->width];
3782 ASImageDecoder *imdec = start_image_decoding(
fgVisual, img, SCL_DO_ALL,
3783 0, y, img->width, 1, 0);
3787 Warning(
"GetScanline",
"Failed to start image decoding");
3795 imdec->decode_image_scanline(imdec);
3796 memcpy(imdec->buffer.buffer, ret, img->width*
sizeof(CARD32));
3797 stop_image_decoding(&imdec);
3812 #if defined(R__GNU) && defined(__i386__) && !defined(__sun)
3813 #define _MEMSET_(dst, lng, val) __asm__("movl %0,%%eax \n"\
3814 "movl %1,%%edi \n" \
3815 "movl %2,%%ecx \n" \
3820 :"g" (val), "g" (dst), "g" (lng) \
3821 :"eax","edi","ecx" \
3825 #define _MEMSET_(dst, lng, val) do {\
3826 for( UInt_t j=0; j < lng; j++) *((dst)+j) = val; } while (0)
3830 #define FillSpansInternal(npt, ppt, widths, color) do {\
3831 UInt_t yy = ppt[0].fY*fImage->width;\
3832 for (UInt_t i = 0; i < npt; i++) {\
3833 _MEMSET_(&fImage->alt.argb32[Idx(yy + ppt[i].fX)], widths[i], color);\
3834 yy += ((i+1 < npt) && (ppt[i].fY != ppt[i+1].fY) ? fImage->width : 0);\
3846 Warning(
"FillRectangle",
"Visual not initiated");
3851 Warning(
"FillRectangle",
"no image");
3855 if (!
fImage->alt.argb32) {
3859 if (!
fImage->alt.argb32) {
3860 Warning(
"FillRectangle",
"Failed to get pixel array");
3864 ARGB32 color = (ARGB32)col;
3866 if (width == 0) width = 1;
3867 if (height == 0) height = 1;
3878 Bool_t has_alpha = (color & 0xff000000) != 0xff000000;
3883 width = x + width >
fImage->width ?
fImage->width - x : width;
3884 height = y + height >
fImage->height ?
fImage->height - y : height;
3886 if (!
fImage->alt.argb32) {
3889 int yyy = y*
fImage->width;
3891 ARGB32 *p0 =
fImage->alt.argb32 + yyy +
x;
3893 for (
UInt_t i = 0; i < height; i++) {
3898 for (
UInt_t i = y; i < y + height; i++) {
3923 Warning(
"Fill",
"Visual not initiated");
3927 ARGB32 color = ARGB32_White;
3930 parse_argb_color(col, &color);
3934 fImage = create_asimage(width ? width : 20, height ? height : 20, 0);
3948 ARGB32 color = (ARGB32)col;
3951 if (!thick) thick = 1;
3959 thick += (x - half);
3965 x = x + thick >=
fImage->width ?
fImage->width - thick - 1 :
x;
3967 int yy = y1*
fImage->width;
3969 for (
UInt_t w = 0; w < thick; w++) {
3970 if (x + w < fImage->width) {
3983 ARGB32 color = (ARGB32)col;
3986 if (!thick) thick = 1;
3994 thick += (y - half);
3998 y = y + thick >=
fImage->height ?
fImage->height - thick - 1 :
y;
4002 int yy = y*
fImage->width;
4003 for (
UInt_t w = 0; w < thick; w++) {
4005 if (y + w < fImage->height) {
4017 const char *col,
UInt_t thick)
4019 ARGB32 color = ARGB32_White;
4020 parse_argb_color(col, &color);
4032 int x,
y, xend, yend;
4039 Warning(
"DrawLine",
"Visual not initiated");
4044 Warning(
"DrawLine",
"no image");
4048 if (!
fImage->alt.argb32) {
4052 if (!
fImage->alt.argb32) {
4053 Warning(
"DrawLine",
"Failed to get pixel array");
4057 ARGB32 color = (ARGB32)col;
4062 if (!dx && !dy)
return;
4066 y2 > y1 ? y2 : y1, color, thick);
4072 x2 > x1 ? x2 : x1, color, thick);
4084 i2 = i1 - (dx << 1);
4101 q = (y2 - y1) * ydir;
4134 i2 = i1 - (dy << 1);
4151 q = (x2 -
x1) * xdir;
4189 const char *col,
UInt_t thick)
4192 Warning(
"DrawRectangle",
"Visual not initiated");
4201 fImage = create_asimage(w, h, 0);
4206 if (!
fImage->alt.argb32) {
4210 if (!
fImage->alt.argb32) {
4211 Warning(
"DrawRectangle",
"Failed to get pixel array");
4215 ARGB32 color = ARGB32_White;
4216 parse_argb_color(col, &color);
4236 ARGB32 color = ARGB32_White;
4241 fImage = create_asimage(w, h, 0);
4247 parse_argb_color(col, &color);
4253 parse_argb_color(col, &color);
4283 ARGB32 color = (ARGB32)col;
4293 thick += (y - half);
4296 thick = thick <= 0 ? 1 : thick;
4298 y = y + thick >=
fImage->height ?
fImage->height - thick - 1 :
y;
4304 x1 = x2 < x1 ? x2 :
x1;
4305 x2 = x2 < tmp ? tmp :
x2;
4308 for (
UInt_t w = 0; w < thick; w++) {
4309 if (y + w < fImage->height) {
4317 if (i >= pDash[iDash]) {
4321 if (iDash >= nDash) {
4337 ARGB32 color = (ARGB32)col;
4347 thick += (x - half);
4350 thick = thick <= 0 ? 1 : thick;
4357 y1 = y2 < y1 ? y2 : y1;
4358 y2 = y2 < tmp ? tmp : y2;
4360 x = x + thick >=
fImage->width ?
fImage->width - thick - 1 :
x;
4362 int yy = y1*
fImage->width;
4364 for (
UInt_t w = 0; w < thick; w++) {
4365 if (x + w < fImage->width) {
4373 if (i >= pDash[iDash]) {
4377 if (iDash >= nDash) {
4393 int x,
y, xend, yend;
4403 char *pDash =
new char[nDash];
4408 for (i = 0; i < (int)nDash; i++) {
4414 i2 = i1 - (dx << 1);
4432 q = (y2 - y1) * ydir;
4437 if ((iDash%2) == 0) {
4449 if (i >= pDash[iDash]) {
4453 if (iDash >= nDash) {
4461 if ((iDash%2) == 0) {
4473 if (i >= pDash[iDash]) {
4477 if (iDash >= nDash) {
4486 for (i = 0; i < (int)nDash; i++) {
4492 i2 = i1 - (dy << 1);
4510 q = (x2 -
x1) * xdir;
4515 if ((iDash%2) == 0) {
4529 if (i >= pDash[iDash]) {
4533 if (iDash >= nDash) {
4541 if ((iDash%2) == 0) {
4555 if (i >= pDash[iDash]) {
4559 if (iDash >= nDash) {
4577 double x,
y, xend=0, yend=0, x0, y0;
4585 double *xDash =
new double[nDash];
4586 double *yDash =
new double[nDash];
4591 for (i = 0; i < (int)nDash; i++) {
4592 xDash[i] = tDash[i] * ac;
4593 yDash[i] = tDash[i] *
as;
4597 xDash[i] = xDash[i]/2;
4598 yDash[i] = yDash[i]/2;
4600 xDash[i] = xDash[i]*2;
4601 yDash[i] = yDash[i]*2;
4618 q = (y2 - y1) * ydir;
4625 while ((x < xend) && (y < yend)) {
4629 if ((iDash%2) == 0) {
4639 if (iDash >= nDash) {
4644 while ((x < xend) && (y > yend)) {
4648 if ((iDash%2) == 0) {
4658 if (iDash >= nDash) {
4677 q = (x2 -
x1) * xdir;
4684 while ((x < xend) && (y < yend)) {
4688 if ((iDash%2) == 0) {
4698 if (iDash >= nDash) {
4703 while ((x > xend) && (y < yend)) {
4707 if ((iDash%2) == 0) {
4717 if (iDash >= nDash) {
4731 const char *pDash,
const char *col,
UInt_t thick)
4735 Warning(
"DrawDashLine",
"Visual not initiated");
4740 Warning(
"DrawDashLine",
"no image");
4744 if (!
fImage->alt.argb32) {
4748 if (!
fImage->alt.argb32) {
4749 Warning(
"DrawDashLine",
"Failed to get pixel array");
4753 if ((nDash < 2) || !pDash || (nDash%2)) {
4754 Warning(
"DrawDashLine",
"Wrong input parameters n=%d %ld", nDash, (
Long_t)
sizeof(pDash)-1);
4758 ARGB32 color = ARGB32_White;
4759 parse_argb_color(col, &color);
4763 }
else if (y1 == y2) {
4777 ARGB32 color = ARGB32_White;
4778 parse_argb_color(col, &color);
4802 Warning(
"PutPixel",
"Visual not initiated");
4807 Warning(
"PutPixel",
"no image");
4811 if (!
fImage->alt.argb32) {
4815 if (!
fImage->alt.argb32) {
4816 Warning(
"PutPixel",
"Failed to get pixel array");
4821 parse_argb_color(col, &color);
4823 if ((x < 0) || (y < 0) || (x >= (
int)
fImage->width) || (y >= (
int)
fImage->height)) {
4824 Warning(
"PutPixel",
"Out of range width=%d x=%d, height=%d y=%d",
4837 Warning(
"PolyPoint",
"Visual not initiated");
4842 Warning(
"PolyPoint",
"no image");
4846 if (!
fImage->alt.argb32) {
4850 if (!
fImage->alt.argb32) {
4851 Warning(
"PolyPoint",
"Failed to get pixel array");
4856 Warning(
"PolyPoint",
"No points specified");
4863 parse_argb_color(col, &color);
4869 for (i = 0; i < npt; i++) {
4870 ipt[i].
fX += ppt[i].
fX;
4871 ipt[i].
fY += ppt[i].
fY;
4876 for (i = 0; i < npt; i++) {
4877 x = ipt ? ipt[i].
fX : ppt[i].
fX;
4878 y = ipt ? ipt[i].
fY : ppt[i].
fY;
4880 if ((x < 0) || (y < 0) || (x >= (
int)
fImage->width) || (y >= (
int)
fImage->height)) {
4896 if (!nseg || !seg) {
4897 Warning(
"DrawSegments",
"Invalid data nseg=%d seg=0x%lx", nseg, (
Long_t)seg);
4903 for (
UInt_t i = 0; i < nseg; i++) {
4904 pt[0].
fX = seg->
fX1;
4905 pt[1].
fX = seg->
fX2;
4906 pt[0].
fY = seg->
fY1;
4907 pt[1].
fY = seg->
fY2;
4921 Warning(
"FillSpans",
"Visual not initiated");
4926 Warning(
"FillSpans",
"no image");
4930 if (!
fImage->alt.argb32) {
4934 if (!
fImage->alt.argb32) {
4935 Warning(
"FillSpans",
"Failed to get pixel array");
4939 if (!npt || !ppt || !widths || (stipple && (!w || !h))) {
4940 Warning(
"FillSpans",
"Invalid input data npt=%d ppt=0x%lx col=%s widths=0x%lx stipple=0x%lx w=%d h=%d",
4946 parse_argb_color(col, &color);
4951 for (
UInt_t i = 0; i < npt; i++) {
4953 for (
UInt_t j = 0; j < widths[i]; j++) {
4954 if ((ppt[i].fX >= (
Int_t)
fImage->width) || (ppt[i].
fX < 0) ||
4965 if (stipple[ii >> 3] & (1 << (ii%8))) {
4979 Warning(
"FillSpans",
"Visual not initiated");
4984 Warning(
"FillSpans",
"no image");
4988 if (!
fImage->alt.argb32) {
4992 if (!
fImage->alt.argb32) {
4993 Warning(
"FillSpans",
"Failed to get pixel array");
4997 if (!npt || !ppt || !widths || !tile) {
4998 Warning(
"FillSpans",
"Invalid input data npt=%d ppt=0x%lx widths=0x%lx tile=0x%lx",
5012 for (
UInt_t i = 0; i < npt; i++) {
5015 for (
UInt_t j = 0; j < widths[i]; j++) {
5016 if ((ppt[i].fX >= (
Int_t)
fImage->width) || (ppt[i].
fX < 0) ||
5035 Warning(
"CropSpans",
"Visual not initiated");
5040 Warning(
"CropSpans",
"no image");
5044 if (!
fImage->alt.argb32) {
5048 if (!
fImage->alt.argb32) {
5049 Warning(
"CropSpans",
"Failed to get pixel array");
5053 if (!npt || !ppt || !widths) {
5054 Warning(
"CropSpans",
"No points specified npt=%d ppt=0x%lx widths=0x%lx", npt, (
Long_t)ppt, (
Long_t)widths);
5059 int y1 = ppt[npt-1].
fY;
5067 for (y = 0; (int)y < y0; y++) {
5068 for (x = 0; x <
fImage->width; x++) {
5070 if (idx < sz)
fImage->alt.argb32[idx] = 0;
5075 for (i = 0; i < npt; i++) {
5076 for (x = 0; (int)x < ppt[i].fX; x++) {
5078 if (idx < sz)
fImage->alt.argb32[idx] = 0;
5080 for (x = ppt[i].fX + widths[i] + 1; x <
fImage->width; x++) {
5082 if (idx < sz)
fImage->alt.argb32[idx] = 0;
5087 for (y = y1; y <
fImage->height; y++) {
5088 for (x = 0; x <
fImage->width; x++) {
5090 if (idx < sz)
fImage->alt.argb32[idx] = 0;
5124 Warning(
"CopyArea",
"Visual not initiated");
5129 Warning(
"CopyArea",
"no image");
5134 ASImage *out = ((
TASImage*)dst)->GetImage();
5140 xsrc = xsrc < 0 ? 0 : xsrc;
5141 ysrc = ysrc < 0 ? 0 : ysrc;
5143 if ((xsrc >= (
int)
fImage->width) || (ysrc >= (
int)
fImage->height))
return;
5145 w = xsrc + w >
fImage->width ?
fImage->width - xsrc : w;
5149 if (!
fImage->alt.argb32) {
5152 if (!out->alt.argb32) {
5154 out = ((
TASImage*)dst)->GetImage();
5157 if (
fImage->alt.argb32 && out->alt.argb32) {
5158 for (y = 0; y < (int)h; y++) {
5159 for (x = 0; x < (int)w; x++) {
5160 idx =
Idx(yy + x + xsrc);
5161 if ((x + xdst < 0) || (ydst + y < 0) ||
5162 (x + xdst >= (
int)out->width) || (y + ydst >= (
int)out->height) )
continue;
5164 idx2 =
Idx((ydst + y)*out->width + x + xdst);
5168 out->alt.argb32[idx2] = 0;
5171 out->alt.argb32[idx2] &=
fImage->alt.argb32[idx];
5174 out->alt.argb32[idx2] =
fImage->alt.argb32[idx] & (~out->alt.argb32[idx2]);
5177 out->alt.argb32[idx2] &= ~
fImage->alt.argb32[idx];
5182 out->alt.argb32[idx2] ^=
fImage->alt.argb32[idx];
5185 out->alt.argb32[idx2] |=
fImage->alt.argb32[idx];
5188 out->alt.argb32[idx2] = (~
fImage->alt.argb32[idx]) & (~out->alt.argb32[idx2]);
5191 out->alt.argb32[idx2] ^= ~
fImage->alt.argb32[idx];
5194 out->alt.argb32[idx2] = ~out->alt.argb32[idx2];
5197 out->alt.argb32[idx2] =
fImage->alt.argb32[idx] | (~out->alt.argb32[idx2]);
5200 out->alt.argb32[idx2] = ~
fImage->alt.argb32[idx];
5203 out->alt.argb32[idx2] |= ~
fImage->alt.argb32[idx];
5206 out->alt.argb32[idx2] = (~
fImage->alt.argb32[idx]) | (~out->alt.argb32[idx2]);
5209 out->alt.argb32[idx2] = 0xFFFFFFFF;
5213 out->alt.argb32[idx2] =
fImage->alt.argb32[idx];
5237 int i, j, ix, iy, w,
h;
5239 ARGB32 color = 0xFFFFFFFF;
5246 for (i = 0; i <
nx; i++) {
5248 for (j = 0; j <
ny; j++) {
5249 icol = (ARGB32)ic[i + (nx*j)];
5250 if (icol != color) {
5289 ymin = ymax = (pts++)->fY;
5292 if (pts->
fY < ymin) {
5296 if (pts->
fY > ymax) {
5304 return (ptMin - ptsStart);
5320 int mr = 0, m1r = 0;
5321 int incr1l = 0, incr2l = 0;
5322 int incr1r = 0, incr2r = 0;
5327 int nextleft, nextright;
5340 Warning(
"GetPolygonSpans",
"Visual not initiated");
5345 Warning(
"GetPolygonSpans",
"no image");
5349 if (!
fImage->alt.argb32) {
5353 if (!
fImage->alt.argb32) {
5354 Warning(
"GetPolygonSpans",
"Failed to get pixel array");
5358 if ((npt < 3) || !ppt) {
5359 Warning(
"GetPolygonSpans",
"No points specified npt=%d ppt=0x%lx", npt, (
Long_t)ppt);
5367 dy = ymax - ymin + 1;
5368 if ((npt < 3) || (dy < 0))
return kFALSE;
5370 ptsOut = firstPoint =
new TPoint[dy];
5371 width = firstWidth =
new UInt_t[dy];
5374 nextleft = nextright = imin;
5375 y = ppt[nextleft].
fY;
5380 if (ppt[nextleft].fY == y) {
5386 if (nextleft >= (
int)npt) {
5393 ppt[left].fX, ppt[nextleft].fX,
5394 xl, dl, ml, m1l, incr1l, incr2l);
5398 if (ppt[nextright].fY == y) {
5404 if (nextright < 0) {
5411 ppt[right].fX, ppt[nextright].fX,
5412 xr, dr, mr, m1r, incr1r, incr2r);
5417 i =
TMath::Min(ppt[nextleft].fY, ppt[nextright].fY) -
y;
5421 delete [] firstWidth;
5422 delete [] firstPoint;
5431 *(width++) = xr - xl;
5432 (ptsOut++)->fX = xl;
5434 *(width++) = xl - xr;
5435 (ptsOut++)->fX = xr;
5443 }
while (y != ymax);
5445 *nspans =
UInt_t(ptsOut - firstPoint);
5446 *outPoint = firstPoint;
5447 *outWidth = firstWidth;
5464 ARGB32 color = ARGB32_White;
5465 parse_argb_color(col, &color);
5468 if (!stipple && ((color & 0xff000000)==0xff000000)) {
5471 FillSpans(nspans, firstPoint, firstWidth, col, stipple, w, h);
5475 delete [] firstWidth;
5476 delete [] firstPoint;
5479 if (firstWidth)
delete [] firstWidth;
5480 if (firstPoint)
delete [] firstPoint;
5497 FillSpans(nspans, firstPoint, firstWidth, tile);
5500 delete [] firstWidth;
5501 delete [] firstPoint;
5504 if (firstWidth)
delete [] firstWidth;
5505 if (firstPoint)
delete [] firstPoint;
5521 CropSpans(nspans, firstPoint, firstWidth);
5524 delete [] firstWidth;
5525 delete [] firstPoint;
5528 if (firstWidth)
delete [] firstWidth;
5529 if (firstPoint)
delete [] firstPoint;
5542 Warning(
"DrawFillArea",
"Visual not initiated");
5547 Warning(
"DrawFillArea",
"no image");
5551 if (!
fImage->alt.argb32) {
5555 if (!
fImage->alt.argb32) {
5556 Warning(
"DrawFillArea",
"Failed to get pixel array");
5560 if ((count < 3) || !ptsIn) {
5561 Warning(
"DrawFillArea",
"No points specified npt=%d ppt=0x%lx", count, (
Long_t)ptsIn);
5570 ARGB32 color = ARGB32_White;
5571 parse_argb_color(col, &color);
5589 static const UInt_t gEdgeTableEntryCacheSize = 200;
5590 static EdgeTableEntry gEdgeTableEntryCache[gEdgeTableEntryCacheSize];
5592 if (count < gEdgeTableEntryCacheSize) {
5600 ptsOut = firstPoint;
5603 pSLL = ET.scanlines.next;
5605 for (y = ET.ymin; y < ET.ymax; y++) {
5606 if (pSLL && y == pSLL->scanline) {
5607 loadAET(&AET, pSLL->edgelist);
5614 ptsOut->
fX = pAET->bres.minor_axis;
5619 *width++ = pAET->next->bres.minor_axis - pAET->bres.minor_axis;
5622 if (!stipple && ((color & 0xff000000)==0xff000000)) {
5625 FillSpans(nPts, firstPoint, firstWidth, col, stipple, w, h);
5627 ptsOut = firstPoint;
5638 if (!stipple && ((color & 0xff000000)==0xff000000)) {
5641 FillSpans(nPts, firstPoint, firstWidth, col, stipple, w, h);
5645 if (del)
delete [] pETEs;
5655 Warning(
"DrawFillArea",
"Visual not initiated");
5660 Warning(
"DrawFillArea",
"no image");
5664 if (!
fImage->alt.argb32) {
5668 if (!
fImage->alt.argb32) {
5669 Warning(
"DrawFillArea",
"Failed to get pixel array");
5673 if ((count < 3) || !ptsIn) {
5674 Warning(
"DrawFillArea",
"No points specified npt=%d ppt=0x%lx", count, (
Long_t)ptsIn);
5700 ptsOut = firstPoint;
5703 pSLL = ET.scanlines.next;
5705 for (y = ET.ymin; y < ET.ymax; y++) {
5706 if (pSLL && y == pSLL->scanline) {
5707 loadAET(&AET, pSLL->edgelist);
5714 ptsOut->
fX = pAET->bres.minor_axis;
5719 *width++ = pAET->next->bres.minor_axis - pAET->bres.minor_axis;
5722 FillSpans(nPts, firstPoint, firstWidth, tile);
5723 ptsOut = firstPoint;
5732 FillSpans(nPts, firstPoint, firstWidth, tile);
5743 ASDrawContext *ctx =
new ASDrawContext;
5745 ctx->canvas_width = im->width;
5746 ctx->canvas_height = im->height;
5747 ctx->canvas = im->alt.argb32;
5748 ctx->scratch_canvas = 0;
5750 ctx->flags = ASDrawCTX_CanvasIsARGB;
5751 asim_set_custom_brush_colored( ctx, brush);
5761 if (ctx->scratch_canvas)
free(ctx->scratch_canvas);
5775 Int_t sz = thick*thick;
5782 matrix =
new CARD32[sz];
5785 for (
int i = 0; i < sz; i++) {
5786 matrix[i] = (CARD32)color;
5790 brush.matrix = matrix;
5791 brush.width = thick;
5792 brush.height = thick;
5793 brush.center_y = brush.center_x = thick/2;
5802 if (xx1 ==
fImage->width) --xx1;
5803 if (yy1 ==
fImage->height) --yy1;
5804 if (xx2 ==
fImage->width) --xx2;
5805 if (yy2 ==
fImage->height) --yy2;
5807 asim_move_to(ctx, xx1, yy1);
5808 asim_line_to(ctx, xx2, yy2);
5823 Bool_t has_alpha = (color & 0xff000000) != 0xff000000;
5827 FT_Bitmap *source = (FT_Bitmap*)bitmap;
5828 UChar_t d = 0, *s = source->buffer;
5830 Int_t dots =
Int_t(source->width * source->rows);
5834 yy = y0 = by > 0 ? by *
fImage->width : 0;
5835 for (y = 0; y < (int) source->rows; y++) {
5837 if ((byy >= (
int)
fImage->height) || (byy <0))
continue;
5839 for (x = 0; x < (int) source->width; x++) {
5841 if ((bxx >= (
int)
fImage->width) || (bxx < 0))
continue;
5843 idx =
Idx(bxx + yy);
5844 r += ((
fImage->alt.argb32[idx] & 0xff0000) >> 16);
5845 g += ((
fImage->alt.argb32[idx] & 0x00ff00) >> 8);
5846 b += (
fImage->alt.argb32[idx] & 0x0000ff);
5856 col[0] = (r << 16) + (g << 8) +
b;
5858 Int_t col4r = (col[4] & 0xff0000) >> 16;
5859 Int_t col4g = (col[4] & 0x00ff00) >> 8;
5860 Int_t col4b = (col[4] & 0x0000ff);
5863 for (x = 3; x > 0; x--) {
5865 Int_t colxr = (col4r*x + r*xx) >> 2;
5866 Int_t colxg = (col4g*x + g*xx) >> 2;
5867 Int_t colxb = (col4b*x + b*xx) >> 2;
5868 col[
x] = (colxr << 16) + (colxg << 8) + colxb;
5874 Int_t clipx1=0, clipx2=0, clipy1=0, clipy2=0;
5878 clipx1 =
gPad->XtoAbsPixel(
gPad->GetX1());
5879 clipx2 =
gPad->XtoAbsPixel(
gPad->GetX2());
5880 clipy1 =
gPad->YtoAbsPixel(
gPad->GetY1());
5881 clipy2 =
gPad->YtoAbsPixel(
gPad->GetY2());
5885 for (y = 0; y < (int) source->rows; y++) {
5888 for (x = 0; x < (int) source->width; x++) {
5892 d = ((d + 10) * 5) >> 8;
5896 if ( noClip || ((x < (
int) source->width) &&
5897 (bxx < (
int)clipx2) && (bxx >= (
int)clipx1) &&
5898 (byy >= (
int)clipy2) && (byy < (
int)clipy1) )) {
5899 idx =
Idx(bxx + yy);
5900 acolor = (ARGB32)col[d];
5904 fImage->alt.argb32[idx] = acolor;
5923 Warning(
"DrawText",
"Visual not initiated");
5927 if (!
fImage->alt.argb32) {
5952 const wchar_t *wcsTitle =
reinterpret_cast<const wchar_t *
>(text->
GetWcsTitle());
5953 if (wcsTitle !=
NULL) {
5963 col =
gROOT->GetColor(1);
5966 ARGB32 color = ARGB32_White;
6020 if (align == 1 || align == 2 || align == 3) {
6022 }
else if (align == 4 || align == 5 || align == 6) {
6029 if (align == 3 || align == 6 || align == 9) {
6031 }
else if (align == 2 || align == 5 || align == 8) {
6038 ftal.x = (ftal.x >> 6);
6039 ftal.y = (ftal.y >> 6);
6044 if (FT_Glyph_To_Bitmap(&glyph->
fImage, ft_render_mode_normal, 0, 1 ))
continue;
6046 FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph->
fImage;
6047 FT_Bitmap *source = &bitmap->bitmap;
6049 Int_t bx = x - ftal.x + bitmap->left;
6050 Int_t by = y + ftal.y - bitmap->top;
6078 if (FT_Glyph_To_Bitmap(&glyph->
fImage, ft_render_mode_normal, 0, 1 ))
continue;
6080 FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph->
fImage;
6081 FT_Bitmap *source = &bitmap->bitmap;
6083 Int_t bx = x + bitmap->left;
6084 Int_t by = y + h - bitmap->top;
6096 static ASImageExportParams params;
6106 ret = ASImage2xpmRawBuff(img, (CARD8 **)buffer, size, 0);
6109 ret = ASImage2PNGBuff(img, (CARD8 **)buffer, size, ¶ms);
6150 static ASImageImportParams params;
6154 params.filter = SCL_DO_ALL;
6156 params.gamma_table = 0;
6157 params.compression = 0;
6158 params.format = ASA_ASImage;
6159 params.search_path = 0;
6160 params.subimage = 0;
6165 char *ptr = buffer[0];
6166 while (isspace((
int)*ptr)) ++ptr;
6168 fImage = xpm_data2ASImage((
const char**)buffer, ¶ms);
6170 fImage = xpmRawBuff2ASImage((
const char*)*buffer, ¶ms);
6175 fImage = PNGBuff2ASimage((CARD8 *)*buffer, ¶ms);
6206 static char *buf = 0;
6228 ASImage *rendered_im;
6229 ASImageLayer layers[2];
6230 init_image_layers(&(layers[0]), 2);
6232 layers[0].dst_x = 0;
6233 layers[0].dst_y = 0;
6234 layers[0].clip_width = img->width;
6235 layers[0].clip_height = img->height;
6236 layers[0].bevel = 0;
6238 layers[1].dst_x = 0;
6239 layers[1].dst_y = 0;
6240 layers[1].clip_width = img->width;
6241 layers[1].clip_height = img->height;
6242 layers[1].merge_scanlines = blend_scanlines_name2func(
"tint");
6243 rendered_im = merge_layers(
fgVisual, &(layers[0]), 2, img->width, img->height,
6245 destroy_asimage(&img);
6249 ASImage *padimg = 0;
6254 padimg = pad_asimage(
fgVisual, img, 0, d, sz, sz, 0x00ffffff,
6258 padimg = pad_asimage(
fgVisual, img, d, 0, sz, sz, 0x00ffffff,
6263 destroy_asimage(&img);
6268 ASImage2xpmRawBuff(padimg, (CARD8 **)ptr, &size, 0);
6271 destroy_asimage(&padimg);
6277 void TASImage::Streamer(
TBuffer &
b)
6291 if ( version == 1 ) {
6293 if (fileVersion > 0 && fileVersion < 50000 ) {
6294 TImage::Streamer(b);
6301 if ( fileVersion < 40200 ) {
6317 TNamed::Streamer(b);
6320 if (image_type != 0) {
6322 buffer =
new char[size];
6327 TAttImage::Streamer(b);
6346 TNamed::Streamer(b);
6348 image_type =
fImage->alt.vector ? 0 : 1;
6351 if (image_type != 0) {
6357 TAttImage::Streamer(b);
6371 if (
fImage->alt.vector) {
6413 if ((start > 0) && (stop - start > 0)) {
6424 Int_t sz = thick*thick;
6428 ARGB32 color = ARGB32_White;
6429 parse_argb_color(col, &color);
6434 matrix =
new CARD32[sz];
6437 for (
int i = 0; i < sz; i++) {
6438 matrix[i] = (CARD32)color;
6442 brush.matrix = matrix;
6443 brush.width = thick;
6444 brush.height = thick;
6445 brush.center_y = brush.center_x = thick/2;
6447 ASDrawContext *ctx = 0;
6450 asim_cube_bezier(ctx, x1, y1, x2, y2, x3, y3);
6463 const char *col,
Int_t thick)
6465 thick = !thick ? 1 : thick;
6466 Int_t sz = thick*thick;
6470 ARGB32 color = ARGB32_White;
6471 parse_argb_color(col, &color);
6476 matrix =
new CARD32[sz];
6479 for (
int i = 0; i < sz; i++) {
6480 matrix[i] = (CARD32)color;
6484 brush.matrix = matrix;
6485 brush.width = thick > 0 ? thick : 1;
6486 brush.height = thick > 0 ? thick : 1;
6487 brush.center_y = brush.center_x = thick > 0 ? thick/2 : 0;
6490 asim_straight_ellips(ctx, x, y, rx, ry, thick < 0);
6504 thick = !thick ? 1 : thick;
6505 Int_t sz = thick*thick;
6509 ARGB32 color = ARGB32_White;
6510 parse_argb_color(col, &color);
6516 matrix =
new CARD32[sz];
6519 for (
int i = 0; i < sz; i++) {
6520 matrix[i] = (CARD32)color;
6524 brush.matrix = matrix;
6525 brush.height = brush.width = thick > 0 ? thick : 1;
6526 brush.center_y = brush.center_x = thick > 0 ? thick/2 : 0;
6529 asim_circle(ctx, x, y, r, thick < 0);
6543 const char *col,
Int_t thick)
6545 thick = !thick ? 1 : thick;
6546 Int_t sz = thick*thick;
6550 ARGB32 color = ARGB32_White;
6551 parse_argb_color(col, &color);
6556 matrix =
new CARD32[sz];
6559 for (
int i = 0; i < sz; i++) {
6560 matrix[i] = (CARD32)color;
6564 brush.matrix = matrix;
6565 brush.width = thick > 0 ? thick : 1;
6566 brush.height = thick > 0 ? thick : 1;
6567 brush.center_y = brush.center_x = thick > 0 ? thick/2 : 0;
6570 asim_ellips(ctx, x, y, rx, ry, angle, thick < 0);
6583 const char *col,
Int_t thick)
6585 thick = !thick ? 1 : thick;
6586 Int_t sz = thick*thick;
6590 ARGB32 color = ARGB32_White;
6591 parse_argb_color(col, &color);
6596 matrix =
new CARD32[sz];
6599 for (
int i = 0; i < sz; i++) {
6600 matrix[i] = (CARD32)color;
6604 brush.matrix = matrix;
6605 brush.width = thick > 0 ? thick : 1;
6606 brush.height = thick > 0 ? thick : 1;
6607 brush.center_y = brush.center_x = thick > 0 ? thick/2 : 0;
6610 asim_ellips2(ctx, x, y, rx, ry, angle, thick < 0);
6622 const char * ,
const char * )
6636 Warning(
"Gray",
"Image not initiated");
6641 Warning(
"Gray",
"Visual not initiated");
6666 if (
fImage->alt.argb32) {
6668 0, ASA_ARGB32, 0, ASIMAGE_QUALITY_DEFAULT);
6670 for (i = 0; i <
fImage->height; i++) {
6671 for (j = 0; j <
fImage->width; j++) {
6674 r = ((
fImage->alt.argb32[idx] & 0xff0000) >> 16);
6675 g = ((
fImage->alt.argb32[idx] & 0x00ff00) >> 8);
6676 b = (
fImage->alt.argb32[idx] & 0x0000ff);
6677 l = (57*r + 181*g + 18*
b)/256;
6678 fGrayImage->alt.argb32[idx] = (l << 16) + (l << 8) +
l;
6685 ASImageDecoder *imdec = start_image_decoding(
fgVisual,
fImage, SCL_DO_ALL,
6697 Warning(
"ToGray",
"Failed to start image output");
6704 CARD32 *aa = imdec->buffer.alpha;
6705 CARD32 *rr = imdec->buffer.red;
6706 CARD32 *gg = imdec->buffer.green;
6707 CARD32 *bb = imdec->buffer.blue;
6712 for (i = 0; i <
fImage->height; i++) {
6713 imdec->decode_image_scanline(imdec);
6714 result.flags = imdec->buffer.flags;
6715 result.back_color = imdec->buffer.back_color;
6717 for (j = 0; j <
fImage->width; j++) {
6718 l = (57*rr[j] + 181*gg[j]+ 18*bb[j])/256;
6719 result.alpha[j] = aa[j];
6721 result.green[j] =
l;
6724 imout->output_image_scanline(imout, &result, 1);
6727 stop_image_decoding(&imdec);
6728 stop_image_output(&imout);
6759 gVirtualX->GetWindowSize(wid, xy, xy, w, h);
6767 Warning(
"FromWindow",
"Visual not initiated");
6775 static int x11 = -1;
6776 if (x11 < 0) x11 =
gVirtualX->InheritsFrom(
"TGX11");
6781 unsigned char *bits =
gVirtualX->GetColorBits(wid, 0, 0, w, h);
6786 fImage = bitmap2asimage(bits, w, h, 0, 0);
6801 for (
UInt_t i = 0; i < h/2; ++i) {
6802 memcpy(xx, buf + 4*w*i, 4*w);
6803 memcpy(buf + 4*w*i, buf + 4*w*(h-i-1), 4*w);
6804 memcpy(buf + 4*w*(h-i-1), xx, 4*w);
6808 fImage = bitmap2asimage(buf, w, h, 0, 0);
6821 if (!
fImage->alt.vector && on) {
6832 gPad->Range(-left / (1.0 - left - right),
6833 -bottom / (1.0 - top - bottom),
6834 1 + right / (1.0 - left - right),
6835 1 + top / ( 1.0 - top - bottom));
6836 gPad->RangeAxis(0, 0, 1, 1);
6872 out << std::endl << str << std::endl << std::endl;
6875 out << xpm <<
"_img = TImage::Create();" << std::endl;
6876 out <<
" " << xpm <<
"_img->SetImageBuffer( (char **)" << xpm <<
", TImage::kXpm);" << std::endl;
6877 out <<
" " << xpm <<
"_img->Draw();" << std::endl;
6890 static char buf[32];
6891 FILE *fp = fopen(name,
"rb+");
6894 printf(
"file %s : failed to open\n", name);
6898 if (!fread(buf, 1, 20, fp)) {
6903 char dpi1 = (set & 0xffff) >> 8;
6904 char dpi2 = set & 0xff;
6909 for (i = 0; i < 20; i++) {
6910 if ((buf[i] == 0x4a) && (buf[i+1] == 0x46) && (buf[i+2] == 0x49) &&
6911 (buf[i+3] == 0x46) && (buf[i+4] == 0x00) ) {
6917 if (i == 20 || dpi+4 >= 20) {
6919 printf(
"file %s : wrong JPEG format\n", name);
6926 buf[dpi + 1] = dpi1;
6927 buf[dpi + 2] = dpi2;
6930 buf[dpi + 3] = dpi1;
6931 buf[dpi + 4] = dpi2;
6934 fwrite(buf, 1, 20, fp);
void SetTitle(const char *title="")
Set a title for an image.
Double_t * Vectorize(UInt_t max_colors=256, UInt_t dither=4, Int_t opaque_threshold=1)
Reduce color-depth of an image and fills vector of "scientific data" [0...1].
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
virtual const char * GetTitle() const
Returns title of object.
#define EVALUATEEDGEEVENODD(pAET, pPrevAET, y)
static void Init()
Initialise the TrueType fonts interface.
Double_t * fPoints
[fNumPoints] value of each anchor point [0..1]
UInt_t GetScaledHeight() const
Return height of the displayed image not of the original image.
static void FreeStorage(ScanLineListBlock *pSLLBlock)
void GetZoomPosition(UInt_t &x, UInt_t &y, UInt_t &w, UInt_t &h) const
Return the zoom parameters.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
virtual Float_t GetTextAngle() const
Return the text angle.
virtual void CellArrayFill(Int_t r, Int_t g, Int_t b)=0
static ASFontManager * gFontManager
static void init_icon_paths()
Set icons paths.
virtual Font_t GetTextFont() const
Return the text font.
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)
Draw a dashed line with thick pixel width.
void PutPixel(Int_t x, Int_t y, const char *col="#000000")
Draw a point at the specified position.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
static ARGB32 GetAverage(ARGB32 foreground, ARGB32 background)
Get average.
virtual void Paint(Option_t *option="")=0
This method must be overridden if a class wants to paint itself.
static Bool_t InitVisual()
Static function to initialize the ASVisual.
UInt_t GetWidth() const
Return width of original image not of the displayed image.
void SetPaletteEnabled(Bool_t on=kTRUE)
Switch on/off the image palette.
virtual void SetBorderMode(Short_t bordermode)
Bool_t IsEditable() const
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)
Draw a box.
static const TString & GetIconPath()
Get the icon path in the installation. Static utility function.
const char * GetTitle() const
Title is used to keep 32x32 xpm image's thumbnail.
static const ASVisual * GetVisual()
Return visual.
TString & ReplaceAll(const TString &s1, const TString &s2)
EImageFileTypes GetFileType(const char *ext)
Return file type depending on specified extension.
R__EXTERN TStyle * gStyle
static Bool_t IsInitialized()
FT_Glyph fImage
glyph image
UInt_t GetHeight() const
Return height of original image not of the displayed image.
virtual void SetName(const char *name)
Set the name of the TNamed.
void Draw(Option_t *option="")
Draw image.
static unsigned long kAllPlanes
void DrawRectangle(UInt_t x, UInt_t y, UInt_t w, UInt_t h, const char *col="#000000", UInt_t thick=1)
Draw a rectangle.
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)
Copy source region to the destination image.
virtual const char * HomeDirectory(const char *userName=0)
Return the user's home directory.
Buffer base class used for serializing objects.
virtual Float_t GetTextSize() const
Return the text size.
virtual UInt_t * GetArgbArray()
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
Bool_t fEditable
! kTRUE image can be resized, moved by resizing/moving gPad
UInt_t * GetArgbArray()
Return a pointer to internal array[width x height] of ARGB32 values This array is directly accessible...
virtual UInt_t GetWidth() const
Int_t LoadPlugin()
Load the plugin library for this handler.
Short_t Min(Short_t a, Short_t b)
void ToLower()
Change string to lower-case.
void StartPaletteEditor()
Start palette editor.
TObject * Clone(const char *newname) const
Clone image.
void ReadImage(const char *file, EImageFileTypes type=TImage::kUnknown)
Read specified image file.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
virtual void SetX1(Double_t x1)
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
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.
virtual void CellArrayEnd()=0
void FromPad(TVirtualPad *pad, Int_t x=0, Int_t y=0, UInt_t w=0, UInt_t h=0)
Create an image from the given pad, afterwards this image can be saved in any of the supported image ...
An abstract interface to image processing library.
virtual void Merge(const TImage *, const char *="alphablend", Int_t=0, Int_t=0)
void Browse(TBrowser *)
Browse image.
void CreateThumbnail()
Create image thumbnail.
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
void DrawLine(UInt_t x1, UInt_t y1, UInt_t x2, UInt_t y2, const char *col="#000000", UInt_t thick=1)
Draw a line.
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)
Draw a cubic bezier line.
virtual void SetX2(Double_t x2)
Long_t ExecPlugin(int nargs, const T &...params)
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Bool_t fPaletteEnabled
! kTRUE - palette is drawn on the image
UInt_t * GetScanline(UInt_t y)
Return a pointer to scan-line.
void DrawTextTTF(Int_t x, Int_t y, const char *text, Int_t size, UInt_t color, const char *font_name, Float_t angle)
Draw text using TrueType fonts.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
static CARD32 gBrushCache[kBrushCacheSize *kBrushCacheSize]
static ARGB32 GetShadow(ARGB32 background)
Calculate shadow color.
UShort_t * fColorRed
[fNumPoints] red color at each anchor point
Double_t * GetVecArray()
Return a pointer to internal array[width x height] of double values [0,1].
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Bool_t SetImageBuffer(char **buffer, EImageFileTypes type=TImage::kPng)
Create image from compressed buffer.
static THashTable * fgPlugList
! hash table containing loaded plugins
void PolyPoint(UInt_t npt, TPoint *ppt, const char *col="#000000", TImage::ECoordMode mode=kCoordModeOrigin)
Draw a poly point.
const char * Data() const
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
EImageQuality GetImageQuality() const
Int_t DistancetoPrimitive(Int_t px, Int_t py)
Is the mouse in the image ?
void Paint(Option_t *option="")
Paint image.
static const double x2[5]
Int_t Idx(Int_t idx)
Return a valid index in fImage tables to avoid seg-fault by accessing out of indices out of array's r...
virtual Short_t GetTextAlign() const
Return the text alignment.
THashTable implements a hash table to store TObject's.
static void LayoutGlyphs()
Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
virtual const char * GetName() const =0
Returns name of object.
void BeginPaint(Bool_t fast=kTRUE)
BeginPaint initializes internal array[width x height] of ARGB32 pixel values.
static void SetTextFont(Font_t fontnumber)
virtual Int_t GetVersionOwner() const =0
void EndPaint()
EndPaint does internal RLE compression of image data.
#define BRESINCRPGON(d, minval, m, m1, incr1, incr2)
static void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
virtual Color_t GetTextColor() const
Return the text color.
void DrawCellArray(Int_t x1, Int_t y1, Int_t x2, Int_t y2, Int_t nx, Int_t ny, UInt_t *ic)
Draw a cell array.
void MapFileTypes(EImageFileTypes &type, UInt_t &astype, Bool_t toas=kTRUE)
Map file type to/from AfterImage types.
TArrayD * GetArray(UInt_t w=0, UInt_t h=0, TImagePalette *pal=gWebImagePalette)
In case of vectorized image return an associated array of doubles otherwise this method creates and r...
UInt_t fZoomOffY
! Y - offset for zooming im image pixels
void Gray(Bool_t on=kTRUE)
Convert RGB image to Gray image and vice versa.
virtual UInt_t Integer(UInt_t imax)
Returns a random integer on [ 0, imax-1 ].
static UInt_t AlphaBlend(UInt_t bot, UInt_t top)
Return alpha-blended value computed from bottom and top pixel values.
static void loadAET(EdgeTableEntry *AET, EdgeTableEntry *ETEs)
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
void WriteImage(const char *file, EImageFileTypes type=TImage::kUnknown)
Write image to specified file.
Base class for several text objects.
UInt_t GetImageCompression() const
virtual void Draw(Option_t *option="")
Draw this frame with its current attributes.
Int_t Atoi() const
Return integer value of string.
static TTGlyph * GetGlyphs()
static ASDrawContext * create_draw_context_argb32(ASImage *im, ASDrawTool *brush)
Create draw context.
void DrawFillArea(UInt_t npt, TPoint *ppt, const char *col="#000000", const char *stipple=0, UInt_t w=16, UInt_t h=16)
Fill a polygon (any type convex, non-convex).
static int GetPolyYBounds(TPoint *pts, int n, int *by, int *ty)
Get poly bounds along Y.
Double_t ATan2(Double_t, Double_t)
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
static ULong_t RGB2Pixel(Int_t r, Int_t g, Int_t b)
Convert r,g,b to graphics system dependent pixel value.
void Scale(UInt_t width, UInt_t height)
Scale the original image.
void DrawGlyph(void *bitmap, UInt_t color, Int_t x, Int_t y)
Draw glyph bitmap.
virtual Int_t GetPixmapID() const =0
R__EXTERN Int_t(* gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret)
void Pad(const char *color="#00FFFFFF", UInt_t left=0, UInt_t right=0, UInt_t top=0, UInt_t bottom=0)
Enlarge image, padding it with specified color on each side in accordance with requested geometry...
Int_t fPaintMode
! 1 - fast mode, 0 - low memory slow mode
virtual UInt_t GetHeight() const
void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
TArrayL * GetPixels(Int_t x=0, Int_t y=0, UInt_t w=0, UInt_t h=0)
Return 2D array of machine dependent pixel values.
void DrawDashZLine(UInt_t x1, UInt_t y1, UInt_t x2, UInt_t y2, UInt_t nDash, const char *pDash, UInt_t col)
Draw a dashed line with one pixel width.
Element * GetMatrixArray()
virtual const TImagePalette & GetPalette() const
void DrawDashHLine(UInt_t y, UInt_t x1, UInt_t x2, UInt_t nDash, const char *pDash, UInt_t col, UInt_t thick)
Draw a dashed horizontal line.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual Int_t UtoPixel(Double_t u) const =0
Bool_t SetJpegDpi(const char *name, UInt_t dpi=72)
Set an image printing resolution in Dots Per Inch units.
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)
Fill spans with specified color or/and stipple.
virtual void Delete(Option_t *option="")
Delete this object.
Using a TBrowser one can browse all ROOT objects.
void DrawCircle(Int_t x, Int_t y, Int_t r, const char *col="#000000", Int_t thick=1)
Draw a circle.
RooArgSet S(const RooAbsArg &v1)
R__EXTERN const char * gProgName
void UnZoom()
Un-zoom the image to original size.
void FillRectangleInternal(UInt_t col, Int_t x, Int_t y, UInt_t width, UInt_t height)
Fill rectangle of size (width, height) at position (x,y) within the existing image with specified col...
Bool_t fIsGray
! kTRUE if image is gray
void SetImage(const Double_t *imageData, UInt_t width, UInt_t height, TImagePalette *palette=0)
Deletes the old image and creates a new image depending on the values of imageData.
virtual void PaintAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, Double_t &wmin, Double_t &wmax, Int_t &ndiv, Option_t *chopt="", Double_t gridlength=0, Bool_t drawGridOnly=kFALSE)
Control function to draw an axis.
static char * gIconPaths[7]
void Append(const TImage *im, const char *option="+", const char *color="#00000000")
Append image.
void SetPalette(const TImagePalette *palette)
Set a new palette to an image.
void DrawWideLine(UInt_t x1, UInt_t y1, UInt_t x2, UInt_t y2, UInt_t col, UInt_t thick)
Draw wide line.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Double_t fMaxValue
! max value in image
R__EXTERN TSystem * gSystem
void Merge(const TImage *im, const char *op="alphablend", Int_t x=0, Int_t y=0)
Merge two images.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
#define FillSpansInternal(npt, ppt, widths, color)
const Mask_t kGCClipXOrigin
void FromWindow(Drawable_t wid, Int_t x=0, Int_t y=0, UInt_t w=0, UInt_t h=0)
Create an image (screenshot) from specified window.
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
TImagePalette fPalette
color palette for value -> color conversion
void FloodFill(Int_t x, Int_t y, const char *col, const char *min_col, const char *max_col=0)
Flood fill.
void CropPolygon(UInt_t npt, TPoint *ppt)
Crop a convex polygon.
static FT_Matrix * GetRotMatrix()
void CropSpans(UInt_t npt, TPoint *ppt, UInt_t *widths)
Crop spans.
UShort_t * fColorAlpha
[fNumPoints] alpha at each anchor point
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
const char * AsHexString() const
Return color as hexadecimal string.
TTF helper class containing glyphs description.
void Slice(UInt_t xStart, UInt_t xEnd, UInt_t yStart, UInt_t yEnd, UInt_t toWidth, UInt_t toHeight)
Another method of enlarging images where corners remain unchanged, but middle part gets tiled...
char * Form(const char *fmt,...)
virtual void CellArrayBegin(Int_t W, Int_t H, Double_t x1, Double_t x2, Double_t y1, Double_t y2)=0
Pixmap_t GetMask()
Returns image mask pixmap (alpha channel).
virtual void SetPalette(const TImagePalette *palette)
Set a new palette for the image.
Array of longs (32 or 64 bits per element).
void AddAt(Long_t c, Int_t i)
Add long c at position i. Check for out of bounds.
virtual const char * GetName() const
Returns name of object.
const Mask_t kGCClipYOrigin
TSubString Strip(EStripType s=kTrailing, char c= ' ') const
Return a substring of self stripped at beginning and/or end.
void FillPolygon(UInt_t npt, TPoint *ppt, const char *col="#000000", const char *stipple=0, UInt_t w=16, UInt_t h=16)
Fill a convex polygon with background color or bitmap.
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)=0
void Blur(Double_t hr=3, Double_t vr=3)
Perform Gaussian blur of the image (useful for drop shadows).
UInt_t fNumPoints
number of anchor points
virtual Int_t GetCanvasID() const =0
UInt_t fZoomOffX
! X - offset for zooming in image pixels
void MapQuality(EImageQuality &quality, UInt_t &asquality, Bool_t toas=kTRUE)
Map quality to/from AfterImage quality.
Int_t CountChar(Int_t c) const
Return number of times character c occurs in the string.
static void CreateETandAET(int count, TPoint *pts, EdgeTable *ET, EdgeTableEntry *AET, EdgeTableEntry *pETEs, ScanLineListBlock *pSLLBlock)
void Flip(Int_t flip=180)
Flip image in place.
R__EXTERN TRandom * gRandom
static int InsertionSort(EdgeTableEntry *AET)
UShort_t * fColorBlue
[fNumPoints] blue color at each anchor point
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
virtual void WriteFastArray(const Bool_t *b, Int_t n)=0
virtual ~TASImage()
Image destructor, clean up image and visual.
static const UInt_t NUMPTSTOBUFFER
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
TASImage * fScaledImage
! temporary scaled and zoomed image produced from original image
void FillRectangle(const char *col=0, Int_t x=0, Int_t y=0, UInt_t width=0, UInt_t height=0)
Fill rectangle of size (width, height) at position (x,y) within the existing image with specified col...
const Double_t * GetArray() const
void HSV(UInt_t hue=0, UInt_t radius=360, Int_t H=0, Int_t S=0, Int_t V=0, Int_t x=0, Int_t y=0, UInt_t width=0, UInt_t height=0)
This function will tile original image to specified size with offsets requested, and then it will go ...
virtual void SetY2(Double_t y2)
Bool_t fConstRatio
keep aspect ratio of image on the screen
UInt_t * GetRgbaArray()
Return a pointer to an array[width x height] of RGBA32 values.
void Tile(UInt_t width, UInt_t height)
Tile the original image.
Int_t fZoomUpdate
! kZoom - new zooming required, kZoomOps - other ops in action, kNoZoom - no zooming or ops ...
void DrawText(Int_t x=0, Int_t y=0, const char *text="", Int_t size=12, const char *color=0, const char *font="fixed", EText3DType type=TImage::kPlain, const char *fore_file=0, Float_t angle=0)
Draw text of size (in pixels for TrueType fonts) at position (x, y) with color specified by hex strin...
void Bevel(Int_t x=0, Int_t y=0, UInt_t width=0, UInt_t height=0, const char *hi="#ffdddddd", const char *lo="#ff555555", UShort_t thick=1, Bool_t pressed=kFALSE)
Bevel is used to create 3D effect while drawing buttons, or any other image that needs to be framed...
void DrawPolyLine(UInt_t nn, TPoint *xy, const char *col="#000000", UInt_t thick=1, TImage::ECoordMode mode=kCoordModeOrigin)
Draw a polyline.
static const double x1[5]
void Crop(Int_t x=0, Int_t y=0, UInt_t width=0, UInt_t height=0)
Crop an image.
struct _EdgeTableEntry EdgeTableEntry
void Mirror(Bool_t vert=kTRUE)
Mirror image in place.
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)
Draw an ellipse.
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="")
Draw image on the drawable wid (pixmap, window) at x,y position.
UInt_t fZoomHeight
! hight of zoomed image in image pixels
virtual Int_t FindColor(UShort_t r, UShort_t g, UShort_t b)
Returns an index of the closest color.
static ARGB32 GetHilite(ARGB32 background)
Calculate highlite color.
static void destroy_asdraw_context32(ASDrawContext *ctx)
Destroy asdraw context32.
void Add(TObject *obj)
Add object to the hash table.
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)
Draw a dashed line.
#define _MEMSET_(dst, lng, val)
The color creation and management class.
struct _ScanLineListBlock ScanLineListBlock
Int_t GetEntries() const
Return the number of objects in array (i.e.
static CARD8 MakeComponentHilite(int cmp)
Make component hilite.
void GetImageBuffer(char **buffer, int *size, EImageFileTypes type=TImage::kPng)
Return in-memory buffer compressed according image type.
void FromGLBuffer(UChar_t *buf, UInt_t w, UInt_t h)
Creates an image (screenshot) from a RGBA buffer.
#define _alphaBlend(bot, top)
TImage & operator=(const TImage &img)
A class to define a conversion from pixel values to pixel color.
void DrawLineInternal(UInt_t x1, UInt_t y1, UInt_t x2, UInt_t y2, UInt_t col, UInt_t thick)
Internal line drawing.
Array of doubles (64 bits per element).
virtual void Draw(Option_t *option="")
Draw this box with its current attributes.
Mother of all ROOT objects.
Double_t fMinValue
! min value in image
void DrawDashVLine(UInt_t x, UInt_t y1, UInt_t y2, UInt_t nDash, const char *pDash, UInt_t col, UInt_t thick)
Draw a dashed vertical line.
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
static void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
Int_t GetNoElements() const
static ASVisual * fgVisual
pointer to visual structure
UShort_t * fColorGreen
[fNumPoints] green color at each anchor point
TASImage()
Default image constructor.
void AddAt(Double_t c, Int_t i)
Add double c at position i. Check for out of bounds.
static Bool_t fgInit
global flag to init afterimage only once
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)
Draw an ellipse.
virtual Int_t VtoPixel(Double_t v) const =0
const char * TypeFromMagicNumber(const char *file)
Guess the file type from the first byte of file.
void DrawSegments(UInt_t nseg, Segment_t *seg, const char *col="#000000", UInt_t thick=1)
Draw segments.
Bool_t GetConstRatio() const
void DrawStraightEllips(Int_t x, Int_t y, Int_t rx, Int_t ry, const char *col="#000000", Int_t thick=1)
Draw a straight ellipse.
Short_t Max(Short_t a, Short_t b)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
struct _ScanLineList ScanLineList
TObject * FindObject(const char *name) const
Find object using its name.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
virtual void * GetStream() const
R__EXTERN TVirtualPS * gVirtualPS
virtual void StartPaletteEditor()
Opens a GUI to edit the color palette.
TASImage & operator=(const TASImage &img)
Image assignment operator.
#define BRESINITPGON(dy, x1, x2, xStart, d, m, m1, incr1, incr2)
static void SetTextSize(Float_t textsize)
Set current text size.
float type_of_call hi(const int &, const int &)
TVirtualPS is an abstract interface to Postscript, PDF, SVG.
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
void flip(struct mesh *m, struct behavior *b, struct otri *flipedge)
UInt_t fZoomWidth
! width of zoomed image in image pixels
ASImage * fGrayImage
! gray image
static TImage * Create()
Create an image.
void DestroyImage()
Destroy image.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
void DrawHLine(UInt_t y, UInt_t x1, UInt_t x2, UInt_t col, UInt_t thick)
Draw an horizontal line.
static const UInt_t kBrushCacheSize
static Int_t GetNumGlyphs()
Float_t GetScreenFactor() const
Pixmap_t GetPixmap()
Returns image pixmap.
virtual void SetY1(Double_t y1)
ASImage * fImage
! pointer to image structure of original image
Bool_t GetPolygonSpans(UInt_t npt, TPoint *ppt, UInt_t *nspans, TPoint **firstPoint, UInt_t **firstWidth)
The code is based on Xserver/mi/mipolycon.c "Copyright 1987, 1998 The Open Group".
void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute mouse events.
void SetDefaults()
Set default parameters.
virtual void Open(const char *filename, Int_t type=-111)=0
char * GetObjectInfo(Int_t px, Int_t py) const
Get image pixel coordinates and the pixel value at the mouse pointer.
To make it possible to use GL for 2D graphic in a TPad/TCanvas.
virtual unsigned char * ReadFile(const char *filename, UInt_t &w, UInt_t &h)=0
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="")
Draw asimage on drawable.
Ssiz_t First(char c) const
Find first occurrence of a character c.
void Gradient(UInt_t angle=0, const char *colors="#FFFFFF #000000", const char *offsets=0, Int_t x=0, Int_t y=0, UInt_t width=0, UInt_t height=0)
Render multipoint gradient inside rectangle of size (width, height) at position (x,y) within the existing image.
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
UInt_t GetScaledWidth() const
Return width of the displayed image not of the original image.
static const FT_BBox & GetBox()
virtual TCanvas * GetCanvas() const =0
const void * GetWcsTitle(void) const
Returns the text as UNICODE.
static const double x3[11]
void DrawVLine(UInt_t x, UInt_t y1, UInt_t y2, UInt_t col, UInt_t thick)
Draw a vertical line.
virtual void BeginPaint(Bool_t=kTRUE)
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.