60 # include <ft2build.h> 61 # include FT_FREETYPE_H 87 #include "RConfigure.h" 92 # include <X11/Xlib.h> 95 # include "Windows4root.h" 100 # define X_DISPLAY_MISSING 1 102 # include <afterbase.h> 104 # include <win32/config.h> 105 # include <win32/afterbase.h> 106 # define X_DISPLAY_MISSING 1 108 # include <afterimage.h> 129 #if defined(__GNUC__) && __GNUC__ >= 4 && ((__GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ >= 1) || (__GNUC_MINOR__ >= 3)) && !__INTEL_COMPILER 130 #pragma GCC diagnostic ignored "-Wstrict-aliasing" 151 #define _alphaBlend(bot, top) {\ 152 __argb32__ *T = (__argb32__*)(top);\ 153 __argb32__ *B = (__argb32__*)(bot);\ 158 B->a = ((B->a*aa)>>8) + T->a;\ 159 B->r = (B->r*aa + T->r*T->a)>>8;\ 160 B->g = (B->g*aa + T->g*T->a)>>8;\ 161 B->b = (B->b*aa + T->b*T->a)>>8;\ 175 destroy_asimage(&fImage);
178 if (fIsGray && fGrayImage) {
179 destroy_asimage(&fGrayImage);
228 fImage = create_asimage(w ? w : 20, h ? h : 20, 0);
254 SetImage(imageData, width, height, palette);
267 SetImage(imageData, width, palette);
280 SetImage(imageData, width, palette);
295 if (img.
fImage->alt.vector) {
298 memcpy(
fImage->alt.vector, img.
fImage->alt.vector, size);
316 if (
this != &img && img.
IsValid()) {
325 if (img.
fImage->alt.vector) {
328 memcpy(
fImage->alt.vector, img.
fImage->alt.vector, size);
360 const char *icons =
"/icons";
379 gIconPaths[4] =
StrDup(ROOTICONPATH);
383 gIconPaths[5] =
StrDup(EXTRAICONPATH);
395 FILE *fp = fopen(file,
"rb");
396 const char *ret =
"";
400 if (!fread(&magic, 1, 1, fp)) {
408 if (!fread(&magic, 1, 1, fp)) {
412 if (!fread(&magic, 1, 1, fp)) {
417 ret = (magic == 1) ?
"ico" :
"cur";
422 if (!fread(&magic, 1, 1, fp)) {
427 if (magic == 0x21) ret =
"ps";
428 else if (magic == 0x50) ret =
"pdf";
478 Warning(
"Scale",
"Visual not initiated");
482 Bool_t xpm = filename && (filename[0] ==
'/' &&
483 filename[1] ==
'*') && filename[2] ==
' ';
495 set_output_threshold(0);
497 static ASImageImportParams iparams;
501 iparams.filter = SCL_DO_ALL;
502 iparams.gamma = SCREEN_GAMMA;
503 iparams.gamma_table =
NULL;
505 iparams.format = ASA_ASImage;
507 iparams.subimage = 0;
508 iparams.return_animation_delay = -1;
512 if (filename) dot = strrchr(filename,
'.');
525 iparams.subimage = ext.
Atoi();
527 ext = strrchr(fname.
Data(),
'.') + 1;
530 image = file2ASImage_extra(fname.
Data(), &iparams);
542 unsigned char *bitmap = 0;
548 if (!handler || ((handler->
LoadPlugin() == -1))) {
567 image = bitmap2asimage(bitmap, w, h, 0, 0);
647 Error(
"WriteImage",
"no image loaded");
651 if (!file || !*file) {
652 Error(
"WriteImage",
"no file name specified");
657 if ((s = strrchr(file,
'.'))) {
661 Error(
"WriteImage",
"cannot determine a valid file type");
669 Error(
"WriteImage",
"not a valid file type was specified");
675 ASImageFileTypes atype = (ASImageFileTypes)mytype;
683 static ASImageExportParams parms;
688 parms.xpm.type = atype;
689 parms.xpm.flags = EXPORT_ALPHA;
690 parms.xpm.dither = 4;
691 parms.xpm.opaque_threshold = 127;
692 parms.xpm.max_colors = 512;
695 ASImage2bmp(im, fname.
Data(), 0);
698 ASImage2xcf(im, fname.
Data(), 0);
701 parms.png.type = atype;
702 parms.png.flags = EXPORT_ALPHA;
706 parms.jpeg.type = atype;
707 parms.jpeg.flags = 0;
708 parms.jpeg.quality = aquality;
711 parms.gif.type = atype;
712 parms.gif.flags = EXPORT_ALPHA;
713 parms.gif.dither = 0;
714 parms.gif.opaque_threshold = 0;
718 parms.gif.type = atype;
719 parms.gif.flags = EXPORT_ALPHA | EXPORT_APPEND;
720 parms.gif.dither = 0;
721 parms.gif.opaque_threshold = 0;
722 parms.gif.animate_repeats = 0;
735 parms.gif.flags |= EXPORT_ANIMATION_REPEATS;
736 parms.gif.animate_repeats = 0;
737 }
else if(sufix==
"") {
754 parms.gif.flags |= EXPORT_ANIMATION_REPEATS;
755 parms.gif.animate_repeats = atoi(s);
764 parms.gif.flags |= EXPORT_ANIMATION_REPEATS;
765 parms.gif.animate_repeats = 0;
772 delay = atoi(sDelay);
773 parms.gif.flags |= EXPORT_ANIMATION_REPEATS;
774 parms.gif.animate_repeats = atoi(sRepeats);
776 Error(
"WriteImage",
"gif suffix %s not yet supported", s);
780 parms.gif.animate_delay = delay;
782 int i1 = fname.
Index(
"gif+");
784 fname = fname(0, i1 + 3);
787 Error(
"WriteImage",
"unexpected gif extension structure %s", fname.
Data());
793 parms.tiff.type = atype;
794 parms.tiff.flags = EXPORT_ALPHA;
795 parms.tiff.rows_per_strip = 0;
796 parms.tiff.compression_type = aquality <= 50 ? TIFF_COMPRESSION_JPEG :
797 TIFF_COMPRESSION_NONE;
798 parms.tiff.jpeg_quality = 100;
799 parms.tiff.opaque_threshold = 0;
802 Error(
"WriteImage",
"file type %s not yet supported", s);
806 if (!ASImage2file(im, 0, fname.
Data(), atype, &parms)) {
807 Error(
"WriteImage",
"error writing file %s", file);
825 if (s ==
"jpg" || s ==
"jpeg")
864 astype = ASIT_Xpm;
break;
866 astype = ASIT_ZCompressedXpm;
break;
868 astype = ASIT_GZCompressedXpm;
break;
870 astype = ASIT_Png;
break;
872 astype = ASIT_Jpeg;
break;
874 astype = ASIT_Xcf;
break;
876 astype = ASIT_Ppm;
break;
878 astype = ASIT_Pnm;
break;
880 astype = ASIT_Bmp;
break;
882 astype = ASIT_Ico;
break;
884 astype = ASIT_Cur;
break;
886 astype = ASIT_Gif;
break;
888 astype = ASIT_Gif;
break;
890 astype = ASIT_Tiff;
break;
892 astype = ASIT_Xbm;
break;
894 astype = ASIT_Targa;
break;
896 astype = ASIT_XMLScript;
break;
898 astype = ASIT_Unknown;
904 case ASIT_ZCompressedXpm:
906 case ASIT_GZCompressedXpm:
949 asquality = 25;
break;
951 asquality = 75;
break;
953 asquality = 50;
break;
955 asquality = 100;
break;
961 if (asquality > 0 && asquality <= 25)
963 if (asquality > 26 && asquality <= 50)
965 if (asquality > 51 && asquality <= 75)
967 if (asquality > 76 && asquality <= 100)
987 Warning(
"SetImage",
"Visual not initiated");
997 for (
Int_t pixel = 1; pixel <
Int_t(width * height); pixel++) {
1005 ASVectorPalette asPalette;
1009 for (col = 0; col < 4; col++)
1010 asPalette.channels[col] =
new UShort_t[asPalette.npoints];
1017 asPalette.points =
new Double_t[asPalette.npoints];
1018 for (Int_t point = 0; point <
Int_t(asPalette.npoints); point++)
1022 height, &asPalette, ASA_ASImage,
1025 delete [] asPalette.points;
1026 for (col = 0; col < 4; col++)
1027 delete [] asPalette.channels[col];
1071 Error(
"FromPad",
"pad cannot be 0");
1076 Warning(
"FromPad",
"Visual not initiated");
1086 if (
gROOT->IsBatch()) {
1094 if (itmp && itmp->
fImage) {
1103 if (itmp && itmp->
fImage && (itmp !=
this)) {
1105 if (itmp->
fImage->alt.argb32) {
1107 fImage->alt.argb32 = (ARGB32*)safemalloc(sz*
sizeof(ARGB32));
1108 memcpy(
fImage->alt.argb32, itmp->
fImage->alt.argb32, sz*4);
1138 static int x11 = -1;
1139 if (x11 < 0) x11 =
gVirtualX->InheritsFrom(
"TGX11");
1144 unsigned char *bits =
gVirtualX->GetColorBits(wd, 0, 0, w, h);
1149 fImage = bitmap2asimage(bits, w, h, 0, 0);
1170 Error(
"Draw",
"no image set");
1183 w =
Int_t(w*cx) + 4;
1184 h =
Int_t(h*cx) + 28;
1188 rname =
"new TCanvas(\"" + rname +
Form(
"\", %d, %d);", w, h);
1189 gROOT->ProcessLineFast(rname.Data());
1198 gPad->Range(-left / (1.0 - left - right),
1199 -bottom / (1.0 - top - bottom),
1200 1 + right / (1.0 - left - right),
1201 1 + top / ( 1.0 - top - bottom));
1202 gPad->RangeAxis(0, 0, 1, 1);
1225 wsrc = wsrc ? wsrc : im->width;
1226 hsrc = hsrc ? hsrc : im->height;
1228 static int x11 = -1;
1229 if (x11 < 0) x11 =
gVirtualX->InheritsFrom(
"TGX11");
1236 UInt_t ww = wsrc - ow + (ow ? 8 : 0);
1243 char *bits =
new char[ww*hh];
1245 ASImageDecoder *imdec = start_image_decoding(
fgVisual, im, SCL_DO_ALPHA,
1246 xsrc, ysrc, ww, 0, 0);
1248 for (yy = 0; yy < hh; yy++) {
1249 imdec->decode_image_scanline(imdec);
1250 CARD32 *
a = imdec->buffer.alpha;
1252 for (xx = 0; xx < ww; xx++) {
1267 stop_image_decoding(&imdec);
1270 (
const char *)bits, ww, hh);
1288 if (x11 && (!
gPad ||
gPad->GetGLDevice() == -1)) {
1289 asimage2drawable(
fgVisual, wid, im, (GC)gc, xsrc, ysrc, x, y, wsrc, hsrc, 1);
1292 unsigned char *bits = (
unsigned char *)im->alt.argb32;
1294 img = tile_asimage(
fgVisual, im, xsrc, ysrc, wsrc, hsrc,
1295 0, ASA_ARGB32, 0, ASIMAGE_QUALITY_DEFAULT);
1297 bits = (
unsigned char *)img->alt.argb32;
1304 if (
gPad &&
gPad->GetGLDevice() != -1) {
1306 painter->DrawPixels(bits, wsrc, hsrc, x, y, !option.
Contains(
"opaque"));
1314 gVirtualX->CopyArea(pic, wid, gc, 0, 0, wsrc, hsrc, x, y);
1321 destroy_asimage(&img);
1345 xsrc, ysrc, wsrc, hsrc, opt);
1364 Error(
"Paint",
"no image set");
1369 Warning(
"Paint",
"Visual not initiated");
1373 Int_t tile_x = 0, tile_y = 0;
1374 CARD32 tile_tint = 0;
1383 if (sscanf(opt.
Data() + opt.
Index(
"t"),
"t%d,%d,%s", &tile_x, &tile_y,
1386 if (parse_argb_color(stint, (CARD32*)&tile_tint) == stint)
1389 Error(
"Paint",
"tile option error");
1397 if (!
fImage->alt.vector) {
1410 to_h = (
Int_t)(to_h * (1.0 -
gPad->GetBottomMargin() -
gPad->GetTopMargin() ) + 0.5);
1411 to_w = (
Int_t)(to_w * (1.0 -
gPad->GetLeftMargin() -
gPad->GetRightMargin() ) + 0.5);
1414 if ((to_w < 25 || to_h < 25) && !expand) {
1415 Error(
"Paint",
"pad too small to display an image");
1427 Int_t pal_Ax = to_w +
gPad->UtoAbsPixel(
gPad->GetLeftMargin()) +
1428 (
gPad->UtoAbsPixel(
gPad->GetRightMargin()) / 10);
1430 Int_t pal_x = to_w +
gPad->UtoPixel(
gPad->GetLeftMargin()) +
1431 (
gPad->UtoPixel(
gPad->GetRightMargin()) / 10);
1436 ASImage *grad_im = 0;
1444 grad.type = GRADIENT_Top2Bottom;
1445 grad.color =
new ARGB32[grad.npoints];
1446 grad.offset =
new double[grad.npoints];
1449 Int_t oldPt = grad.npoints -
pt -1;
1450 grad.offset[
pt] = 1 - pal.
fPoints[oldPt];
1451 grad.color[
pt] = (((ARGB32)(pal.
fColorBlue[oldPt] & 0xff00)) >> 8) |
1453 (((ARGB32)(pal.
fColorRed[oldPt] & 0xff00)) << 8) |
1454 (((ARGB32)(pal.
fColorAlpha[oldPt] & 0xff00)) << 16);
1458 pal_h, SCL_DO_COLOR,
1461 delete [] grad.color;
1462 delete [] grad.offset;
1470 to_w, to_h, tile_tint, ASA_ASImage,
1497 ASImage *tmpImage = 0;
1508 destroy_asimage(&tmpImage);
1523 Error(
"Paint",
"image could not be rendered to display");
1527 int tox = expand ? 0 : int(
gPad->UtoPixel(1.) *
gPad->GetLeftMargin());
1528 int toy = expand ? 0 : int(
gPad->VtoPixel(0.) *
gPad->GetTopMargin());
1530 if (!
gROOT->IsBatch()) {
1545 axis.
PaintAxis(pal_Xpos,
gPad->PixeltoY(pal_Ay + pal_h - 1),
1546 pal_Xpos,
gPad->PixeltoY(pal_Ay),
1547 min, max, ndiv,
"+LU");
1552 pal_Xpos,
gPad->AbsPixeltoY(pal_Ay + 1),
1553 min, max, ndiv,
"+L");
1563 gPad->XtoAbsPixel(0),
gPad->YtoAbsPixel(1));
1568 dump->
Merge(&tgrad,
"alphablend", pal_Ax, pal_Ay);
1578 pal_Xpos,
gPad->AbsPixeltoY(pal_Ay + 1),
1579 min, max, ndiv,
"+L");
1583 Warning(
"Paint",
"PDF not implemented yet");
1586 Warning(
"Paint",
"SVG not implemented yet");
1606 x2 = x1+dx/image->width;
1608 y2 = y1+dy/image->height;
1610 x1 =
gPad->GetX1()+dx*
gPad->GetLeftMargin();
1611 x2 = x1+(dx*(1-
gPad->GetRightMargin()-
gPad->GetLeftMargin()))/image->width;
1612 y1 =
gPad->GetY2()-dy*
gPad->GetTopMargin();
1613 y2 = y1+(dy*(1-
gPad->GetTopMargin()-
gPad->GetBottomMargin()))/image->height;
1618 ASImageDecoder *imdec = start_image_decoding(
fgVisual, image, SCL_DO_ALL,
1619 0, 0, image->width, image->height, 0);
1621 for (
Int_t yt = 0; yt < (
Int_t)image->height; yt++) {
1622 imdec->decode_image_scanline(imdec);
1623 for (
Int_t xt = 0; xt < (
Int_t)image->width; xt++)
1625 imdec->buffer.green[xt],
1626 imdec->buffer.blue[xt]);
1628 stop_image_decoding(&imdec);
1633 Double_t xconv = (
gPad->AbsPixeltoX(pal_Ax + pal_w) -
gPad->AbsPixeltoX(pal_Ax)) / grad_im->width;
1634 Double_t yconv = (
gPad->AbsPixeltoY(pal_Ay - pal_h) -
gPad->AbsPixeltoY(pal_Ay)) / grad_im->height;
1635 x1 =
gPad->AbsPixeltoX(pal_Ax);
1637 y2 =
gPad->AbsPixeltoY(pal_Ay);
1642 imdec = start_image_decoding(
fgVisual, grad_im, SCL_DO_ALL,
1643 0, 0, grad_im->width, grad_im->height, 0);
1645 for (
Int_t yt = 0; yt < (
Int_t)grad_im->height; yt++) {
1646 imdec->decode_image_scanline(imdec);
1647 for (
Int_t xt = 0; xt < (
Int_t)grad_im->width; xt++)
1649 imdec->buffer.green[xt],
1650 imdec->buffer.blue[xt]);
1653 stop_image_decoding(&imdec);
1664 pal_Xpos,
gPad->AbsPixeltoY(pal_Ay + 1),
1665 min, max, ndiv,
"+L");
1671 destroy_asimage(&grad_im);
1680 Int_t pxl, pyl, pxt, pyt;
1687 if (px1 < px2) {pxl = px1; pxt = px2;}
1688 else {pxl = px2; pxt = px1;}
1689 if (py1 < py2) {pyl = py1; pyt = py2;}
1690 else {pyl = py2; pyt = py1;}
1692 if ((px > pxl && px < pxt) && (py > pyl && py < pyt))
1703 static TBox *ZoomBox;
1708 gPad->ExecuteEvent(event, px, py);
1714 static Int_t px1old, py1old, px2old, py2old;
1715 static Int_t px1, py1, px2, py2, pxl, pyl, pxt, pyt;
1726 if (imgX < 0) px = px - imgX;
1727 if (imgY < 0) py = py - imgY;
1732 if (imgX >= (
int)image->width) px = px - imgX + image->width - 1;
1733 if (imgY >= (
int)image->height) py = py - imgY + image->height - 1;
1738 px1 =
gPad->XtoAbsPixel(
gPad->GetX1());
1739 py1 =
gPad->YtoAbsPixel(
gPad->GetY1());
1740 px2 =
gPad->XtoAbsPixel(
gPad->GetX2());
1741 py2 =
gPad->YtoAbsPixel(
gPad->GetY2());
1742 px1old = px; py1old = py;
1764 ZoomBox =
new TBox(pxl, pyl, pxt, pyt);
1766 ZoomBox->
Draw(
"l*");
1785 Int_t imgX1 = px1old -
gPad->XtoAbsPixel(0);
1786 Int_t imgY1 = py1old -
gPad->YtoAbsPixel(1);
1787 Int_t imgX2 = px -
gPad->XtoAbsPixel(0);
1788 Int_t imgY2 = py -
gPad->YtoAbsPixel(1);
1790 imgY1 = image->height - 1 - imgY1;
1791 imgY2 = image->height - 1 - imgY2;
1797 Zoom((imgX1 < imgX2) ? imgX1 : imgX2, (imgY1 < imgY2) ? imgY1 : imgY2,
1816 static char info[64];
1822 px -=
gPad->XtoAbsPixel(0);
1823 py -=
gPad->YtoAbsPixel(1);
1826 if (px < 0 || py < 0)
return info;
1830 if (px >= (
int)image->width || py >= (
int)image->height)
1833 py = image->height - 1 - py;
1840 if (
fImage->alt.vector) {
1841 snprintf(info,64,
"x: %d y: %d %.5g",
1844 snprintf(info,64,
"x: %d y: %d", px, py);
1860 Warning(
"SetPalette",
"Visual not initiated");
1865 Warning(
"SetPalette",
"Image not valid");
1869 if (
fImage->alt.vector == 0)
1875 ASVectorPalette asPalette;
1877 asPalette.channels[0] =
new CARD16 [asPalette.npoints];
1878 asPalette.channels[1] =
new CARD16 [asPalette.npoints];
1879 asPalette.channels[2] =
new CARD16 [asPalette.npoints];
1880 asPalette.channels[3] =
new CARD16 [asPalette.npoints];
1886 asPalette.points =
new double[asPalette.npoints];
1887 for (
Int_t point = 0; point <
Int_t(asPalette.npoints); point++)
1893 delete [] asPalette.points;
1894 for (Int_t col = 0; col < 4; col++)
1895 delete [] asPalette.channels[col];
1914 Warning(
"Scale",
"Image not initiated");
1919 Warning(
"Scale",
"Visual not initiated");
1927 if (toWidth > 30000)
1929 if (toHeight > 30000)
1932 ASImage *img = scale_asimage(
fgVisual,
fImage, toWidth, toHeight,
1949 Warning(
"Scale",
"Image not initiated");
1954 Warning(
"Scale",
"Visual not initiated");
1962 if (toWidth > 30000)
1964 if (toHeight > 30000)
1968 yStart, yEnd, toWidth, toHeight,
1984 Warning(
"Tile",
"Image not initiated");
1989 Warning(
"Tile",
"Visual not initiated");
1997 if (toWidth > 30000)
1999 if (toHeight > 30000)
2002 ASImage *img = tile_asimage(
fgVisual,
fImage, 0, 0, toWidth, toHeight, 0,
2024 Warning(
"Zoom",
"Image not valid");
2046 Warning(
"UnZoom",
"Image not valid");
2074 Warning(
"Flip",
"Image not valid");
2078 Warning(
"Flip",
"Visual not initiated");
2082 if (
fImage->alt.vector) {
2083 Warning(
"Flip",
"flip does not work for data images");
2087 Int_t rflip = flip/90;
2121 Warning(
"Mirror",
"Image not valid");
2126 Warning(
"Mirror",
"Visual not initiated");
2130 if (
fImage->alt.vector) {
2131 Warning(
"Mirror",
"mirror does not work for data images");
2203 if (inbatch && !noX) {
2215 fgVisual = create_asvisual(0, 0, 0, 0);
2222 fgVisual = create_asvisual(0, 0, 0, 0);
2225 disp = (Display*)
gVirtualX->GetDisplay();
2228 Visual *vis = (Visual*)
gVirtualX->GetVisual();
2231 if (vis == 0 || cmap == 0) {
2232 fgVisual = create_asvisual(0, 0, 0, 0);
2234 fgVisual = create_asvisual_for_id(disp, screen, depth,
2235 XVisualIDFromVisual(vis), cmap, 0);
2239 fgVisual = create_asvisual(0, 0, 0, 0);
2252 Warning(
"StartPaletteEditor",
"Image not valid");
2255 if (
fImage->alt.vector == 0) {
2256 Warning(
"StartPaletteEditor",
"palette can be modified only for data images");
2271 Warning(
"GetPixmap",
"Visual not initiated");
2279 static int x11 = -1;
2280 if (x11 < 0) x11 =
gVirtualX->InheritsFrom(
"TGX11");
2286 if (!
fImage->alt.argb32) {
2289 ret =
gVirtualX->CreatePixmapFromData((
unsigned char*)
fImage->alt.argb32,
2305 Warning(
"GetMask",
"Visual not initiated");
2312 Warning(
"GetMask",
"No image");
2317 UInt_t ow = img->width%8;
2318 UInt_t ww = img->width - ow + (ow ? 8 : 0);
2325 char *bits =
new char[ww*hh];
2327 ASImageDecoder *imdec = start_image_decoding(
fgVisual, img, SCL_DO_ALPHA,
2334 for (y = 0; y < hh; y++) {
2335 imdec->decode_image_scanline(imdec);
2336 CARD32 *
a = imdec->buffer.alpha;
2338 for (x = 0; x < ww; x++) {
2352 stop_image_decoding(&imdec);
2353 pxmap =
gVirtualX->CreateBitmap(
gVirtualX->GetDefaultRootWindow(), (
const char *)bits,
2365 Warning(
"SetImage",
"Visual not initiated");
2375 gVirtualX->GetWindowSize(pxm, xy, xy, w, h);
2379 static int x11 = -1;
2380 if (x11 < 0) x11 =
gVirtualX->InheritsFrom(
"TGX11");
2385 unsigned char *bits =
gVirtualX->GetColorBits(pxm, 0, 0, w, h);
2392 fImage = bitmap2asimage(bits, w, h, 0, 0);
2396 unsigned char *mask_bits =
gVirtualX->GetColorBits(mask, 0, 0, w, h);
2397 fImage = bitmap2asimage(bits, w, h, 0, mask_bits);
2398 delete [] mask_bits;
2409 Warning(
"GetPixels",
"Wrong Image");
2414 ASImageDecoder *imdec;
2416 width = !width ? img->width : width;
2417 height = !height ? img->height : height;
2428 if ((x >= (
int)img->width) || (y >= (
int)img->height)) {
2432 if ((
int)(x + width) > (
int)img->width) {
2433 width = img->width -
x;
2436 if ((
int)(y + height) > (
int)img->height) {
2437 height = img->height -
y;
2440 if ((imdec = start_image_decoding(0,
fImage, SCL_DO_ALL, 0, y,
2441 img->width, height, 0)) == 0) {
2442 Warning(
"GetPixels",
"Failed to create image decoder");
2452 for (
UInt_t k = 0; k < height; k++) {
2453 imdec->decode_image_scanline(imdec);
2455 for (
UInt_t i = 0; i < width; ++i) {
2456 if ((r == (
Int_t)imdec->buffer.red[i]) &&
2457 (g == (
Int_t)imdec->buffer.green[i]) &&
2458 (b == (
Int_t)imdec->buffer.blue[i])) {
2460 r = (
Int_t)imdec->buffer.red[i];
2461 g = (
Int_t)imdec->buffer.green[i];
2462 b = (
Int_t)imdec->buffer.blue[i];
2465 ret->
AddAt(p, k*width + i);
2469 stop_image_decoding(&imdec);
2481 Warning(
"GetVecArray",
"Bad Image");
2484 if (
fImage->alt.vector) {
2485 return fImage->alt.vector;
2503 Warning(
"GetArray",
"Bad Image");
2509 if (
fImage->alt.vector) {
2514 ASImageDecoder *imdec;
2516 w = w ? w :
fImage->width;
2525 if ((imdec = start_image_decoding(0, img, SCL_DO_ALL, 0, 0,
2526 img->width, 0, 0)) == 0) {
2527 Warning(
"GetArray",
"Failed to create image decoder");
2538 for (
UInt_t k = 0; k <
h; k++) {
2539 imdec->decode_image_scanline(imdec);
2541 for (
UInt_t i = 0; i < w; ++i) {
2542 if ((r == imdec->buffer.red[i]) &&
2543 (g == imdec->buffer.green[i]) &&
2544 (b == imdec->buffer.blue[i])) {
2546 r = imdec->buffer.red[i];
2547 g = imdec->buffer.green[i];
2548 b = imdec->buffer.blue[i];
2549 if (palette) p = palette->
FindColor(r, g, b);
2551 v = palette ? palette->
fPoints[p] :
Double_t((r << 16) + (g << 8) + b)/0xFFFFFF;
2552 ret->
AddAt(v, (h-k-1)*w + i);
2556 stop_image_decoding(&imdec);
2579 const char *color,
const char *font_name,
2582 UInt_t width=0, height=0;
2583 ARGB32 text_color = ARGB32_Black;
2584 ASImage *fore_im = 0;
2585 ASImage *text_im = 0;
2589 Warning(
"DrawText",
"Visual not initiated");
2605 parse_argb_color(color, &text_color);
2618 Warning(
"DrawText",
"cannot create Font Manager");
2625 font = get_asfont(
gFontManager,
"fixed", 0, size, ASF_GuessWho);
2627 Warning(
"DrawText",
"cannot find a font %s", font_name);
2632 get_text_size(text, font, (ASText3DType)type, &width, &height);
2635 fImage = create_asimage(width, height, 0);
2639 text_im = draw_text(text, font, (ASText3DType)type, 0);
2644 ASImage *tmp = file2ASImage(fore_file, 0xFFFFFFFF, SCREEN_GAMMA, 0, 0);
2646 if ((tmp->width != width) || (tmp->height != height)) {
2647 fore_im = tile_asimage(
fgVisual, tmp, 0, 0, width, height, 0,
2650 destroy_asimage(&tmp);
2657 move_asimage_channel(fore_im, IC_ALPHA, text_im, IC_ALPHA);
2658 destroy_asimage(&text_im);
2666 ASImage *rendered_im;
2667 ASImageLayer layers[2];
2669 init_image_layers(&(layers[0]), 2);
2670 fore_im->back_color = text_color;
2671 layers[0].im = rimg;
2672 layers[0].dst_x = 0;
2673 layers[0].dst_y = 0;
2674 layers[0].clip_width = rimg->width;
2675 layers[0].clip_height = rimg->height;
2676 layers[0].bevel = 0;
2677 layers[1].im = fore_im;
2678 layers[1].dst_x =
x;
2679 layers[1].dst_y =
y;
2680 layers[1].clip_width = fore_im->width;
2681 layers[1].clip_height = fore_im->height;
2683 rendered_im = merge_layers(
fgVisual, &(layers[0]), 2, rimg->width, rimg->height,
2686 destroy_asimage(&fore_im);
2719 Warning(
"Merge",
"Visual not initiated");
2723 ASImage *rendered_im;
2724 ASImageLayer layers[2];
2726 init_image_layers(&(layers[0]), 2);
2728 layers[0].dst_x = 0;
2729 layers[0].dst_y = 0;
2730 layers[0].clip_width =
fImage->width;
2731 layers[0].clip_height =
fImage->height;
2732 layers[0].bevel = 0;
2733 layers[1].im = ((
TASImage*)im)->fImage;
2734 layers[1].dst_x =
x;
2735 layers[1].dst_y =
y;
2736 layers[1].clip_width = im->
GetWidth();
2737 layers[1].clip_height = im->
GetHeight();
2738 layers[1].merge_scanlines = blend_scanlines_name2func(op ? op :
"add");
2756 Warning(
"Blur",
"Visual not initiated");
2761 fImage = create_asimage(100, 100, 0);
2764 Warning(
"Blur",
"Failed to create image");
2771 ASImage *rendered_im = blur_asimage_gauss(
fgVisual,
fImage, hr > 0 ? hr : 3,
2772 vr > 0 ? vr : 3, SCL_DO_ALL,
2785 Warning(
"Clone",
"Image not initiated");
2792 Warning(
"Clone",
"Failed to create image");
2808 if (
fImage->alt.argb32) {
2810 im->
fImage->alt.argb32 = (ARGB32*)safemalloc(sz*
sizeof(ARGB32));
2811 memcpy(im->
fImage->alt.argb32,
fImage->alt.argb32, sz *
sizeof(ARGB32));
2831 Warning(
"Vectorize",
"Visual not initiated");
2836 fImage = create_asimage(100, 100, 0);
2839 Warning(
"Vectorize",
"Failed to create image");
2850 dither = dither > 7 ? 7 : dither;
2852 res = colormap_asimage(
fImage, &cmap, max_colors, dither, opaque_threshold);
2864 g = INDEX_SHIFT_GREEN(cmap.entries[res[i]].green);
2865 b = INDEX_SHIFT_BLUE(cmap.entries[res[i]].blue);
2866 r = INDEX_SHIFT_RED(cmap.entries[res[i]].red);
2868 v = MAKE_INDEXED_COLOR24(r,g,
b);
2878 for (
UInt_t j = 0; j < cmap.count; j++) {
2879 g = INDEX_SHIFT_GREEN(cmap.entries[j].green);
2880 b = INDEX_SHIFT_BLUE(cmap.entries[j].blue);
2881 r = INDEX_SHIFT_RED(cmap.entries[j].red);
2882 v = MAKE_INDEXED_COLOR24(r,g,
b);
2884 v = (v>>12) & 0x0FFF;
2887 pal->
fColorRed[j] = cmap.entries[j].red << 8;
2889 pal->
fColorBlue[j] = cmap.entries[j].blue << 8;
2893 destroy_colormap(&cmap,
kTRUE);
2896 fImage->alt.vector = vec;
2898 if (res)
delete res;
2944 Warning(
"HSV",
"Visual not initiated");
2949 fImage = create_asimage(width ? width : 20, height ? height : 20, 0);
2952 Warning(
"HSV",
"Failed to create image");
2961 width = !width ?
fImage->width : width;
2962 height = !height ?
fImage->height : height;
2964 ASImage *rendered_im = 0;
2967 rendered_im = adjust_asimage_hsv(
fgVisual,
fImage, x, y, width, height,
2968 hue, radius, H, S, V, ASA_ASImage, 100,
2969 ASIMAGE_QUALITY_TOP);
2972 Warning(
"HSV",
"Failed to create rendered image");
3007 Warning(
"Gradient",
"Visual not initiated");
3011 ASImage *rendered_im = 0;
3012 ASGradient gradient;
3014 int reverse = 0, npoints1 = 0, npoints2 = 0;
3021 if ((angle > 2 * 180 * 15 / 16) || (angle < 2 * 180 * 1 / 16)) {
3022 gradient.type = GRADIENT_Left2Right;
3023 }
else if (angle < 2 * 180 * 3 / 16) {
3024 gradient.type = GRADIENT_TopLeft2BottomRight;
3025 }
else if (angle < 2 * 180 * 5 / 16) {
3026 gradient.type = GRADIENT_Top2Bottom;
3027 }
else if (angle < 2 * 180 * 7 / 16) {
3028 gradient.type = GRADIENT_BottomLeft2TopRight; reverse = 1;
3029 }
else if (angle < 2 * 180 * 9 / 16) {
3030 gradient.type = GRADIENT_Left2Right; reverse = 1;
3031 }
else if (angle < 2 * 180 * 11 / 16) {
3032 gradient.type = GRADIENT_TopLeft2BottomRight; reverse = 1;
3033 }
else if (angle < 2 * 180 * 13 / 16) {
3034 gradient.type = GRADIENT_Top2Bottom; reverse = 1;
3036 gradient.type = GRADIENT_BottomLeft2TopRight;
3039 for (p = (
char*)colors; isspace((
int)*p); p++) { }
3041 for (npoints1 = 0; *p; npoints1++) {
3043 for ( ; *p && !isspace((
int)*p); p++) { }
3045 for ( ; isspace((
int)*p); p++) { }
3048 for (p = (
char*)offsets; isspace((
int)*p); p++) { }
3050 for (npoints2 = 0; *p; npoints2++) {
3052 for ( ; *p && !isspace((
int)*p); p++) { }
3054 for ( ; isspace((
int)*p); p++) { }
3059 if (offsets && (npoints1 > npoints2)) npoints1 = npoints2;
3068 gradient.color =
new ARGB32[npoints1];
3069 gradient.offset =
new double[npoints1];
3071 for (p = (
char*)
colors; isspace((
int)*p); p++) { }
3073 for (npoints1 = 0; *p; ) {
3077 for ( ; *p && !isspace((
int)*p); p++) { }
3079 for ( ; isspace((
int)*p); p++) { }
3081 col = str(pb - colors, p - pb);
3083 if (parse_argb_color(col.
Data(), gradient.color + npoints1) != col) {
3086 Warning(
"Gradient",
"Failed to parse color [%s] - defaulting to black", pb);
3091 for (p = (
char*)offsets; isspace((
int)*p); p++) { }
3093 for (npoints2 = 0; *p; ) {
3097 for ( ; *p && !isspace((
int)*p); p++) { }
3100 gradient.offset[npoints2] = strtod(pb, &pb);
3102 if (pb == p) npoints2++;
3104 for ( ; isspace((
int)*p); p++) { }
3107 for (npoints2 = 0; npoints2 < npoints1; npoints2++) {
3108 gradient.offset[npoints2] = (double)npoints2 / (npoints1 - 1);
3111 gradient.npoints = npoints1;
3113 if (npoints2 && (gradient.npoints > npoints2)) {
3114 gradient.npoints = npoints2;
3117 for (i = 0; i < gradient.npoints/2; i++) {
3118 int i2 = gradient.npoints - 1 - i;
3119 ARGB32
c = gradient.color[i];
3120 double o = gradient.offset[i];
3121 gradient.color[i] = gradient.color[i2];
3122 gradient.color[i2] =
c;
3123 gradient.offset[i] = gradient.offset[i2];
3124 gradient.offset[i2] = o;
3126 for (i = 0; i < gradient.npoints; i++) {
3127 gradient.offset[i] = 1.0 - gradient.offset[i];
3130 rendered_im = make_gradient(
fgVisual, &gradient, width, height, SCL_DO_ALL,
3133 delete [] gradient.color;
3134 delete [] gradient.offset;
3138 Warning(
"Gradient",
"Failed to create gradient image");
3147 ASImageLayer layers[2];
3149 init_image_layers(&(layers[0]), 2);
3151 layers[0].dst_x = 0;
3152 layers[0].dst_y = 0;
3153 layers[0].clip_width =
fImage->width;
3154 layers[0].clip_height =
fImage->height;
3155 layers[0].bevel = 0;
3156 layers[1].im = rendered_im;
3157 layers[1].dst_x =
x;
3158 layers[1].dst_y =
y;
3159 layers[1].clip_width = width;
3160 layers[1].clip_height = height;
3161 layers[1].merge_scanlines = alphablend_scanlines;
3166 Warning(
"Gradient",
"Failed to create merged image");
3170 destroy_asimage(&rendered_im);
3185 cmp = (cmp * 12) / 10;
3187 return (cmp > 255) ? 255 : cmp;
3208 return (background >> 1) & 0x7F7F7F7F;
3219 a = ARGB32_ALPHA8(foreground) + ARGB32_ALPHA8(background);
3221 r = ARGB32_RED8(foreground) + ARGB32_RED8(background);
3223 g = ARGB32_GREEN8(foreground) + ARGB32_GREEN8(background);
3225 b = ARGB32_BLUE8(foreground) + ARGB32_BLUE8(background);
3228 return MAKE_ARGB32(a, r, g, b);
3244 const char *hi_color,
const char *lo_color,
UShort_t thick,
3248 Warning(
"Bevel",
"Visual not initiated");
3255 ARGB32
hi=ARGB32_White, lo=ARGB32_White;
3256 parse_argb_color(hi_color, &hi);
3257 parse_argb_color(lo_color, &lo);
3260 bevel.lo_color =
hi;
3262 bevel.hi_color = lo;
3265 bevel.hi_color =
hi;
3267 bevel.lo_color = lo;
3272 int extra_hilite = 2;
3273 bevel.left_outline = bevel.top_outline = bevel.right_outline = bevel.bottom_outline = thick;
3274 bevel.left_inline = bevel.top_inline = bevel.right_inline = bevel.bottom_inline = extra_hilite + 1;
3276 if (bevel.top_outline > 1) {
3277 bevel.top_inline += bevel.top_outline - 1;
3280 if (bevel.left_outline > 1) {
3281 bevel.left_inline += bevel.left_outline - 1;
3284 if (bevel.right_outline > 1) {
3285 bevel.right_inline += bevel.right_outline - 1;
3288 if (bevel.bottom_outline > 1) {
3289 bevel.bottom_inline += bevel.bottom_outline - 1;
3293 ARGB32
fill = ((hi>>24) != 0xff) || ((lo>>24) != 0xff) ? bevel.hilo_color : (bevel.hilo_color | 0xff000000);
3296 fImage = create_asimage(width ? width : 20, height ? height : 20, 0);
3299 Warning(
"Bevel",
"Failed to create image");
3308 width = !width ?
fImage->width : width;
3309 height = !height ?
fImage->height : height;
3311 ASImageLayer layers[2];
3312 init_image_layers(&(layers[0]), 2);
3315 layers[0].dst_x = 0;
3316 layers[0].dst_y = 0;
3317 layers[0].clip_width =
fImage->width;
3318 layers[0].clip_height =
fImage->height;
3319 layers[0].bevel = 0;
3321 UInt_t w = width - (bevel.left_outline + bevel.right_outline);
3322 UInt_t h = height - (bevel.top_outline + bevel.bottom_outline);
3323 ASImage *bevel_im = create_asimage(w, h, 0);
3326 Warning(
"Bevel",
"Failed to create bevel image");
3330 layers[1].im = bevel_im;
3331 fill_asimage(
fgVisual, bevel_im, 0, 0, w, h, fill);
3333 layers[1].dst_x =
x;
3334 layers[1].dst_y =
y;
3335 layers[1].clip_width = width;
3336 layers[1].clip_height = height;
3337 layers[1].bevel = &bevel;
3338 layers[1].merge_scanlines = alphablend_scanlines;
3342 destroy_asimage(&bevel_im);
3345 Warning(
"Bevel",
"Failed to image");
3365 Warning(
"Pad",
"Visual not initiated");
3370 fImage = create_asimage(100, 100, 0);
3373 Warning(
"Pad",
"Failed to create image");
3382 ARGB32 color = ARGB32_White;
3383 parse_argb_color(col, &color);
3394 Warning(
"Pad",
"Failed to create output image");
3411 Warning(
"Crop",
"Visual not initiated");
3423 width = x + width >
fImage->width ?
fImage->width -
x : width;
3424 height = y + height >
fImage->height ?
fImage->height -
y : height;
3426 if ((width ==
fImage->width) && (height ==
fImage->height)) {
3427 Warning(
"Crop",
"input size larger than image");
3430 ASImageDecoder *imdec = start_image_decoding(
fgVisual,
fImage, SCL_DO_ALL,
3431 x, y, width, height, 0);
3434 Warning(
"Crop",
"Failed to start image decoding");
3438 ASImage *img = create_asimage(width, height, 0);
3442 Warning(
"Crop",
"Failed to create image");
3446 ASImageOutput *imout = start_image_output(
fgVisual, img, ASA_ASImage,
3450 Warning(
"Crop",
"Failed to start image output");
3451 destroy_asimage(&img);
3452 if (imdec)
delete [] imdec;
3460 for (
UInt_t i = 0; i < height; i++) {
3461 imdec->decode_image_scanline(imdec);
3462 imout->output_image_scanline(imout, &(imdec->buffer), 1);
3465 stop_image_decoding(&imdec);
3466 stop_image_output(&imout);
3490 Warning(
"Append",
"Visual not initiated");
3507 Merge(im,
"alphablend", width, 0);
3508 }
else if (opt ==
"/") {
3510 Merge(im,
"alphablend", 0, height);
3529 Warning(
"BeginPaint",
"Visual not initiated");
3544 0, ASA_ARGB32, 0, ASIMAGE_QUALITY_DEFAULT);
3547 Warning(
"BeginPaint",
"Failed to create image");
3561 Warning(
"EndPaint",
"no image");
3565 if (!
fImage->alt.argb32)
return;
3568 0, ASA_ASImage, 0, ASIMAGE_QUALITY_DEFAULT);
3571 Warning(
"EndPaint",
"Failed to create image");
3588 Warning(
"GetArgbArray",
"no image");
3595 if (!img->alt.argb32) {
3605 return (
UInt_t *)img->alt.argb32;
3616 Warning(
"GetRgbaArray",
"no image");
3623 if (!img->alt.argb32) {
3641 for (i = 0; i < img->height; i++) {
3642 for (j = 0; j < img->width; j++) {
3644 argb = img->alt.argb32[idx];
3646 rgb = argb & 0x00ffffff;
3647 rgba = (rgb << 8) + a;
3662 Warning(
"GetScanline",
"no image");
3667 CARD32 *ret =
new CARD32[img->width];
3669 ASImageDecoder *imdec = start_image_decoding(
fgVisual, img, SCL_DO_ALL,
3670 0, y, img->width, 1, 0);
3674 Warning(
"GetScanline",
"Failed to start image decoding");
3682 imdec->decode_image_scanline(imdec);
3683 memcpy(imdec->buffer.buffer, ret, img->width*
sizeof(CARD32));
3684 stop_image_decoding(&imdec);
3699 #if defined(R__GNU) && defined(__i386__) && !defined(__sun) 3700 #define _MEMSET_(dst, lng, val) __asm__("movl %0,%%eax \n"\ 3701 "movl %1,%%edi \n" \ 3702 "movl %2,%%ecx \n" \ 3707 :"g" (val), "g" (dst), "g" (lng) \ 3708 :"eax","edi","ecx" \ 3712 #define _MEMSET_(dst, lng, val) do {\ 3713 for( UInt_t j=0; j < lng; j++) *((dst)+j) = val; } while (0) 3717 #define FillSpansInternal(npt, ppt, widths, color) do {\ 3718 UInt_t yy = ppt[0].fY*fImage->width;\ 3719 for (UInt_t i = 0; i < npt; i++) {\ 3720 _MEMSET_(&fImage->alt.argb32[Idx(yy + ppt[i].fX)], widths[i], color);\ 3721 yy += ((i+1 < npt) && (ppt[i].fY != ppt[i+1].fY) ? fImage->width : 0);\ 3733 Warning(
"FillRectangle",
"Visual not initiated");
3738 Warning(
"FillRectangle",
"no image");
3742 if (!
fImage->alt.argb32) {
3746 if (!
fImage->alt.argb32) {
3747 Warning(
"FillRectangle",
"Failed to get pixel array");
3751 ARGB32 color = (ARGB32)col;
3753 if (width == 0) width = 1;
3754 if (height == 0) height = 1;
3765 Bool_t has_alpha = (color & 0xff000000) != 0xff000000;
3770 width = x + width >
fImage->width ?
fImage->width -
x : width;
3771 height = y + height >
fImage->height ?
fImage->height -
y : height;
3773 if (!
fImage->alt.argb32) {
3776 int yyy = y*
fImage->width;
3778 ARGB32 *p0 =
fImage->alt.argb32 + yyy +
x;
3780 for (
UInt_t i = 0; i < height; i++) {
3785 for (
UInt_t i = y; i < y + height; i++) {
3810 Warning(
"Fill",
"Visual not initiated");
3814 ARGB32 color = ARGB32_White;
3817 parse_argb_color(col, &color);
3821 fImage = create_asimage(width ? width : 20, height ? height : 20, 0);
3835 ARGB32 color = (ARGB32)col;
3838 if (!thick) thick = 1;
3846 thick += (x - half);
3852 x = x + thick >=
fImage->width ?
fImage->width - thick - 1 :
x;
3854 int yy = y1*
fImage->width;
3856 for (
UInt_t w = 0; w < thick; w++) {
3857 if (x + w < fImage->width) {
3870 ARGB32 color = (ARGB32)col;
3873 if (!thick) thick = 1;
3881 thick += (y - half);
3885 y = y + thick >=
fImage->height ?
fImage->height - thick - 1 :
y;
3889 int yy = y*
fImage->width;
3890 for (
UInt_t w = 0; w < thick; w++) {
3892 if (y + w < fImage->height) {
3904 const char *col,
UInt_t thick)
3906 ARGB32 color = ARGB32_White;
3907 parse_argb_color(col, &color);
3919 int x,
y, xend, yend;
3926 Warning(
"DrawLine",
"Visual not initiated");
3931 Warning(
"DrawLine",
"no image");
3935 if (!
fImage->alt.argb32) {
3939 if (!
fImage->alt.argb32) {
3940 Warning(
"DrawLine",
"Failed to get pixel array");
3944 ARGB32 color = (ARGB32)col;
3951 y2 > y1 ? y2 : y1, color, thick);
3957 x2 > x1 ? x2 : x1, color, thick);
3969 i2 = i1 - (dx << 1);
3986 q = (y2 - y1) * ydir;
4019 i2 = i1 - (dy << 1);
4036 q = (x2 -
x1) * xdir;
4074 const char *col,
UInt_t thick)
4077 Warning(
"DrawRectangle",
"Visual not initiated");
4086 fImage = create_asimage(w, h, 0);
4091 if (!
fImage->alt.argb32) {
4095 if (!
fImage->alt.argb32) {
4096 Warning(
"DrawRectangle",
"Failed to get pixel array");
4100 ARGB32 color = ARGB32_White;
4101 parse_argb_color(col, &color);
4121 ARGB32 color = ARGB32_White;
4126 fImage = create_asimage(w, h, 0);
4132 parse_argb_color(col, &color);
4138 parse_argb_color(col, &color);
4168 ARGB32 color = (ARGB32)col;
4178 thick += (y - half);
4181 thick = thick <= 0 ? 1 : thick;
4183 y = y + thick >=
fImage->height ?
fImage->height - thick - 1 :
y;
4189 x1 = x2 < x1 ?
x2 :
x1;
4190 x2 = x2 < tmp ? tmp :
x2;
4193 for (
UInt_t w = 0; w < thick; w++) {
4194 if (y + w < fImage->height) {
4202 if (i >= pDash[iDash]) {
4206 if (iDash >= nDash) {
4222 ARGB32 color = (ARGB32)col;
4232 thick += (x - half);
4235 thick = thick <= 0 ? 1 : thick;
4242 y1 = y2 < y1 ? y2 : y1;
4243 y2 = y2 < tmp ? tmp : y2;
4245 x = x + thick >=
fImage->width ?
fImage->width - thick - 1 :
x;
4247 int yy = y1*
fImage->width;
4249 for (
UInt_t w = 0; w < thick; w++) {
4250 if (x + w < fImage->width) {
4258 if (i >= pDash[iDash]) {
4262 if (iDash >= nDash) {
4278 int x,
y, xend, yend;
4288 char *pDash =
new char[nDash];
4293 for (i = 0; i < (int)nDash; i++) {
4299 i2 = i1 - (dx << 1);
4317 q = (y2 - y1) * ydir;
4322 if ((iDash%2) == 0) {
4334 if (i >= pDash[iDash]) {
4338 if (iDash >= nDash) {
4346 if ((iDash%2) == 0) {
4358 if (i >= pDash[iDash]) {
4362 if (iDash >= nDash) {
4371 for (i = 0; i < (int)nDash; i++) {
4377 i2 = i1 - (dy << 1);
4395 q = (x2 -
x1) * xdir;
4400 if ((iDash%2) == 0) {
4414 if (i >= pDash[iDash]) {
4418 if (iDash >= nDash) {
4426 if ((iDash%2) == 0) {
4440 if (i >= pDash[iDash]) {
4444 if (iDash >= nDash) {
4462 double x,
y, xend=0, yend=0, x0, y0;
4470 double *xDash =
new double[nDash];
4471 double *yDash =
new double[nDash];
4476 for (i = 0; i < (int)nDash; i++) {
4477 xDash[i] = tDash[i] * ac;
4478 yDash[i] = tDash[i] * as;
4482 xDash[i] = xDash[i]/2;
4483 yDash[i] = yDash[i]/2;
4485 xDash[i] = xDash[i]*2;
4486 yDash[i] = yDash[i]*2;
4503 q = (y2 - y1) * ydir;
4510 while ((x < xend) && (y < yend)) {
4514 if ((iDash%2) == 0) {
4524 if (iDash >= nDash) {
4529 while ((x < xend) && (y > yend)) {
4533 if ((iDash%2) == 0) {
4543 if (iDash >= nDash) {
4562 q = (x2 -
x1) * xdir;
4569 while ((x < xend) && (y < yend)) {
4573 if ((iDash%2) == 0) {
4583 if (iDash >= nDash) {
4588 while ((x > xend) && (y < yend)) {
4592 if ((iDash%2) == 0) {
4602 if (iDash >= nDash) {
4616 const char *pDash,
const char *col,
UInt_t thick)
4620 Warning(
"DrawDashLine",
"Visual not initiated");
4625 Warning(
"DrawDashLine",
"no image");
4629 if (!
fImage->alt.argb32) {
4633 if (!
fImage->alt.argb32) {
4634 Warning(
"DrawDashLine",
"Failed to get pixel array");
4638 if ((nDash < 2) || !pDash || (nDash%2)) {
4639 Warning(
"DrawDashLine",
"Wrong input parameters n=%d %ld", nDash, (
Long_t)
sizeof(pDash)-1);
4643 ARGB32 color = ARGB32_White;
4644 parse_argb_color(col, &color);
4648 }
else if (y1 == y2) {
4662 ARGB32 color = ARGB32_White;
4663 parse_argb_color(col, &color);
4687 Warning(
"PutPixel",
"Visual not initiated");
4692 Warning(
"PutPixel",
"no image");
4696 if (!
fImage->alt.argb32) {
4700 if (!
fImage->alt.argb32) {
4701 Warning(
"PutPixel",
"Failed to get pixel array");
4706 parse_argb_color(col, &color);
4708 if ((x < 0) || (y < 0) || (x >= (
int)
fImage->width) || (y >= (
int)
fImage->height)) {
4709 Warning(
"PutPixel",
"Out of range width=%d x=%d, height=%d y=%d",
4722 Warning(
"PolyPoint",
"Visual not initiated");
4727 Warning(
"PolyPoint",
"no image");
4731 if (!
fImage->alt.argb32) {
4735 if (!
fImage->alt.argb32) {
4736 Warning(
"PolyPoint",
"Failed to get pixel array");
4741 Warning(
"PolyPoint",
"No points specified");
4748 parse_argb_color(col, &color);
4754 for (i = 0; i < npt; i++) {
4755 ipt[i].
fX += ppt[i].
fX;
4756 ipt[i].
fY += ppt[i].
fY;
4761 for (i = 0; i < npt; i++) {
4762 x = ipt ? ipt[i].
fX : ppt[i].
fX;
4763 y = ipt ? ipt[i].
fY : ppt[i].
fY;
4765 if ((x < 0) || (y < 0) || (x >= (
int)
fImage->width) || (y >= (
int)
fImage->height)) {
4781 if (!nseg || !seg) {
4782 Warning(
"DrawSegments",
"Invalid data nseg=%d seg=0x%lx", nseg, (
Long_t)seg);
4788 for (
UInt_t i = 0; i < nseg; i++) {
4789 pt[0].
fX = seg->
fX1;
4790 pt[1].
fX = seg->
fX2;
4791 pt[0].
fY = seg->
fY1;
4792 pt[1].
fY = seg->
fY2;
4806 Warning(
"FillSpans",
"Visual not initiated");
4811 Warning(
"FillSpans",
"no image");
4815 if (!
fImage->alt.argb32) {
4819 if (!
fImage->alt.argb32) {
4820 Warning(
"FillSpans",
"Failed to get pixel array");
4824 if (!npt || !ppt || !widths || (stipple && (!w || !h))) {
4825 Warning(
"FillSpans",
"Invalid input data npt=%d ppt=0x%lx col=%s widths=0x%lx stipple=0x%lx w=%d h=%d",
4831 parse_argb_color(col, &color);
4836 for (
UInt_t i = 0; i < npt; i++) {
4838 for (
UInt_t j = 0; j < widths[i]; j++) {
4839 if ((ppt[i].fX >= (
Int_t)
fImage->width) || (ppt[i].
fX < 0) ||
4850 if (stipple[ii >> 3] & (1 << (ii%8))) {
4864 Warning(
"FillSpans",
"Visual not initiated");
4869 Warning(
"FillSpans",
"no image");
4873 if (!
fImage->alt.argb32) {
4877 if (!
fImage->alt.argb32) {
4878 Warning(
"FillSpans",
"Failed to get pixel array");
4882 if (!npt || !ppt || !widths || !tile) {
4883 Warning(
"FillSpans",
"Invalid input data npt=%d ppt=0x%lx widths=0x%lx tile=0x%lx",
4897 for (
UInt_t i = 0; i < npt; i++) {
4900 for (
UInt_t j = 0; j < widths[i]; j++) {
4901 if ((ppt[i].fX >= (
Int_t)
fImage->width) || (ppt[i].
fX < 0) ||
4920 Warning(
"CropSpans",
"Visual not initiated");
4925 Warning(
"CropSpans",
"no image");
4929 if (!
fImage->alt.argb32) {
4933 if (!
fImage->alt.argb32) {
4934 Warning(
"CropSpans",
"Failed to get pixel array");
4938 if (!npt || !ppt || !widths) {
4939 Warning(
"CropSpans",
"No points specified npt=%d ppt=0x%lx widths=0x%lx", npt, (
Long_t)ppt, (
Long_t)widths);
4944 int y1 = ppt[npt-1].
fY;
4952 for (y = 0; (int)y < y0; y++) {
4953 for (x = 0; x <
fImage->width; x++) {
4955 if (idx < sz)
fImage->alt.argb32[idx] = 0;
4960 for (i = 0; i < npt; i++) {
4961 for (x = 0; (int)x < ppt[i].fX; x++) {
4963 if (idx < sz)
fImage->alt.argb32[idx] = 0;
4965 for (x = ppt[i].fX + widths[i] + 1; x <
fImage->width; x++) {
4967 if (idx < sz)
fImage->alt.argb32[idx] = 0;
4972 for (y = y1; y <
fImage->height; y++) {
4973 for (x = 0; x <
fImage->width; x++) {
4975 if (idx < sz)
fImage->alt.argb32[idx] = 0;
5009 Warning(
"CopyArea",
"Visual not initiated");
5014 Warning(
"CopyArea",
"no image");
5019 ASImage *out = ((
TASImage*)dst)->GetImage();
5025 xsrc = xsrc < 0 ? 0 : xsrc;
5026 ysrc = ysrc < 0 ? 0 : ysrc;
5028 if ((xsrc >= (
int)
fImage->width) || (ysrc >= (
int)
fImage->height))
return;
5030 w = xsrc + w >
fImage->width ?
fImage->width - xsrc : w;
5037 if (!out->alt.argb32) {
5039 out = ((
TASImage*)dst)->GetImage();
5042 if (
fImage->alt.argb32 && out->alt.argb32) {
5043 for (y = 0; y < (int)h; y++) {
5044 for (x = 0; x < (int)w; x++) {
5045 idx =
Idx(yy + x + xsrc);
5046 if ((x + xdst < 0) || (ydst + y < 0) ||
5047 (x + xdst >= (
int)out->width) || (y + ydst >= (
int)out->height) )
continue;
5049 idx2 =
Idx((ydst + y)*out->width + x + xdst);
5053 out->alt.argb32[idx2] = 0;
5056 out->alt.argb32[idx2] &=
fImage->alt.argb32[idx];
5059 out->alt.argb32[idx2] =
fImage->alt.argb32[idx] & (~out->alt.argb32[idx2]);
5062 out->alt.argb32[idx2] &= ~
fImage->alt.argb32[idx];
5067 out->alt.argb32[idx2] ^=
fImage->alt.argb32[idx];
5070 out->alt.argb32[idx2] |=
fImage->alt.argb32[idx];
5073 out->alt.argb32[idx2] = (~
fImage->alt.argb32[idx]) & (~out->alt.argb32[idx2]);
5076 out->alt.argb32[idx2] ^= ~
fImage->alt.argb32[idx];
5079 out->alt.argb32[idx2] = ~out->alt.argb32[idx2];
5082 out->alt.argb32[idx2] =
fImage->alt.argb32[idx] | (~out->alt.argb32[idx2]);
5085 out->alt.argb32[idx2] = ~
fImage->alt.argb32[idx];
5088 out->alt.argb32[idx2] |= ~
fImage->alt.argb32[idx];
5091 out->alt.argb32[idx2] = (~
fImage->alt.argb32[idx]) | (~out->alt.argb32[idx2]);
5094 out->alt.argb32[idx2] = 0xFFFFFFFF;
5098 out->alt.argb32[idx2] =
fImage->alt.argb32[idx];
5122 int i, j, ix, iy, w,
h;
5124 ARGB32 color = 0xFFFFFFFF;
5131 for (i = 0; i <
nx; i++) {
5133 for (j = 0; j <
ny; j++) {
5134 icol = (ARGB32)ic[i + (nx*j)];
5135 if (icol != color) {
5174 ymin = ymax = (pts++)->fY;
5177 if (pts->
fY < ymin) {
5181 if (pts->
fY > ymax) {
5189 return (ptMin - ptsStart);
5205 int mr = 0, m1r = 0;
5206 int incr1l = 0, incr2l = 0;
5207 int incr1r = 0, incr2r = 0;
5212 int nextleft, nextright;
5225 Warning(
"GetPolygonSpans",
"Visual not initiated");
5230 Warning(
"GetPolygonSpans",
"no image");
5234 if (!
fImage->alt.argb32) {
5238 if (!
fImage->alt.argb32) {
5239 Warning(
"GetPolygonSpans",
"Failed to get pixel array");
5243 if ((npt < 3) || !ppt) {
5244 Warning(
"GetPolygonSpans",
"No points specified npt=%d ppt=0x%lx", npt, (
Long_t)ppt);
5252 dy = ymax - ymin + 1;
5253 if ((npt < 3) || (dy < 0))
return kFALSE;
5255 ptsOut = firstPoint =
new TPoint[dy];
5256 width = firstWidth =
new UInt_t[dy];
5259 nextleft = nextright = imin;
5260 y = ppt[nextleft].
fY;
5265 if (ppt[nextleft].fY == y) {
5271 if (nextleft >= (
int)npt) {
5278 ppt[left].fX, ppt[nextleft].fX,
5279 xl, dl, ml, m1l, incr1l, incr2l);
5283 if (ppt[nextright].fY == y) {
5289 if (nextright < 0) {
5296 ppt[right].fX, ppt[nextright].fX,
5297 xr, dr, mr, m1r, incr1r, incr2r);
5302 i =
TMath::Min(ppt[nextleft].fY, ppt[nextright].fY) -
y;
5306 delete [] firstWidth;
5307 delete [] firstPoint;
5316 *(width++) = xr - xl;
5317 (ptsOut++)->fX = xl;
5319 *(width++) = xl - xr;
5320 (ptsOut++)->fX = xr;
5328 }
while (y != ymax);
5330 *nspans =
UInt_t(ptsOut - firstPoint);
5331 *outPoint = firstPoint;
5332 *outWidth = firstWidth;
5349 ARGB32 color = ARGB32_White;
5350 parse_argb_color(col, &color);
5353 if (!stipple && ((color & 0xff000000)==0xff000000)) {
5356 FillSpans(nspans, firstPoint, firstWidth, col, stipple, w, h);
5360 delete [] firstWidth;
5361 delete [] firstPoint;
5364 if (firstWidth)
delete [] firstWidth;
5365 if (firstPoint)
delete [] firstPoint;
5382 FillSpans(nspans, firstPoint, firstWidth, tile);
5385 delete [] firstWidth;
5386 delete [] firstPoint;
5389 if (firstWidth)
delete [] firstWidth;
5390 if (firstPoint)
delete [] firstPoint;
5406 CropSpans(nspans, firstPoint, firstWidth);
5409 delete [] firstWidth;
5410 delete [] firstPoint;
5413 if (firstWidth)
delete [] firstWidth;
5414 if (firstPoint)
delete [] firstPoint;
5427 Warning(
"DrawFillArea",
"Visual not initiated");
5432 Warning(
"DrawFillArea",
"no image");
5436 if (!
fImage->alt.argb32) {
5440 if (!
fImage->alt.argb32) {
5441 Warning(
"DrawFillArea",
"Failed to get pixel array");
5445 if ((count < 3) || !ptsIn) {
5446 Warning(
"DrawFillArea",
"No points specified npt=%d ppt=0x%lx", count, (
Long_t)ptsIn);
5455 ARGB32 color = ARGB32_White;
5456 parse_argb_color(col, &color);
5474 static const UInt_t gEdgeTableEntryCacheSize = 200;
5475 static EdgeTableEntry gEdgeTableEntryCache[gEdgeTableEntryCacheSize];
5477 if (count < gEdgeTableEntryCacheSize) {
5485 ptsOut = firstPoint;
5488 pSLL = ET.scanlines.next;
5490 for (y = ET.ymin; y < ET.ymax; y++) {
5491 if (pSLL && y == pSLL->scanline) {
5492 loadAET(&AET, pSLL->edgelist);
5499 ptsOut->
fX = pAET->bres.minor_axis;
5504 *width++ = pAET->next->bres.minor_axis - pAET->bres.minor_axis;
5507 if (!stipple && ((color & 0xff000000)==0xff000000)) {
5510 FillSpans(nPts, firstPoint, firstWidth, col, stipple, w, h);
5512 ptsOut = firstPoint;
5523 if (!stipple && ((color & 0xff000000)==0xff000000)) {
5526 FillSpans(nPts, firstPoint, firstWidth, col, stipple, w, h);
5530 if (del)
delete [] pETEs;
5540 Warning(
"DrawFillArea",
"Visual not initiated");
5545 Warning(
"DrawFillArea",
"no image");
5549 if (!
fImage->alt.argb32) {
5553 if (!
fImage->alt.argb32) {
5554 Warning(
"DrawFillArea",
"Failed to get pixel array");
5558 if ((count < 3) || !ptsIn) {
5559 Warning(
"DrawFillArea",
"No points specified npt=%d ppt=0x%lx", count, (
Long_t)ptsIn);
5585 ptsOut = firstPoint;
5588 pSLL = ET.scanlines.next;
5590 for (y = ET.ymin; y < ET.ymax; y++) {
5591 if (pSLL && y == pSLL->scanline) {
5592 loadAET(&AET, pSLL->edgelist);
5599 ptsOut->
fX = pAET->bres.minor_axis;
5604 *width++ = pAET->next->bres.minor_axis - pAET->bres.minor_axis;
5607 FillSpans(nPts, firstPoint, firstWidth, tile);
5608 ptsOut = firstPoint;
5617 FillSpans(nPts, firstPoint, firstWidth, tile);
5628 ASDrawContext *ctx =
new ASDrawContext;
5630 ctx->canvas_width = im->width;
5631 ctx->canvas_height = im->height;
5632 ctx->canvas = im->alt.argb32;
5633 ctx->scratch_canvas = 0;
5635 ctx->flags = ASDrawCTX_CanvasIsARGB;
5636 asim_set_custom_brush_colored( ctx, brush);
5646 if (ctx->scratch_canvas)
free(ctx->scratch_canvas);
5660 Int_t sz = thick*thick;
5667 matrix =
new CARD32[sz];
5670 for (
int i = 0; i < sz; i++) {
5671 matrix[i] = (CARD32)color;
5675 brush.matrix = matrix;
5676 brush.width = thick;
5677 brush.height = thick;
5678 brush.center_y = brush.center_x = thick/2;
5687 if (xx1 ==
fImage->width) --xx1;
5688 if (yy1 ==
fImage->height) --yy1;
5689 if (xx2 ==
fImage->width) --xx2;
5690 if (yy2 ==
fImage->height) --yy2;
5692 asim_move_to(ctx, xx1, yy1);
5693 asim_line_to(ctx, xx2, yy2);
5708 Bool_t has_alpha = (color & 0xff000000) != 0xff000000;
5712 FT_Bitmap *source = (FT_Bitmap*)bitmap;
5713 UChar_t d = 0, *s = source->buffer;
5715 Int_t dots =
Int_t(source->width * source->rows);
5719 yy = y0 = by > 0 ? by *
fImage->width : 0;
5720 for (y = 0; y < (int) source->rows; y++) {
5722 if ((byy >= (
int)
fImage->height) || (byy <0))
continue;
5724 for (x = 0; x < (int) source->width; x++) {
5726 if ((bxx >= (
int)
fImage->width) || (bxx < 0))
continue;
5728 idx =
Idx(bxx + yy);
5729 r += ((
fImage->alt.argb32[idx] & 0xff0000) >> 16);
5730 g += ((
fImage->alt.argb32[idx] & 0x00ff00) >> 8);
5731 b += (
fImage->alt.argb32[idx] & 0x0000ff);
5741 col[0] = (r << 16) + (g << 8) +
b;
5743 Int_t col4r = (col[4] & 0xff0000) >> 16;
5744 Int_t col4g = (col[4] & 0x00ff00) >> 8;
5745 Int_t col4b = (col[4] & 0x0000ff);
5748 for (x = 3; x > 0; x--) {
5750 Int_t colxr = (col4r*x + r*xx) >> 2;
5751 Int_t colxg = (col4g*x + g*xx) >> 2;
5752 Int_t colxb = (col4b*x + b*xx) >> 2;
5753 col[
x] = (colxr << 16) + (colxg << 8) + colxb;
5758 for (y = 0; y < (int) source->rows; y++) {
5760 if ((byy >= (
int)
fImage->height) || (byy <0))
continue;
5762 for (x = 0; x < (int) source->width; x++) {
5767 d = ((d + 10) * 5) >> 8;
5770 if (d && (x < (
int) source->width) && (bxx < (
int)
fImage->width) && (bxx >= 0)) {
5771 idx =
Idx(bxx + yy);
5772 acolor = (ARGB32)col[d];
5776 fImage->alt.argb32[idx] = acolor;
5794 Warning(
"DrawText",
"Visual not initiated");
5798 if (!
fImage->alt.argb32) {
5823 const wchar_t *wcsTitle =
reinterpret_cast<const wchar_t *
>(text->
GetWcsTitle());
5824 if (wcsTitle !=
NULL) {
5834 col =
gROOT->GetColor(1);
5837 ARGB32 color = ARGB32_White;
5891 if (align == 1 || align == 2 || align == 3) {
5893 }
else if (align == 4 || align == 5 || align == 6) {
5900 if (align == 3 || align == 6 || align == 9) {
5902 }
else if (align == 2 || align == 5 || align == 8) {
5909 ftal.x = (ftal.x >> 6);
5910 ftal.y = (ftal.y >> 6);
5915 if (FT_Glyph_To_Bitmap(&glyph->
fImage, ft_render_mode_normal, 0, 1 ))
continue;
5917 FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph->
fImage;
5918 FT_Bitmap *source = &bitmap->bitmap;
5920 Int_t bx = x - ftal.x + bitmap->left;
5921 Int_t by = y + ftal.y - bitmap->top;
5949 if (FT_Glyph_To_Bitmap(&glyph->
fImage, ft_render_mode_normal, 0, 1 ))
continue;
5951 FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph->
fImage;
5952 FT_Bitmap *source = &bitmap->bitmap;
5954 Int_t bx = x + bitmap->left;