61# include FT_FREETYPE_H
88#include "RConfigure.h"
97# include "Windows4root.h"
101# define X_DISPLAY_MISSING 1
103# include <afterbase.h>
105# include <win32/config.h>
106# include <win32/afterbase.h>
107# define X_DISPLAY_MISSING 1
109# include <afterimage.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;\
233 fImage = create_asimage(w ? w : 20,
h ?
h : 20, 0);
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");
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;
771 }
else if(sLength>3 && sufix.
CountChar(
'+')==2 &&
TString(sufix(1,sLength-2)).Contains(
"++")) {
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");
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);
1140 static int x11 = -1;
1141 if (x11 < 0) x11 =
gVirtualX->InheritsFrom(
"TGX11");
1146 unsigned char *bits =
gVirtualX->GetColorBits(wd, 0, 0, w,
h);
1151 fImage = bitmap2asimage(bits, w,
h, 0, 0);
1172 Error(
"Draw",
"no image set");
1185 w =
Int_t(w*cx) + 4;
1190 rname =
"new TCanvas(\"" + rname +
Form(
"\", %d, %d);", w,
h);
1200 gPad->Range(-left / (1.0 - left - right),
1201 -bottom / (1.0 - top - bottom),
1202 1 + right / (1.0 - left - right),
1203 1 + top / ( 1.0 - top - bottom));
1204 gPad->RangeAxis(0, 0, 1, 1);
1227 wsrc = wsrc ? wsrc : im->width;
1228 hsrc = hsrc ? hsrc : im->height;
1230 static int x11 = -1;
1231 if (x11 < 0) x11 =
gVirtualX->InheritsFrom(
"TGX11");
1238 UInt_t ww = wsrc - ow + (ow ? 8 : 0);
1245 char *bits =
new char[ww*hh];
1247 ASImageDecoder *imdec = start_image_decoding(
fgVisual, im, SCL_DO_ALPHA,
1248 xsrc, ysrc, ww, 0, 0);
1250 for (yy = 0; yy < hh; yy++) {
1251 imdec->decode_image_scanline(imdec);
1252 CARD32 *
a = imdec->buffer.alpha;
1254 for (xx = 0; xx < ww; xx++) {
1269 stop_image_decoding(&imdec);
1272 (
const char *)bits, ww, hh);
1290 if (x11 && (!
gPad ||
gPad->GetGLDevice() == -1)) {
1291 asimage2drawable(
fgVisual, wid, im, (GC)gc, xsrc, ysrc,
x,
y, wsrc, hsrc, 1);
1294 unsigned char *bits = (
unsigned char *)im->alt.argb32;
1296 img = tile_asimage(
fgVisual, im, xsrc, ysrc, wsrc, hsrc,
1297 0, ASA_ARGB32, 0, ASIMAGE_QUALITY_DEFAULT);
1299 bits = (
unsigned char *)img->alt.argb32;
1306 if (
gPad &&
gPad->GetGLDevice() != -1) {
1308 painter->DrawPixels(bits, wsrc, hsrc,
x,
y, !option.
Contains(
"opaque"));
1316 gVirtualX->CopyArea(pic, wid, gc, 0, 0, wsrc, hsrc,
x,
y);
1323 destroy_asimage(&img);
1347 xsrc, ysrc, wsrc, hsrc, opt);
1366 Error(
"Paint",
"no image set");
1371 Warning(
"Paint",
"Visual not initiated");
1375 Int_t tile_x = 0, tile_y = 0;
1376 CARD32 tile_tint = 0;
1385 if (sscanf(opt.
Data() + opt.
Index(
"t"),
"t%d,%d,%s", &tile_x, &tile_y,
1388 if (parse_argb_color(stint, (CARD32*)&tile_tint) == stint)
1391 Error(
"Paint",
"tile option error");
1399 if (!
fImage->alt.vector) {
1412 to_h = (
Int_t)(to_h * (1.0 -
gPad->GetBottomMargin() -
gPad->GetTopMargin() ) + 0.5);
1413 to_w = (
Int_t)(to_w * (1.0 -
gPad->GetLeftMargin() -
gPad->GetRightMargin() ) + 0.5);
1416 if ((to_w < 25 || to_h < 25) && !expand) {
1417 Error(
"Paint",
"pad too small to display an image");
1429 Int_t pal_Ax = to_w +
gPad->UtoAbsPixel(
gPad->GetLeftMargin()) +
1430 (
gPad->UtoAbsPixel(
gPad->GetRightMargin()) / 10);
1432 Int_t pal_x = to_w +
gPad->UtoPixel(
gPad->GetLeftMargin()) +
1433 (
gPad->UtoPixel(
gPad->GetRightMargin()) / 10);
1438 ASImage *grad_im = 0;
1446 grad.type = GRADIENT_Top2Bottom;
1447 grad.color =
new ARGB32[grad.npoints];
1448 grad.offset =
new double[grad.npoints];
1451 Int_t oldPt = grad.npoints -
pt -1;
1452 grad.offset[
pt] = 1 - pal.
fPoints[oldPt];
1453 grad.color[
pt] = (((ARGB32)(pal.
fColorBlue[oldPt] & 0xff00)) >> 8) |
1455 (((ARGB32)(pal.
fColorRed[oldPt] & 0xff00)) << 8) |
1456 (((ARGB32)(pal.
fColorAlpha[oldPt] & 0xff00)) << 16);
1460 pal_h, SCL_DO_COLOR,
1463 delete [] grad.color;
1464 delete [] grad.offset;
1472 to_w, to_h, tile_tint, ASA_ASImage,
1499 ASImage *tmpImage = 0;
1510 destroy_asimage(&tmpImage);
1525 Error(
"Paint",
"image could not be rendered to display");
1529 int tox = expand ? 0 :
int(
gPad->UtoPixel(1.) *
gPad->GetLeftMargin());
1530 int toy = expand ? 0 :
int(
gPad->VtoPixel(0.) *
gPad->GetTopMargin());
1532 if (!
gROOT->IsBatch()) {
1547 axis.
PaintAxis(pal_Xpos,
gPad->PixeltoY(pal_Ay + pal_h - 1),
1548 pal_Xpos,
gPad->PixeltoY(pal_Ay),
1549 min, max, ndiv,
"+LU");
1554 pal_Xpos,
gPad->AbsPixeltoY(pal_Ay + 1),
1555 min, max, ndiv,
"+L");
1565 gPad->XtoAbsPixel(0),
gPad->YtoAbsPixel(1));
1570 dump->
Merge(&tgrad,
"alphablend", pal_Ax, pal_Ay);
1580 pal_Xpos,
gPad->AbsPixeltoY(pal_Ay + 1),
1581 min, max, ndiv,
"+L");
1585 Warning(
"Paint",
"PDF not implemented yet");
1588 Warning(
"Paint",
"SVG not implemented yet");
1597 color =
new TColor(
colors->GetEntries(), 1., 1., 1.,
"Image_PS");
1608 x2 =
x1+dx/image->width;
1610 y2 = y1+dy/image->height;
1613 x2 =
x1+(dx*(1-
gPad->GetRightMargin()-
gPad->GetLeftMargin()))/image->width;
1614 y1 =
gPad->GetY2()-dy*
gPad->GetTopMargin();
1615 y2 = y1+(dy*(1-
gPad->GetTopMargin()-
gPad->GetBottomMargin()))/image->height;
1620 ASImageDecoder *imdec = start_image_decoding(
fgVisual, image, SCL_DO_ALL,
1621 0, 0, image->width, image->height, 0);
1623 for (
Int_t yt = 0; yt < (
Int_t)image->height; yt++) {
1624 imdec->decode_image_scanline(imdec);
1625 for (
Int_t xt = 0; xt < (
Int_t)image->width; xt++)
1627 imdec->buffer.green[xt],
1628 imdec->buffer.blue[xt]);
1630 stop_image_decoding(&imdec);
1635 Double_t xconv = (
gPad->AbsPixeltoX(pal_Ax + pal_w) -
gPad->AbsPixeltoX(pal_Ax)) / grad_im->width;
1636 Double_t yconv = (
gPad->AbsPixeltoY(pal_Ay - pal_h) -
gPad->AbsPixeltoY(pal_Ay)) / grad_im->height;
1637 x1 =
gPad->AbsPixeltoX(pal_Ax);
1639 y2 =
gPad->AbsPixeltoY(pal_Ay);
1644 imdec = start_image_decoding(
fgVisual, grad_im, SCL_DO_ALL,
1645 0, 0, grad_im->width, grad_im->height, 0);
1647 for (
Int_t yt = 0; yt < (
Int_t)grad_im->height; yt++) {
1648 imdec->decode_image_scanline(imdec);
1649 for (
Int_t xt = 0; xt < (
Int_t)grad_im->width; xt++)
1651 imdec->buffer.green[xt],
1652 imdec->buffer.blue[xt]);
1655 stop_image_decoding(&imdec);
1666 pal_Xpos,
gPad->AbsPixeltoY(pal_Ay + 1),
1667 min, max, ndiv,
"+L");
1673 destroy_asimage(&grad_im);
1682 Int_t pxl, pyl, pxt, pyt;
1689 if (px1 < px2) {pxl = px1; pxt = px2;}
1690 else {pxl = px2; pxt = px1;}
1691 if (py1 < py2) {pyl = py1; pyt = py2;}
1692 else {pyl = py2; pyt = py1;}
1694 if ((px > pxl && px < pxt) && (py > pyl && py < pyt))
1705 static TBox *ZoomBox;
1716 static Int_t px1old, py1old, px2old, py2old;
1717 static Int_t px1, py1, px2, py2, pxl, pyl, pxt, pyt;
1728 if (imgX < 0) px = px - imgX;
1729 if (imgY < 0) py = py - imgY;
1734 if (imgX >= (
int)image->width) px = px - imgX + image->width - 1;
1735 if (imgY >= (
int)image->height) py = py - imgY + image->height - 1;
1740 px1 =
gPad->XtoAbsPixel(
gPad->GetX1());
1741 py1 =
gPad->YtoAbsPixel(
gPad->GetY1());
1742 px2 =
gPad->XtoAbsPixel(
gPad->GetX2());
1743 py2 =
gPad->YtoAbsPixel(
gPad->GetY2());
1744 px1old = px; py1old = py;
1766 ZoomBox =
new TBox(pxl, pyl, pxt, pyt);
1768 ZoomBox->
Draw(
"l*");
1787 Int_t imgX1 = px1old -
gPad->XtoAbsPixel(0);
1788 Int_t imgY1 = py1old -
gPad->YtoAbsPixel(1);
1789 Int_t imgX2 = px -
gPad->XtoAbsPixel(0);
1790 Int_t imgY2 = py -
gPad->YtoAbsPixel(1);
1792 imgY1 = image->height - 1 - imgY1;
1793 imgY2 = image->height - 1 - imgY2;
1799 Zoom((imgX1 < imgX2) ? imgX1 : imgX2, (imgY1 < imgY2) ? imgY1 : imgY2,
1818 static char info[64];
1824 px -=
gPad->XtoAbsPixel(0);
1825 py -=
gPad->YtoAbsPixel(1);
1828 if (px < 0 || py < 0)
return info;
1832 if (px >= (
int)image->width || py >= (
int)image->height)
1835 py = image->height - 1 - py;
1842 if (
fImage->alt.vector) {
1843 snprintf(info,64,
"x: %d y: %d %.5g",
1846 snprintf(info,64,
"x: %d y: %d", px, py);
1862 Warning(
"SetPalette",
"Visual not initiated");
1867 Warning(
"SetPalette",
"Image not valid");
1871 if (
fImage->alt.vector == 0)
1877 ASVectorPalette asPalette;
1879 asPalette.channels[0] =
new CARD16 [asPalette.npoints];
1880 asPalette.channels[1] =
new CARD16 [asPalette.npoints];
1881 asPalette.channels[2] =
new CARD16 [asPalette.npoints];
1882 asPalette.channels[3] =
new CARD16 [asPalette.npoints];
1888 asPalette.points =
new double[asPalette.npoints];
1889 for (
Int_t point = 0; point <
Int_t(asPalette.npoints); point++)
1895 delete [] asPalette.points;
1896 for (
Int_t col = 0; col < 4; col++)
1897 delete [] asPalette.channels[col];
1916 Warning(
"Scale",
"Image not initiated");
1921 Warning(
"Scale",
"Visual not initiated");
1929 if (toWidth > 30000)
1931 if (toHeight > 30000)
1934 ASImage *img = scale_asimage(
fgVisual,
fImage, toWidth, toHeight,
1951 Warning(
"Scale",
"Image not initiated");
1956 Warning(
"Scale",
"Visual not initiated");
1964 if (toWidth > 30000)
1966 if (toHeight > 30000)
1970 yStart, yEnd, toWidth, toHeight,
1986 Warning(
"Tile",
"Image not initiated");
1991 Warning(
"Tile",
"Visual not initiated");
1999 if (toWidth > 30000)
2001 if (toHeight > 30000)
2004 ASImage *img = tile_asimage(
fgVisual,
fImage, 0, 0, toWidth, toHeight, 0,
2026 Warning(
"Zoom",
"Image not valid");
2048 Warning(
"UnZoom",
"Image not valid");
2076 Warning(
"Flip",
"Image not valid");
2080 Warning(
"Flip",
"Visual not initiated");
2084 if (
fImage->alt.vector) {
2085 Warning(
"Flip",
"flip does not work for data images");
2123 Warning(
"Mirror",
"Image not valid");
2128 Warning(
"Mirror",
"Visual not initiated");
2132 if (
fImage->alt.vector) {
2133 Warning(
"Mirror",
"mirror does not work for data images");
2205 if (inbatch && !noX) {
2217 fgVisual = create_asvisual(0, 0, 0, 0);
2224 fgVisual = create_asvisual(0, 0, 0, 0);
2227 disp = (Display*)
gVirtualX->GetDisplay();
2230 Visual *vis = (Visual*)
gVirtualX->GetVisual();
2233 if (vis == 0 || cmap == 0) {
2234 fgVisual = create_asvisual(0, 0, 0, 0);
2236 fgVisual = create_asvisual_for_id(disp, screen, depth,
2237 XVisualIDFromVisual(vis), cmap, 0);
2241 fgVisual = create_asvisual(0, 0, 0, 0);
2254 Warning(
"StartPaletteEditor",
"Image not valid");
2257 if (
fImage->alt.vector == 0) {
2258 Warning(
"StartPaletteEditor",
"palette can be modified only for data images");
2273 Warning(
"GetPixmap",
"Visual not initiated");
2281 static int x11 = -1;
2282 if (x11 < 0) x11 =
gVirtualX->InheritsFrom(
"TGX11");
2288 if (!
fImage->alt.argb32) {
2291 ret =
gVirtualX->CreatePixmapFromData((
unsigned char*)
fImage->alt.argb32,
2307 Warning(
"GetMask",
"Visual not initiated");
2314 Warning(
"GetMask",
"No image");
2319 UInt_t ow = img->width%8;
2320 UInt_t ww = img->width - ow + (ow ? 8 : 0);
2327 char *bits =
new char[ww*hh];
2329 ASImageDecoder *imdec = start_image_decoding(
fgVisual, img, SCL_DO_ALPHA,
2336 for (
y = 0;
y < hh;
y++) {
2337 imdec->decode_image_scanline(imdec);
2338 CARD32 *
a = imdec->buffer.alpha;
2340 for (
x = 0;
x < ww;
x++) {
2354 stop_image_decoding(&imdec);
2355 pxmap =
gVirtualX->CreateBitmap(
gVirtualX->GetDefaultRootWindow(), (
const char *)bits,
2367 Warning(
"SetImage",
"Visual not initiated");
2381 static int x11 = -1;
2382 if (x11 < 0) x11 =
gVirtualX->InheritsFrom(
"TGX11");
2387 unsigned char *bits =
gVirtualX->GetColorBits(pxm, 0, 0, w,
h);
2394 fImage = bitmap2asimage(bits, w,
h, 0, 0);
2398 unsigned char *mask_bits =
gVirtualX->GetColorBits(mask, 0, 0, w,
h);
2399 fImage = bitmap2asimage(bits, w,
h, 0, mask_bits);
2400 delete [] mask_bits;
2411 Warning(
"GetPixels",
"Wrong Image");
2416 ASImageDecoder *imdec;
2419 height = !height ? img->height : height;
2430 if ((
x >= (
int)img->width) || (
y >= (
int)img->height)) {
2434 if ((
int)(
x +
width) > (
int)img->width) {
2438 if ((
int)(
y + height) > (
int)img->height) {
2439 height = img->height -
y;
2442 if ((imdec = start_image_decoding(0,
fImage, SCL_DO_ALL, 0,
y,
2443 img->width, height, 0)) == 0) {
2444 Warning(
"GetPixels",
"Failed to create image decoder");
2454 for (
UInt_t k = 0; k < height; k++) {
2455 imdec->decode_image_scanline(imdec);
2458 if ((
r == (
Int_t)imdec->buffer.red[i]) &&
2459 (
g == (
Int_t)imdec->buffer.green[i]) &&
2460 (
b == (
Int_t)imdec->buffer.blue[i])) {
2462 r = (
Int_t)imdec->buffer.red[i];
2463 g = (
Int_t)imdec->buffer.green[i];
2464 b = (
Int_t)imdec->buffer.blue[i];
2471 stop_image_decoding(&imdec);
2483 Warning(
"GetVecArray",
"Bad Image");
2486 if (
fImage->alt.vector) {
2487 return fImage->alt.vector;
2505 Warning(
"GetArray",
"Bad Image");
2511 if (
fImage->alt.vector) {
2516 ASImageDecoder *imdec;
2518 w = w ? w :
fImage->width;
2527 if ((imdec = start_image_decoding(0, img, SCL_DO_ALL, 0, 0,
2528 img->width, 0, 0)) == 0) {
2529 Warning(
"GetArray",
"Failed to create image decoder");
2540 for (
UInt_t k = 0; k <
h; k++) {
2541 imdec->decode_image_scanline(imdec);
2543 for (
UInt_t i = 0; i < w; ++i) {
2544 if ((
r == imdec->buffer.red[i]) &&
2545 (
g == imdec->buffer.green[i]) &&
2546 (
b == imdec->buffer.blue[i])) {
2548 r = imdec->buffer.red[i];
2549 g = imdec->buffer.green[i];
2550 b = imdec->buffer.blue[i];
2558 stop_image_decoding(&imdec);
2581 const char *color,
const char *font_name,
2585 ARGB32 text_color = ARGB32_Black;
2586 ASImage *fore_im = 0;
2587 ASImage *text_im = 0;
2591 Warning(
"DrawText",
"Visual not initiated");
2599 if (fn.
Last(
'/') == 0) fn = fn(1, fn.
Length() - 1);
2612 parse_argb_color(color, &text_color);
2625 Warning(
"DrawText",
"cannot create Font Manager");
2632 font = get_asfont(
gFontManager,
"fixed", 0, size, ASF_GuessWho);
2634 Warning(
"DrawText",
"cannot find a font %s", font_name);
2639 get_text_size(
text, font, (ASText3DType)
type, &
width, &height);
2646 text_im = draw_text(
text, font, (ASText3DType)
type, 0);
2651 ASImage *tmp = file2ASImage(fore_file, 0xFFFFFFFF, SCREEN_GAMMA, 0, 0);
2653 if ((tmp->width !=
width) || (tmp->height != height)) {
2654 fore_im = tile_asimage(
fgVisual, tmp, 0, 0,
width, height, 0,
2657 destroy_asimage(&tmp);
2664 move_asimage_channel(fore_im, IC_ALPHA, text_im, IC_ALPHA);
2665 destroy_asimage(&text_im);
2673 ASImage *rendered_im;
2674 ASImageLayer layers[2];
2676 init_image_layers(&(layers[0]), 2);
2677 fore_im->back_color = text_color;
2678 layers[0].im = rimg;
2679 layers[0].dst_x = 0;
2680 layers[0].dst_y = 0;
2681 layers[0].clip_width = rimg->width;
2682 layers[0].clip_height = rimg->height;
2683 layers[0].bevel = 0;
2684 layers[1].im = fore_im;
2685 layers[1].dst_x =
x;
2686 layers[1].dst_y =
y;
2687 layers[1].clip_width = fore_im->width;
2688 layers[1].clip_height = fore_im->height;
2690 rendered_im = merge_layers(
fgVisual, &(layers[0]), 2, rimg->width, rimg->height,
2693 destroy_asimage(&fore_im);
2726 Warning(
"Merge",
"Visual not initiated");
2730 ASImage *rendered_im;
2731 ASImageLayer layers[2];
2733 init_image_layers(&(layers[0]), 2);
2735 layers[0].dst_x = 0;
2736 layers[0].dst_y = 0;
2737 layers[0].clip_width =
fImage->width;
2738 layers[0].clip_height =
fImage->height;
2739 layers[0].bevel = 0;
2740 layers[1].im = ((
TASImage*)im)->fImage;
2741 layers[1].dst_x =
x;
2742 layers[1].dst_y =
y;
2743 layers[1].clip_width = im->
GetWidth();
2744 layers[1].clip_height = im->
GetHeight();
2745 layers[1].merge_scanlines = blend_scanlines_name2func(op ? op :
"add");
2763 Warning(
"Blur",
"Visual not initiated");
2768 fImage = create_asimage(100, 100, 0);
2771 Warning(
"Blur",
"Failed to create image");
2778 ASImage *rendered_im = blur_asimage_gauss(
fgVisual,
fImage, hr > 0 ? hr : 3,
2779 vr > 0 ? vr : 3, SCL_DO_ALL,
2792 Warning(
"Clone",
"Image not initiated");
2799 Warning(
"Clone",
"Failed to create image");
2815 if (
fImage->alt.argb32) {
2817 im->
fImage->alt.argb32 = (ARGB32*)safemalloc(sz*
sizeof(ARGB32));
2818 memcpy(im->
fImage->alt.argb32,
fImage->alt.argb32, sz *
sizeof(ARGB32));
2838 Warning(
"Vectorize",
"Visual not initiated");
2843 fImage = create_asimage(100, 100, 0);
2846 Warning(
"Vectorize",
"Failed to create image");
2857 dither = dither > 7 ? 7 : dither;
2859 res = colormap_asimage(
fImage, &cmap, max_colors, dither, opaque_threshold);
2871 g = INDEX_SHIFT_GREEN(cmap.entries[res[i]].green);
2872 b = INDEX_SHIFT_BLUE(cmap.entries[res[i]].blue);
2873 r = INDEX_SHIFT_RED(cmap.entries[res[i]].red);
2875 v = MAKE_INDEXED_COLOR24(
r,
g,
b);
2885 for (
UInt_t j = 0; j < cmap.count; j++) {
2886 g = INDEX_SHIFT_GREEN(cmap.entries[j].green);
2887 b = INDEX_SHIFT_BLUE(cmap.entries[j].blue);
2888 r = INDEX_SHIFT_RED(cmap.entries[j].red);
2889 v = MAKE_INDEXED_COLOR24(
r,
g,
b);
2891 v = (
v>>12) & 0x0FFF;
2894 pal->
fColorRed[j] = cmap.entries[j].red << 8;
2896 pal->
fColorBlue[j] = cmap.entries[j].blue << 8;
2900 destroy_colormap(&cmap,
kTRUE);
2903 fImage->alt.vector = vec;
2906 if (res) safefree(res);
2952 Warning(
"HSV",
"Visual not initiated");
2960 Warning(
"HSV",
"Failed to create image");
2970 height = !height ?
fImage->height : height;
2972 ASImage *rendered_im = 0;
2976 hue, radius,
H, S, V, ASA_ASImage, 100,
2977 ASIMAGE_QUALITY_TOP);
2980 Warning(
"HSV",
"Failed to create rendered image");
3015 Warning(
"Gradient",
"Visual not initiated");
3019 ASImage *rendered_im = 0;
3020 ASGradient gradient;
3022 int reverse = 0, npoints1 = 0, npoints2 = 0;
3029 if ((angle > 2 * 180 * 15 / 16) || (angle < 2 * 180 * 1 / 16)) {
3030 gradient.type = GRADIENT_Left2Right;
3031 }
else if (angle < 2 * 180 * 3 / 16) {
3032 gradient.type = GRADIENT_TopLeft2BottomRight;
3033 }
else if (angle < 2 * 180 * 5 / 16) {
3034 gradient.type = GRADIENT_Top2Bottom;
3035 }
else if (angle < 2 * 180 * 7 / 16) {
3036 gradient.type = GRADIENT_BottomLeft2TopRight; reverse = 1;
3037 }
else if (angle < 2 * 180 * 9 / 16) {
3038 gradient.type = GRADIENT_Left2Right; reverse = 1;
3039 }
else if (angle < 2 * 180 * 11 / 16) {
3040 gradient.type = GRADIENT_TopLeft2BottomRight; reverse = 1;
3041 }
else if (angle < 2 * 180 * 13 / 16) {
3042 gradient.type = GRADIENT_Top2Bottom; reverse = 1;
3044 gradient.type = GRADIENT_BottomLeft2TopRight;
3047 for (p = (
char*)
colors; isspace((
int)*p); p++) { }
3049 for (npoints1 = 0; *p; npoints1++) {
3051 for ( ; *p && !isspace((
int)*p); p++) { }
3053 for ( ; isspace((
int)*p); p++) { }
3056 for (p = (
char*)offsets; isspace((
int)*p); p++) { }
3058 for (npoints2 = 0; *p; npoints2++) {
3060 for ( ; *p && !isspace((
int)*p); p++) { }
3062 for ( ; isspace((
int)*p); p++) { }
3067 if (offsets && (npoints1 > npoints2)) npoints1 = npoints2;
3076 gradient.color =
new ARGB32[npoints1];
3077 gradient.offset =
new double[npoints1];
3079 for (p = (
char*)
colors; isspace((
int)*p); p++) { }
3081 for (npoints1 = 0; *p; ) {
3085 for ( ; *p && !isspace((
int)*p); p++) { }
3087 for ( ; isspace((
int)*p); p++) { }
3089 col = str(pb -
colors, p - pb);
3091 if (parse_argb_color(col.
Data(), gradient.color + npoints1) != col) {
3094 Warning(
"Gradient",
"Failed to parse color [%s] - defaulting to black", pb);
3099 for (p = (
char*)offsets; isspace((
int)*p); p++) { }
3101 for (npoints2 = 0; *p; ) {
3105 for ( ; *p && !isspace((
int)*p); p++) { }
3108 gradient.offset[npoints2] = strtod(pb, &pb);
3110 if (pb == p) npoints2++;
3112 for ( ; isspace((
int)*p); p++) { }
3115 for (npoints2 = 0; npoints2 < npoints1; npoints2++) {
3116 gradient.offset[npoints2] = (
double)npoints2 / (npoints1 - 1);
3119 gradient.npoints = npoints1;
3121 if (npoints2 && (gradient.npoints > npoints2)) {
3122 gradient.npoints = npoints2;
3125 for (i = 0; i < gradient.npoints/2; i++) {
3126 int i2 = gradient.npoints - 1 - i;
3127 ARGB32
c = gradient.color[i];
3128 double o = gradient.offset[i];
3129 gradient.color[i] = gradient.color[i2];
3130 gradient.color[i2] =
c;
3131 gradient.offset[i] = gradient.offset[i2];
3132 gradient.offset[i2] = o;
3134 for (i = 0; i < gradient.npoints; i++) {
3135 gradient.offset[i] = 1.0 - gradient.offset[i];
3138 rendered_im = make_gradient(
fgVisual, &gradient,
width, height, SCL_DO_ALL,
3141 delete [] gradient.color;
3142 delete [] gradient.offset;
3146 Warning(
"Gradient",
"Failed to create gradient image");
3155 ASImageLayer layers[2];
3157 init_image_layers(&(layers[0]), 2);
3159 layers[0].dst_x = 0;
3160 layers[0].dst_y = 0;
3161 layers[0].clip_width =
fImage->width;
3162 layers[0].clip_height =
fImage->height;
3163 layers[0].bevel = 0;
3164 layers[1].im = rendered_im;
3165 layers[1].dst_x =
x;
3166 layers[1].dst_y =
y;
3167 layers[1].clip_width =
width;
3168 layers[1].clip_height = height;
3169 layers[1].merge_scanlines = alphablend_scanlines;
3174 Warning(
"Gradient",
"Failed to create merged image");
3178 destroy_asimage(&rendered_im);
3193 cmp = (cmp * 12) / 10;
3195 return (cmp > 255) ? 255 : cmp;
3216 return (background >> 1) & 0x7F7F7F7F;
3227 a = ARGB32_ALPHA8(foreground) + ARGB32_ALPHA8(background);
3229 r = ARGB32_RED8(foreground) + ARGB32_RED8(background);
3231 g = ARGB32_GREEN8(foreground) + ARGB32_GREEN8(background);
3233 b = ARGB32_BLUE8(foreground) + ARGB32_BLUE8(background);
3236 return MAKE_ARGB32(
a,
r,
g,
b);
3252 const char *hi_color,
const char *lo_color,
UShort_t thick,
3256 Warning(
"Bevel",
"Visual not initiated");
3263 ARGB32
hi=ARGB32_White, lo=ARGB32_White;
3264 parse_argb_color(hi_color, &
hi);
3265 parse_argb_color(lo_color, &lo);
3268 bevel.lo_color =
hi;
3270 bevel.hi_color = lo;
3273 bevel.hi_color =
hi;
3275 bevel.lo_color = lo;
3280 int extra_hilite = 2;
3281 bevel.left_outline = bevel.top_outline = bevel.right_outline = bevel.bottom_outline = thick;
3282 bevel.left_inline = bevel.top_inline = bevel.right_inline = bevel.bottom_inline = extra_hilite + 1;
3284 if (bevel.top_outline > 1) {
3285 bevel.top_inline += bevel.top_outline - 1;
3288 if (bevel.left_outline > 1) {
3289 bevel.left_inline += bevel.left_outline - 1;
3292 if (bevel.right_outline > 1) {
3293 bevel.right_inline += bevel.right_outline - 1;
3296 if (bevel.bottom_outline > 1) {
3297 bevel.bottom_inline += bevel.bottom_outline - 1;
3301 ARGB32 fill = ((
hi>>24) != 0xff) || ((lo>>24) != 0xff) ? bevel.hilo_color : (bevel.hilo_color | 0xff000000);
3307 Warning(
"Bevel",
"Failed to create image");
3317 height = !height ?
fImage->height : height;
3319 ASImageLayer layers[2];
3320 init_image_layers(&(layers[0]), 2);
3323 layers[0].dst_x = 0;
3324 layers[0].dst_y = 0;
3325 layers[0].clip_width =
fImage->width;
3326 layers[0].clip_height =
fImage->height;
3327 layers[0].bevel = 0;
3329 UInt_t w =
width - (bevel.left_outline + bevel.right_outline);
3330 UInt_t h = height - (bevel.top_outline + bevel.bottom_outline);
3331 ASImage *bevel_im = create_asimage(w,
h, 0);
3334 Warning(
"Bevel",
"Failed to create bevel image");
3338 layers[1].im = bevel_im;
3339 fill_asimage(
fgVisual, bevel_im, 0, 0, w,
h, fill);
3341 layers[1].dst_x =
x;
3342 layers[1].dst_y =
y;
3343 layers[1].clip_width =
width;
3344 layers[1].clip_height = height;
3345 layers[1].bevel = &bevel;
3346 layers[1].merge_scanlines = alphablend_scanlines;
3350 destroy_asimage(&bevel_im);
3353 Warning(
"Bevel",
"Failed to image");
3373 Warning(
"Pad",
"Visual not initiated");
3378 fImage = create_asimage(100, 100, 0);
3381 Warning(
"Pad",
"Failed to create image");
3388 ARGB32 color = ARGB32_White;
3389 parse_argb_color(col, &color);
3400 Warning(
"Pad",
"Failed to create output image");
3417 Warning(
"Crop",
"Visual not initiated");
3430 height =
y + height >
fImage->height ?
fImage->height -
y : height;
3433 Warning(
"Crop",
"input size larger than image");
3436 ASImageDecoder *imdec = start_image_decoding(
fgVisual,
fImage, SCL_DO_ALL,
3440 Warning(
"Crop",
"Failed to start image decoding");
3444 ASImage *img = create_asimage(
width, height, 0);
3448 Warning(
"Crop",
"Failed to create image");
3452 ASImageOutput *imout = start_image_output(
fgVisual, img, ASA_ASImage,
3456 Warning(
"Crop",
"Failed to start image output");
3457 destroy_asimage(&img);
3458 if (imdec)
delete [] imdec;
3466 for (
UInt_t i = 0; i < height; i++) {
3467 imdec->decode_image_scanline(imdec);
3468 imout->output_image_scanline(imout, &(imdec->buffer), 1);
3471 stop_image_decoding(&imdec);
3472 stop_image_output(&imout);
3496 Warning(
"Append",
"Visual not initiated");
3514 }
else if (opt ==
"/") {
3516 Merge(im,
"alphablend", 0, height);
3535 Warning(
"BeginPaint",
"Visual not initiated");
3550 0, ASA_ARGB32, 0, ASIMAGE_QUALITY_DEFAULT);
3553 Warning(
"BeginPaint",
"Failed to create image");
3567 Warning(
"EndPaint",
"no image");
3571 if (!
fImage->alt.argb32)
return;
3574 0, ASA_ASImage, 0, ASIMAGE_QUALITY_DEFAULT);
3577 Warning(
"EndPaint",
"Failed to create image");
3594 Warning(
"GetArgbArray",
"no image");
3601 if (!img->alt.argb32) {
3611 return (
UInt_t *)img->alt.argb32;
3622 Warning(
"GetRgbaArray",
"no image");
3629 if (!img->alt.argb32) {
3647 for (i = 0; i < img->height; i++) {
3648 for (j = 0; j < img->width; j++) {
3650 argb = img->alt.argb32[idx];
3652 rgb = argb & 0x00ffffff;
3653 rgba = (rgb << 8) +
a;
3668 Warning(
"GetScanline",
"no image");
3673 CARD32 *ret =
new CARD32[img->width];
3675 ASImageDecoder *imdec = start_image_decoding(
fgVisual, img, SCL_DO_ALL,
3676 0,
y, img->width, 1, 0);
3680 Warning(
"GetScanline",
"Failed to start image decoding");
3688 imdec->decode_image_scanline(imdec);
3689 memcpy(imdec->buffer.buffer, ret, img->width*
sizeof(CARD32));
3690 stop_image_decoding(&imdec);
3705#if defined(R__GNU) && defined(__i386__) && !defined(__sun)
3706#define _MEMSET_(dst, lng, val) __asm__("movl %0,%%eax \n"\
3707 "movl %1,%%edi \n" \
3708 "movl %2,%%ecx \n" \
3713 :"g" (val), "g" (dst), "g" (lng) \
3714 :"eax","edi","ecx" \
3718 #define _MEMSET_(dst, lng, val) do {\
3719 for( UInt_t j=0; j < lng; j++) *((dst)+j) = val; } while (0)
3723#define FillSpansInternal(npt, ppt, widths, color) do {\
3724 UInt_t yy = ppt[0].fY*fImage->width;\
3725 for (UInt_t i = 0; i < npt; i++) {\
3726 _MEMSET_(&fImage->alt.argb32[Idx(yy + ppt[i].fX)], widths[i], color);\
3727 yy += ((i+1 < npt) && (ppt[i].fY != ppt[i+1].fY) ? fImage->width : 0);\
3739 Warning(
"FillRectangle",
"Visual not initiated");
3744 Warning(
"FillRectangle",
"no image");
3748 if (!
fImage->alt.argb32) {
3752 if (!
fImage->alt.argb32) {
3753 Warning(
"FillRectangle",
"Failed to get pixel array");
3757 ARGB32 color = (ARGB32)col;
3760 if (height == 0) height = 1;
3771 Bool_t has_alpha = (color & 0xff000000) != 0xff000000;
3777 height =
y + height >
fImage->height ?
fImage->height -
y : height;
3779 if (!
fImage->alt.argb32) {
3784 ARGB32 *p0 =
fImage->alt.argb32 + yyy +
x;
3786 for (
UInt_t i = 0; i < height; i++) {
3791 for (
UInt_t i =
y; i <
y + height; i++) {
3816 Warning(
"Fill",
"Visual not initiated");
3820 ARGB32 color = ARGB32_White;
3823 parse_argb_color(col, &color);
3841 ARGB32 color = (ARGB32)col;
3844 if (!thick) thick = 1;
3852 thick += (
x - half);
3860 int yy = y1*
fImage->width;
3862 for (
UInt_t w = 0; w < thick; w++) {
3863 if (
x + w < fImage->
width) {
3876 ARGB32 color = (ARGB32)col;
3879 if (!thick) thick = 1;
3887 thick += (
y - half);
3896 for (
UInt_t w = 0; w < thick; w++) {
3898 if (
y + w < fImage->height) {
3910 const char *col,
UInt_t thick)
3912 ARGB32 color = ARGB32_White;
3913 parse_argb_color(col, &color);
3925 int x,
y, xend, yend;
3932 Warning(
"DrawLine",
"Visual not initiated");
3937 Warning(
"DrawLine",
"no image");
3941 if (!
fImage->alt.argb32) {
3945 if (!
fImage->alt.argb32) {
3946 Warning(
"DrawLine",
"Failed to get pixel array");
3950 ARGB32 color = (ARGB32)col;
3955 if (!dx && !dy)
return;
3959 y2 > y1 ? y2 : y1, color, thick);
3977 i2 = i1 - (dx << 1);
3994 q = (y2 - y1) * ydir;
4027 i2 = i1 - (dy << 1);
4044 q = (
x2 -
x1) * xdir;
4082 const char *col,
UInt_t thick)
4085 Warning(
"DrawRectangle",
"Visual not initiated");
4092 fImage = create_asimage(w,
h, 0);
4097 if (!
fImage->alt.argb32) {
4101 if (!
fImage->alt.argb32) {
4102 Warning(
"DrawRectangle",
"Failed to get pixel array");
4106 ARGB32 color = ARGB32_White;
4107 parse_argb_color(col, &color);
4127 ARGB32 color = ARGB32_White;
4132 fImage = create_asimage(w,
h, 0);
4138 parse_argb_color(col, &color);
4144 parse_argb_color(col, &color);
4174 ARGB32 color = (ARGB32)col;
4184 thick += (
y - half);
4187 thick = thick <= 0 ? 1 : thick;
4196 x2 =
x2 < tmp ? tmp :
x2;
4199 for (
UInt_t w = 0; w < thick; w++) {
4200 if (
y + w < fImage->height) {
4208 if (i >= pDash[iDash]) {
4212 if (iDash >= nDash) {
4228 ARGB32 color = (ARGB32)col;
4238 thick += (
x - half);
4241 thick = thick <= 0 ? 1 : thick;
4248 y1 = y2 < y1 ? y2 : y1;
4249 y2 = y2 < tmp ? tmp : y2;
4253 int yy = y1*
fImage->width;
4255 for (
UInt_t w = 0; w < thick; w++) {
4256 if (
x + w < fImage->
width) {
4264 if (i >= pDash[iDash]) {
4268 if (iDash >= nDash) {
4284 int x,
y, xend, yend;
4294 char *pDash =
new char[nDash];
4299 for (i = 0; i < (
int)nDash; i++) {
4305 i2 = i1 - (dx << 1);
4323 q = (y2 - y1) * ydir;
4328 if ((iDash%2) == 0) {
4340 if (i >= pDash[iDash]) {
4344 if (iDash >= nDash) {
4352 if ((iDash%2) == 0) {
4364 if (i >= pDash[iDash]) {
4368 if (iDash >= nDash) {
4377 for (i = 0; i < (
int)nDash; i++) {
4383 i2 = i1 - (dy << 1);
4401 q = (
x2 -
x1) * xdir;
4406 if ((iDash%2) == 0) {
4420 if (i >= pDash[iDash]) {
4424 if (iDash >= nDash) {
4432 if ((iDash%2) == 0) {
4446 if (i >= pDash[iDash]) {
4450 if (iDash >= nDash) {
4468 double x,
y, xend=0, yend=0, x0, y0;
4476 double *xDash =
new double[nDash];
4477 double *yDash =
new double[nDash];
4482 for (i = 0; i < (
int)nDash; i++) {
4483 xDash[i] = tDash[i] * ac;
4484 yDash[i] = tDash[i] * as;
4488 xDash[i] = xDash[i]/2;
4489 yDash[i] = yDash[i]/2;
4491 xDash[i] = xDash[i]*2;
4492 yDash[i] = yDash[i]*2;
4509 q = (y2 - y1) * ydir;
4516 while ((
x < xend) && (
y < yend)) {
4520 if ((iDash%2) == 0) {
4530 if (iDash >= nDash) {
4535 while ((
x < xend) && (
y > yend)) {
4539 if ((iDash%2) == 0) {
4549 if (iDash >= nDash) {
4568 q = (
x2 -
x1) * xdir;
4575 while ((
x < xend) && (
y < yend)) {
4579 if ((iDash%2) == 0) {
4589 if (iDash >= nDash) {
4594 while ((
x > xend) && (
y < yend)) {
4598 if ((iDash%2) == 0) {
4608 if (iDash >= nDash) {
4622 const char *pDash,
const char *col,
UInt_t thick)
4626 Warning(
"DrawDashLine",
"Visual not initiated");
4631 Warning(
"DrawDashLine",
"no image");
4635 if (!
fImage->alt.argb32) {
4639 if (!
fImage->alt.argb32) {
4640 Warning(
"DrawDashLine",
"Failed to get pixel array");
4644 if ((nDash < 2) || !pDash || (nDash%2)) {
4645 Warning(
"DrawDashLine",
"Wrong input parameters n=%d %ld", nDash, (
Long_t)
sizeof(pDash)-1);
4649 ARGB32 color = ARGB32_White;
4650 parse_argb_color(col, &color);
4654 }
else if (y1 == y2) {
4668 ARGB32 color = ARGB32_White;
4669 parse_argb_color(col, &color);
4676 for (
UInt_t i = 1; i < nn; i++) {
4693 Warning(
"PutPixel",
"Visual not initiated");
4698 Warning(
"PutPixel",
"no image");
4702 if (!
fImage->alt.argb32) {
4706 if (!
fImage->alt.argb32) {
4707 Warning(
"PutPixel",
"Failed to get pixel array");
4712 parse_argb_color(col, &color);
4714 if ((
x < 0) || (
y < 0) || (
x >= (
int)
fImage->width) || (
y >= (
int)
fImage->height)) {
4715 Warning(
"PutPixel",
"Out of range width=%d x=%d, height=%d y=%d",
4728 Warning(
"PolyPoint",
"Visual not initiated");
4733 Warning(
"PolyPoint",
"no image");
4737 if (!
fImage->alt.argb32) {
4741 if (!
fImage->alt.argb32) {
4742 Warning(
"PolyPoint",
"Failed to get pixel array");
4747 Warning(
"PolyPoint",
"No points specified");
4754 parse_argb_color(col, &color);
4760 for (i = 0; i < npt; i++) {
4761 ipt[i].
fX += ppt[i].
fX;
4762 ipt[i].
fY += ppt[i].
fY;
4767 for (i = 0; i < npt; i++) {
4768 x = ipt ? ipt[i].
fX : ppt[i].
fX;
4769 y = ipt ? ipt[i].
fY : ppt[i].
fY;
4771 if ((
x < 0) || (
y < 0) || (
x >= (
int)
fImage->width) || (
y >= (
int)
fImage->height)) {
4787 if (!nseg || !seg) {
4788 Warning(
"DrawSegments",
"Invalid data nseg=%d seg=0x%lx", nseg, (
Long_t)seg);
4794 for (
UInt_t i = 0; i < nseg; i++) {
4795 pt[0].fX = seg->
fX1;
4796 pt[1].fX = seg->
fX2;
4797 pt[0].fY = seg->
fY1;
4798 pt[1].fY = seg->
fY2;
4812 Warning(
"FillSpans",
"Visual not initiated");
4817 Warning(
"FillSpans",
"no image");
4821 if (!
fImage->alt.argb32) {
4825 if (!
fImage->alt.argb32) {
4826 Warning(
"FillSpans",
"Failed to get pixel array");
4830 if (!npt || !ppt || !widths || (stipple && (!w || !
h))) {
4831 Warning(
"FillSpans",
"Invalid input data npt=%d ppt=0x%lx col=%s widths=0x%lx stipple=0x%lx w=%d h=%d",
4837 parse_argb_color(col, &color);
4842 for (
UInt_t i = 0; i < npt; i++) {
4844 for (
UInt_t j = 0; j < widths[i]; j++) {
4845 if ((ppt[i].fX >= (
Int_t)
fImage->width) || (ppt[i].
fX < 0) ||
4856 if (stipple[ii >> 3] & (1 << (ii%8))) {
4870 Warning(
"FillSpans",
"Visual not initiated");
4875 Warning(
"FillSpans",
"no image");
4879 if (!
fImage->alt.argb32) {
4883 if (!
fImage->alt.argb32) {
4884 Warning(
"FillSpans",
"Failed to get pixel array");
4888 if (!npt || !ppt || !widths || !tile) {
4889 Warning(
"FillSpans",
"Invalid input data npt=%d ppt=0x%lx widths=0x%lx tile=0x%lx",
4902 for (
UInt_t i = 0; i < npt; i++) {
4905 for (
UInt_t j = 0; j < widths[i]; j++) {
4906 if ((ppt[i].fX >= (
Int_t)
fImage->width) || (ppt[i].
fX < 0) ||
4924 Warning(
"CropSpans",
"Visual not initiated");
4929 Warning(
"CropSpans",
"no image");
4933 if (!
fImage->alt.argb32) {
4937 if (!
fImage->alt.argb32) {
4938 Warning(
"CropSpans",
"Failed to get pixel array");
4942 if (!npt || !ppt || !widths) {
4943 Warning(
"CropSpans",
"No points specified npt=%d ppt=0x%lx widths=0x%lx", npt, (
Long_t)ppt, (
Long_t)widths);
4948 int y1 = ppt[npt-1].
fY;
4956 for (
y = 0; (
int)
y < y0;
y++) {
4959 if (idx < sz)
fImage->alt.argb32[idx] = 0;
4964 for (i = 0; i < npt; i++) {
4965 for (
x = 0; (
int)
x < ppt[i].fX;
x++) {
4967 if (idx < sz)
fImage->alt.argb32[idx] = 0;
4969 for (
x = ppt[i].fX + widths[i] + 1;
x <
fImage->width;
x++) {
4971 if (idx < sz)
fImage->alt.argb32[idx] = 0;
4979 if (idx < sz)
fImage->alt.argb32[idx] = 0;
5013 Warning(
"CopyArea",
"Visual not initiated");
5018 Warning(
"CopyArea",
"no image");
5023 ASImage *out = ((
TASImage*)dst)->GetImage();
5029 xsrc = xsrc < 0 ? 0 : xsrc;
5030 ysrc = ysrc < 0 ? 0 : ysrc;
5032 if ((xsrc >= (
int)
fImage->width) || (ysrc >= (
int)
fImage->height))
return;
5034 w = xsrc + w >
fImage->width ?
fImage->width - xsrc : w;
5038 if (!
fImage->alt.argb32) {
5041 if (!out->alt.argb32) {
5043 out = ((
TASImage*)dst)->GetImage();
5046 if (
fImage->alt.argb32 && out->alt.argb32) {
5047 for (
y = 0;
y < (
int)
h;
y++) {
5048 for (
x = 0;
x < (
int)w;
x++) {
5049 idx =
Idx(yy +
x + xsrc);
5050 if ((
x + xdst < 0) || (ydst +
y < 0) ||
5051 (
x + xdst >= (
int)out->width) || (
y + ydst >= (
int)out->height) )
continue;
5053 idx2 =
Idx((ydst +
y)*out->width +
x + xdst);
5057 out->alt.argb32[idx2] = 0;
5060 out->alt.argb32[idx2] &=
fImage->alt.argb32[idx];
5063 out->alt.argb32[idx2] =
fImage->alt.argb32[idx] & (~out->alt.argb32[idx2]);
5066 out->alt.argb32[idx2] &= ~fImage->alt.argb32[idx];
5071 out->alt.argb32[idx2] ^=
fImage->alt.argb32[idx];
5074 out->alt.argb32[idx2] |=
fImage->alt.argb32[idx];
5077 out->alt.argb32[idx2] = (~fImage->alt.argb32[idx]) & (~out->alt.argb32[idx2]);
5080 out->alt.argb32[idx2] ^= ~fImage->alt.argb32[idx];
5083 out->alt.argb32[idx2] = ~out->alt.argb32[idx2];
5086 out->alt.argb32[idx2] =
fImage->alt.argb32[idx] | (~out->alt.argb32[idx2]);
5089 out->alt.argb32[idx2] = ~fImage->alt.argb32[idx];
5092 out->alt.argb32[idx2] |= ~fImage->alt.argb32[idx];
5095 out->alt.argb32[idx2] = (~fImage->alt.argb32[idx]) | (~out->alt.argb32[idx2]);
5098 out->alt.argb32[idx2] = 0xFFFFFFFF;
5102 out->alt.argb32[idx2] =
fImage->alt.argb32[idx];
5126 int i, j, ix, iy, w,
h;
5128 ARGB32 color = 0xFFFFFFFF;
5135 for (i = 0; i < nx; i++) {
5137 for (j = 0; j < ny; j++) {
5138 icol = (ARGB32)ic[i + (nx*j)];
5139 if (icol != color) {
5193 return (ptMin - ptsStart);
5209 int mr = 0, m1r = 0;
5210 int incr1l = 0, incr2l = 0;
5211 int incr1r = 0, incr2r = 0;
5216 int nextleft, nextright;