00001
00002
00003
00004
00005
00006
00007
00008 #include <stdio.h>
00009 #include "../../basext.h"
00010
00011 #include "gd.h"
00012 #include "gdfontt.h"
00013 #include "gdfonts.h"
00014 #include "gdfontmb.h"
00015 #include "gdfontl.h"
00016 #include "gdfontg.h"
00017
00018 #define MAXBFONT 5
00019 #define DEFAULTBFONT 3
00020 #define DEFAULTPTSIZE 12.0
00021 #define ANGLE_UP 270
00022
00023 #define GD_ERROR_ARGUMENT 0x00080001
00024 #define GD_ERROR_FILE 0x00080002
00025 #define GD_ERROR_ERROR 0x00080003
00026 #define GD_ERROR_POLYAS 0x00080004
00027 #define GD_ERROR_POLYAS1 0x00080005
00028
00029
00030
00031 typedef struct _ImageList {
00032 struct _ImageList *prev,*next;
00033 gdImagePtr im;
00034 char *TTFfont;
00035 int BinFont;
00036 int color;
00037 int angle;
00038 double ptsize;
00039 } ImageList, *pImageList;
00040
00041 typedef struct _GdClass {
00042 pImageList pImages;
00043 } GdClass, *pGdClass;
00044
00045
00046
00047 #define InsertImage(x) __InsertImage(pSt,ppModuleInternal,(x))
00048 static pImageList __InsertImage(pSupportTable pSt,
00049 void **ppModuleInternal,
00050 gdImagePtr pImage){
00051 pGdClass p;
00052 pImageList q;
00053
00054 p = (pGdClass)besMODULEPOINTER;
00055
00056 q = besALLOC(sizeof(ImageList));
00057 if( q == NULL )return NULL;
00058
00059 q->next = p->pImages;
00060 q->prev = NULL;
00061 q->im = pImage;
00062 if( q->next )
00063 q->next->prev = q;
00064 p->pImages = q;
00065
00066 q->TTFfont = NULL;
00067 q->BinFont = DEFAULTBFONT;
00068 q->color = 0;
00069 q->angle = 0;
00070 q->ptsize = DEFAULTPTSIZE;
00071 return q;
00072 }
00073
00074
00075 #define RemoveImage(x) __RemoveImage(pSt,ppModuleInternal,(x))
00076 static void __RemoveImage(pSupportTable pSt,
00077 void **ppModuleInternal,
00078 pImageList q){
00079 pGdClass p;
00080
00081 p = (pGdClass)besMODULEPOINTER;
00082
00083 if( q->prev )
00084 q->prev->next = q->next;
00085 else
00086 p->pImages = q->next;
00087
00088 if( q->next )
00089 q->next->prev = q->prev;
00090
00091 besFREE(q);
00092 }
00093
00094 besVERSION_NEGOTIATE
00095
00096 return (int)INTERFACE_VERSION;
00097
00098 besEND
00099
00100 besSUB_START
00101 pGdClass p;
00102
00103 besMODULEPOINTER = besALLOC(sizeof(GdClass));
00104 if( besMODULEPOINTER == NULL )return 0;
00105 p = (pGdClass)besMODULEPOINTER;
00106 p->pImages = NULL;
00107
00108 besEND
00109
00110 besSUB_FINISH
00111 pGdClass p;
00112 pImageList q,k;
00113 p = (pGdClass)besMODULEPOINTER;
00114
00115 q = p->pImages;
00116 while( q ){
00117 gdImageDestroy(q->im);
00118 q = (k=q)->next;
00119 besFREE(k);
00120 }
00121
00122 besFREE(p);
00123 besEND
00124
00125
00126 #define GET_M_L_ARGUMENT(x,y) Argument = besARGUMENT(y);\
00127 besDEREFERENCE(Argument);\
00128 if( Argument == NULL )return COMMAND_ERROR_ARGUMENT_RANGE;\
00129 Argument = besCONVERT2LONG(Argument);\
00130 x = (int)LONGVALUE(Argument);
00131
00132 #define GET_COLOR_ARGUMENT(y) \
00133 if( besARGNR < y ){ color = p->color; }else{\
00134 Argument = besARGUMENT(y);\
00135 besDEREFERENCE(Argument);\
00136 if( Argument == NULL ) color = p->color; else{\
00137 Argument = besCONVERT2LONG(Argument);\
00138 color = (int)LONGVALUE(Argument);}}
00139
00140
00141 #define GET_M_P_ARGUMENT(x,y) Argument = besARGUMENT(y);\
00142 besDEREFERENCE(Argument);\
00143 if( Argument == NULL )return COMMAND_ERROR_ARGUMENT_RANGE;\
00144 if( TYPE(Argument) != VTYPE_STRING ||\
00145 STRLEN(Argument) != sizeof(x) )return COMMAND_ERROR_ARGUMENT_TYPE;\
00146 memcpy(&(x),STRINGVALUE(Argument),sizeof(x));
00147
00148
00149 besFUNCTION(gdicfpng)
00150 VARIABLE Argument;
00151 gdImagePtr pIm;
00152 pImageList p;
00153 char *pszFileName;
00154 int FileAccess;
00155 FILE *fp;
00156
00157 besRETURNVALUE = NULL;
00158
00159 if( besARGNR < 1 )return COMMAND_ERROR_FEW_ARGS;
00160
00161 Argument = besARGUMENT(1);
00162 besDEREFERENCE(Argument);
00163 if( Argument == NULL )return GD_ERROR_ARGUMENT;
00164 Argument = besCONVERT2STRING(Argument);
00165 besCONVERT2ZCHAR(Argument,pszFileName);
00166
00167 FileAccess = besHOOK_FILE_ACCESS(pszFileName);
00168 if( !(FileAccess&1) ){
00169 besFREE(pszFileName);
00170 return GD_ERROR_FILE;
00171 }
00172
00173 fp = fopen(pszFileName,"rb");
00174 besFREE(pszFileName);
00175 if( fp == NULL )return GD_ERROR_FILE;
00176 pIm = gdImageCreateFromPng(fp);
00177 fclose(fp);
00178
00179 if( pIm == NULL )return COMMAND_ERROR_MEMORY_LOW;
00180
00181 p = InsertImage(pIm);
00182
00183 if( p == NULL ){
00184 gdImageDestroy(pIm);
00185 return COMMAND_ERROR_MEMORY_LOW;
00186 }
00187 besALLOC_RETURN_STRING(sizeof(p));
00188 memcpy(STRINGVALUE(besRETURNVALUE),&p,sizeof(p));
00189 besEND
00190
00191 besFUNCTION(getxdime)
00192 VARIABLE Argument;
00193 pImageList p;
00194
00195 if( besARGNR < 1 )return COMMAND_ERROR_FEW_ARGS;
00196
00197 GET_M_P_ARGUMENT(p,1)
00198
00199 besALLOC_RETURN_LONG;
00200 LONGVALUE(besRETURNVALUE) = gdImageSX(p->im);
00201 besEND
00202
00203 besFUNCTION(getydime)
00204 VARIABLE Argument;
00205 pImageList p;
00206
00207 if( besARGNR < 1 )return COMMAND_ERROR_FEW_ARGS;
00208
00209 GET_M_P_ARGUMENT(p,1)
00210
00211 besALLOC_RETURN_LONG;
00212 LONGVALUE(besRETURNVALUE) = gdImageSY(p->im);
00213 besEND
00214
00215
00216 besFUNCTION(gdic)
00217 VARIABLE Argument;
00218 int sx,sy;
00219 gdImagePtr pIm;
00220 pImageList p;
00221
00222 besRETURNVALUE = NULL;
00223
00224 if( besARGNR < 2 )return COMMAND_ERROR_FEW_ARGS;
00225
00226 GET_M_L_ARGUMENT(sx,1)
00227 GET_M_L_ARGUMENT(sy,2)
00228
00229 pIm = gdImageCreate(sx,sy);
00230 if( pIm == NULL )return COMMAND_ERROR_MEMORY_LOW;
00231
00232 p = InsertImage(pIm);
00233
00234 if( p == NULL ){
00235 gdImageDestroy(pIm);
00236 return COMMAND_ERROR_MEMORY_LOW;
00237 }
00238 besALLOC_RETURN_STRING(sizeof(p));
00239 memcpy(STRINGVALUE(besRETURNVALUE),&p,sizeof(p));
00240 besEND
00241
00242
00243 besFUNCTION(imdestr)
00244 VARIABLE Argument;
00245 pImageList p;
00246
00247 if( besARGNR < 1 )return COMMAND_ERROR_FEW_ARGS;
00248
00249 GET_M_P_ARGUMENT(p,1)
00250
00251 gdImageDestroy(p->im);
00252 RemoveImage(p);
00253
00254 besEND
00255
00256
00257 besFUNCTION(gdac)
00258 VARIABLE Argument;
00259 int r,g,b,color;
00260 pImageList p;
00261
00262 besRETURNVALUE = NULL;
00263
00264 if( besARGNR < 4 )return COMMAND_ERROR_FEW_ARGS;
00265
00266 GET_M_P_ARGUMENT(p,1)
00267 GET_M_L_ARGUMENT(r,2)
00268 GET_M_L_ARGUMENT(g,3)
00269 GET_M_L_ARGUMENT(b,4)
00270
00271 color = gdImageColorAllocate(p->im,r,g,b);
00272
00273 besALLOC_RETURN_LONG;
00274 LONGVALUE(besRETURNVALUE) = (long)color;
00275 besEND
00276
00277
00278 besFUNCTION(gdline)
00279 VARIABLE Argument;
00280 int xs,ys,xe,ye,color;
00281 pImageList p;
00282
00283 besRETURNVALUE = NULL;
00284
00285
00286 if( besARGNR < 5 )return COMMAND_ERROR_FEW_ARGS;
00287
00288 GET_M_P_ARGUMENT(p,1)
00289 GET_M_L_ARGUMENT(xs,2)
00290 GET_M_L_ARGUMENT(ys,3)
00291 GET_M_L_ARGUMENT(xe,4)
00292 GET_M_L_ARGUMENT(ye,5)
00293
00294 if( besARGNR == 5 ){
00295 color = p->color;
00296 }else{
00297 Argument = besARGUMENT(6);
00298 besDEREFERENCE(Argument);
00299 if( Argument == NULL )
00300 color = gdStyled;
00301 else{
00302 Argument = besCONVERT2LONG(Argument);
00303 color = (int)LONGVALUE(Argument);
00304 }
00305 }
00306 gdImageLine(p->im,xs,ys,xe,ye,color);
00307 besEND
00308
00309
00310
00311
00312 besFUNCTION(gdrect)
00313 VARIABLE Argument;
00314 int xs,ys,xe,ye,color;
00315 pImageList p;
00316 long fill;
00317
00318 besRETURNVALUE = NULL;
00319
00320 if( besARGNR < 7 )return COMMAND_ERROR_FEW_ARGS;
00321
00322 GET_M_P_ARGUMENT(p,1)
00323 GET_M_L_ARGUMENT(xs,2)
00324 GET_M_L_ARGUMENT(ys,3)
00325 GET_M_L_ARGUMENT(xe,4)
00326 GET_M_L_ARGUMENT(ye,5)
00327 GET_COLOR_ARGUMENT(6)
00328 GET_M_L_ARGUMENT(fill,7)
00329
00330 if( fill )
00331 gdImageFilledRectangle(p->im,xs,ys,xe,ye,color);
00332 else
00333 gdImageRectangle(p->im,xs,ys,xe,ye,color);
00334 besEND
00335
00336 besFUNCTION(impng)
00337 VARIABLE Argument;
00338 pImageList p;
00339 FILE *fp;
00340 char *pszFileName;
00341 int FileAccess;
00342
00343 if( besARGNR < 2 )return COMMAND_ERROR_FEW_ARGS;
00344
00345 GET_M_P_ARGUMENT(p,1)
00346
00347 Argument = besARGUMENT(2);
00348 besDEREFERENCE(Argument);
00349 if( Argument == NULL )return GD_ERROR_ARGUMENT;
00350 Argument = besCONVERT2STRING(Argument);
00351 besCONVERT2ZCHAR(Argument,pszFileName);
00352 FileAccess = besHOOK_FILE_ACCESS(pszFileName);
00353 if( !(FileAccess&2) ){
00354 besFREE(pszFileName);
00355 return GD_ERROR_FILE;
00356 }
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367 fp = fopen(pszFileName,"wb");
00368 besFREE(pszFileName);
00369 if( fp == NULL )return GD_ERROR_FILE;
00370 gdImagePng(p->im,fp);
00371 fclose(fp);
00372 besEND
00373
00374
00375 besFUNCTION(impngstr)
00376 VARIABLE Argument;
00377 int size;
00378 void *q;
00379 pImageList p;
00380
00381 besRETURNVALUE = NULL;
00382
00383 if( besARGNR < 1 )return COMMAND_ERROR_FEW_ARGS;
00384
00385 GET_M_P_ARGUMENT(p,1)
00386 q = gdImagePngPtr(p->im,&size);
00387 if( size <= 0 )return GD_ERROR_ERROR;
00388 besALLOC_RETURN_STRING((long)size);
00389 memcpy(STRINGVALUE(besRETURNVALUE),q,size);
00390 free(q);
00391 besEND
00392
00393
00394 besFUNCTION(gdpix)
00395 VARIABLE Argument;
00396 int x,y,color;
00397 pImageList p;
00398
00399 besRETURNVALUE = NULL;
00400
00401 if( besARGNR < 3 )return COMMAND_ERROR_FEW_ARGS;
00402
00403 GET_M_P_ARGUMENT(p,1)
00404 GET_M_L_ARGUMENT(x,2)
00405 GET_M_L_ARGUMENT(y,3)
00406 GET_COLOR_ARGUMENT(4)
00407
00408 gdImageSetPixel(p->im,x,y,color);
00409 besEND
00410
00411
00412
00413
00414
00415
00416 besFUNCTION(gdpoly)
00417 VARIABLE Argument;
00418 VARIABLE vX,vY;
00419 VARIABLE V;
00420 int ArraySize,color;
00421 long i,j;
00422 pImageList p;
00423 gdPoint *point;
00424 long fill;
00425
00426 besRETURNVALUE = NULL;
00427
00428 if( besARGNR < 5 )return COMMAND_ERROR_FEW_ARGS;
00429
00430 GET_M_P_ARGUMENT(p,1)
00431
00432 vX = besARGUMENT(2);
00433 besDEREFERENCE(vX);
00434 if( TYPE(vX) != VTYPE_ARRAY )return COMMAND_ERROR_ARGUMENT_TYPE;
00435 ArraySize = ARRAYHIGH(vX) - ARRAYLOW(vX) +1;
00436
00437 vY = besARGUMENT(3);
00438 besDEREFERENCE(vY);
00439 if( TYPE(vY) != VTYPE_ARRAY )return COMMAND_ERROR_ARGUMENT_TYPE;
00440 if( ArraySize != ARRAYHIGH(vY) - ARRAYLOW(vY) +1 )
00441 return GD_ERROR_POLYAS;
00442
00443 if( ARRAYLOW(vX) != ARRAYLOW(vY) )return GD_ERROR_POLYAS1;
00444
00445 point = besALLOC(ArraySize*sizeof(gdPoint));
00446 if( point == NULL )return COMMAND_ERROR_MEMORY_LOW;
00447
00448 for( i=0 , j = ARRAYLOW(vX) ; i < ArraySize ; i++ , j++ ){
00449 V = ARRAYVALUE(vX,j);
00450 if( V == NULL ){
00451 besFREE(point);
00452 return COMMAND_ERROR_ARGUMENT_TYPE;
00453 }
00454 point[i].x = LONGVALUE(besCONVERT2LONG(V));
00455 V = ARRAYVALUE(vY,j);
00456 if( V == NULL ){
00457 besFREE(point);
00458 return COMMAND_ERROR_ARGUMENT_TYPE;
00459 }
00460 point[i].y = LONGVALUE(besCONVERT2LONG(V));
00461 }
00462
00463 GET_COLOR_ARGUMENT(4)
00464 GET_M_L_ARGUMENT(fill,5)
00465
00466 if( fill )
00467 gdImageFilledPolygon(p->im,point,ArraySize,color);
00468 else
00469 gdImagePolygon(p->im,point,ArraySize,color);
00470 besFREE(point);
00471 besEND
00472
00473
00474
00475
00476 besFUNCTION(gdarc)
00477 VARIABLE Argument;
00478 long cx,cy,w,h,s,e,color;
00479 pImageList p;
00480
00481 besRETURNVALUE = NULL;
00482
00483 if( besARGNR < 7 )return COMMAND_ERROR_FEW_ARGS;
00484
00485 GET_M_P_ARGUMENT(p,1)
00486 GET_M_L_ARGUMENT(cx,2)
00487 GET_M_L_ARGUMENT(cy,3)
00488 GET_M_L_ARGUMENT(w,4)
00489 GET_M_L_ARGUMENT(h,5)
00490 GET_M_L_ARGUMENT(s,6)
00491 GET_M_L_ARGUMENT(e,7)
00492 GET_COLOR_ARGUMENT(8)
00493
00494 gdImageArc(p->im, (int) cx, (int) cy, (int) w, (int) h, (int) s, (int) e, (int) color);
00495
00496 besEND
00497
00498
00499
00500
00501 besFUNCTION(gdfilltb)
00502 VARIABLE Argument;
00503 long x,y,border,color;
00504 pImageList p;
00505
00506 besRETURNVALUE = NULL;
00507
00508 if( besARGNR < 4 )return COMMAND_ERROR_FEW_ARGS;
00509
00510 GET_M_P_ARGUMENT(p,1)
00511 GET_M_L_ARGUMENT(x,2)
00512 GET_M_L_ARGUMENT(y,3)
00513 GET_M_L_ARGUMENT(border,4)
00514 GET_COLOR_ARGUMENT(5)
00515
00516 gdImageFillToBorder(p->im, (int) x, (int) y, (int) border, (int) color);
00517
00518 besEND
00519
00520
00521
00522
00523 besFUNCTION(gdfill)
00524 VARIABLE Argument;
00525 long x,y,color;
00526 pImageList p;
00527
00528 besRETURNVALUE = NULL;
00529
00530 if( besARGNR < 3 )return COMMAND_ERROR_FEW_ARGS;
00531
00532 GET_M_P_ARGUMENT(p,1)
00533 GET_M_L_ARGUMENT(x,2)
00534 GET_M_L_ARGUMENT(y,3)
00535 GET_COLOR_ARGUMENT(4)
00536
00537 gdImageFill(p->im, (int) x, (int) y, (int) color);
00538
00539 besEND
00540
00541
00542
00543
00544 besFUNCTION(gdstbrus)
00545 VARIABLE Argument;
00546 pImageList p,q;
00547
00548 besRETURNVALUE = NULL;
00549
00550 if( besARGNR < 2 )return COMMAND_ERROR_FEW_ARGS;
00551
00552 GET_M_P_ARGUMENT(p,1)
00553 GET_M_P_ARGUMENT(q,2)
00554 if( p == q )return COMMAND_ERROR_ARGUMENT_RANGE;
00555
00556 gdImageSetBrush(p->im, q->im );
00557
00558 besEND
00559
00560
00561
00562
00563 besFUNCTION(gdstile)
00564 VARIABLE Argument;
00565 pImageList p,q;
00566
00567 besRETURNVALUE = NULL;
00568
00569 if( besARGNR < 2 )return COMMAND_ERROR_FEW_ARGS;
00570
00571 GET_M_P_ARGUMENT(p,1)
00572 GET_M_P_ARGUMENT(q,2)
00573
00574 gdImageSetTile(p->im, q->im );
00575
00576 besEND
00577
00578
00579
00580
00581 besFUNCTION(gdsstyle)
00582 VARIABLE Argument;
00583 VARIABLE vSTYLE,V;
00584 int ArraySize;
00585 long i,j;
00586 pImageList p;
00587 int *style;
00588
00589 besRETURNVALUE = NULL;
00590
00591 if( besARGNR < 2 )return COMMAND_ERROR_FEW_ARGS;
00592
00593 GET_M_P_ARGUMENT(p,1)
00594
00595 vSTYLE = besARGUMENT(2);
00596 besDEREFERENCE(vSTYLE);
00597 if( TYPE(vSTYLE) != VTYPE_ARRAY )return COMMAND_ERROR_ARGUMENT_TYPE;
00598 ArraySize = ARRAYHIGH(vSTYLE) - ARRAYLOW(vSTYLE) +1;
00599
00600 style = besALLOC(ArraySize*sizeof(int));
00601 if( style == NULL )return COMMAND_ERROR_MEMORY_LOW;
00602
00603 for( i=0 , j = ARRAYLOW(vSTYLE) ; i < ArraySize ; i++ , j++ ){
00604 V = ARRAYVALUE(vSTYLE,j);
00605 if( V == NULL )
00606 style[i] = gdTransparent;
00607 else
00608 style[i] = (int)LONGVALUE(besCONVERT2LONG(V));
00609 }
00610 gdImageSetStyle(p->im,style,ArraySize);
00611 besFREE(style);
00612 besEND
00613
00614
00615
00616
00617
00618 besFUNCTION(gdgetc)
00619 VARIABLE Argument;
00620 long color,component;
00621 pImageList p;
00622
00623 besRETURNVALUE = NULL;
00624
00625 if( besARGNR < 3 )return COMMAND_ERROR_FEW_ARGS;
00626
00627 GET_M_P_ARGUMENT(p,1)
00628 GET_M_L_ARGUMENT(color,2)
00629 GET_M_L_ARGUMENT(component,3);
00630
00631 switch( component ){
00632 default: return COMMAND_ERROR_ARGUMENT_RANGE;
00633 case 1: color = gdImageRed(p->im,color);
00634 break;
00635 case 2: color = gdImageGreen(p->im,color);
00636 break;
00637 case 4: color = gdImageBlue(p->im,color);
00638 break;
00639 }
00640
00641 besALLOC_RETURN_LONG;
00642 LONGVALUE(besRETURNVALUE) = color;
00643
00644 besEND
00645
00646
00647
00648
00649 besFUNCTION(gdbons)
00650 VARIABLE Argument;
00651 long x,y;
00652 pImageList p;
00653
00654 besRETURNVALUE = NULL;
00655
00656 if( besARGNR < 3 )return COMMAND_ERROR_FEW_ARGS;
00657
00658 GET_M_P_ARGUMENT(p,1)
00659 GET_M_L_ARGUMENT(x,2)
00660 GET_M_L_ARGUMENT(y,3);
00661
00662 besALLOC_RETURN_LONG;
00663 LONGVALUE(besRETURNVALUE) = gdImageBoundsSafe(p->im,(int)x,(int)y);
00664
00665 besEND
00666
00667
00668 besFUNCTION(gdcolor)
00669 VARIABLE Argument;
00670 long color;
00671 pImageList p;
00672
00673 besRETURNVALUE = NULL;
00674
00675 if( besARGNR < 2 )return COMMAND_ERROR_FEW_ARGS;
00676
00677 GET_M_P_ARGUMENT(p,1)
00678 GET_M_L_ARGUMENT(color,2)
00679
00680 p->color = color;
00681 besEND
00682
00683
00684
00685 besFUNCTION(gdfont)
00686 VARIABLE Argument;
00687 pImageList p;
00688 char *s;
00689 long slen;
00690 int IsTTF;
00691
00692 besRETURNVALUE = NULL;
00693
00694 if( besARGNR < 2 )return COMMAND_ERROR_FEW_ARGS;
00695
00696 GET_M_P_ARGUMENT(p,1)
00697
00698 if( p->TTFfont )besFREE(p->TTFfont);
00699 p->TTFfont = NULL;
00700 p->BinFont = DEFAULTBFONT;
00701 p->angle = 0;
00702 p->ptsize = DEFAULTPTSIZE;
00703
00704 Argument = besARGUMENT(2);
00705 besDEREFERENCE(Argument);
00706 if( Argument ){
00707 if( IsTTF=(TYPE(Argument) == VTYPE_STRING) ){
00708
00709 slen = STRLEN(Argument);
00710 s = STRINGVALUE(Argument);
00711 while( slen --)if( *s++ == (char)0 )return COMMAND_ERROR_ARGUMENT_RANGE;
00712 besCONVERT2ZCHAR(Argument,p->TTFfont);
00713 }else{
00714 Argument = besCONVERT2LONG(Argument);
00715 p->BinFont = LONGVALUE(Argument);
00716 if( p->BinFont < 1 || p->BinFont > MAXBFONT )p->BinFont = DEFAULTBFONT;
00717 }
00718 }
00719
00720 if( besARGNR < 3 )return COMMAND_ERROR_SUCCESS;
00721 Argument = besARGUMENT(3);
00722 besDEREFERENCE(Argument);
00723 if( Argument != NULL ){
00724 Argument = besCONVERT2LONG(Argument);
00725 p->angle = LONGVALUE(Argument);
00726 if( ! IsTTF ){
00727 if( p->angle != 0 && p->angle != ANGLE_UP ){
00728 p->angle = 0;
00729 return COMMAND_ERROR_ARGUMENT_RANGE;
00730 }
00731 }
00732 }
00733
00734 if( ! IsTTF || besARGNR < 4 )return COMMAND_ERROR_SUCCESS;
00735 Argument = besARGUMENT(4);
00736 besDEREFERENCE(Argument);
00737 if( Argument == NULL )return COMMAND_ERROR_SUCCESS;
00738 Argument = besCONVERT2DOUBLE(Argument);
00739 p->ptsize = DOUBLEVALUE(Argument);
00740
00741 besEND
00742
00743
00744
00745
00746
00747
00748
00749 besFUNCTION(gdprint)
00750 VARIABLE Argument;
00751 VARIABLE *pV;
00752 long x,y;
00753 pImageList p;
00754 int argI;
00755 char *s,*r;
00756 gdFontPtr font;
00757 int brect[8];
00758 unsigned long slen;
00759
00760 besRETURNVALUE = NULL;
00761
00762 if( besARGNR < 3 )return COMMAND_ERROR_FEW_ARGS;
00763
00764 GET_M_P_ARGUMENT(p,1)
00765 GET_M_L_ARGUMENT(x,2)
00766 GET_M_L_ARGUMENT(y,3);
00767
00768 pV = besALLOC((besARGNR-3)*sizeof(VARIABLE));
00769 if( pV == NULL )return COMMAND_ERROR_MEMORY_LOW;
00770 pV -= 4;
00771 for( slen = 0, argI = 4 ; argI <= besARGNR ; argI++ ){
00772 Argument = besARGUMENT(argI);
00773 besDEREFERENCE(Argument);
00774 pV[argI] = besCONVERT2STRING(Argument);
00775 slen += STRLEN(pV[argI]);
00776 }
00777 s = besALLOC(slen+1);
00778 if( s == NULL ){
00779 pV += 4;
00780 besFREE(pV);
00781 return COMMAND_ERROR_MEMORY_LOW;
00782 }
00783 for( r = s , argI = 4 ; argI <= besARGNR ; argI++ ){
00784 for( slen = 0 ; STRINGVALUE(pV[argI])[slen] && slen < STRLEN(pV[argI]) ; slen++ )
00785 *r++ = STRINGVALUE(pV[argI])[slen];
00786 }
00787 *r = (char)0;
00788 pV += 4;
00789 besFREE(pV);
00790
00791 if( p->TTFfont ){
00792 r = gdImageStringTTF(p->im, brect, p->color, p->TTFfont, p->ptsize,
00793 (double)p->angle, (int) x, (int) y, s) ;
00794 if( r ){
00795 besFREE(s);
00796 return GD_ERROR_ERROR;
00797 }
00798 }else{
00799 font = gdFontMediumBold;
00800 switch( p->BinFont ){
00801 case 1: font = gdFontTiny; break;
00802 case 2: font = gdFontSmall; break;
00803 case 3: font = gdFontMediumBold; break;
00804 case 4: font = gdFontLarge; break;
00805 case 5: font = gdFontGiant; break;
00806 }
00807 if( p->angle == ANGLE_UP )
00808 gdImageStringUp(p->im,font, (int) x, (int) y, s, p->color);
00809 else
00810 gdImageString(p->im,font, (int) x, (int) y, s, p->color);
00811 }
00812 besFREE(s);
00813
00814 besEND
00815
00816
00817
00818
00819 besFUNCTION(gdtrnspa)
00820 VARIABLE Argument;
00821 long c;
00822 pImageList p;
00823
00824 besRETURNVALUE = NULL;
00825
00826 if( besARGNR < 2 )return COMMAND_ERROR_FEW_ARGS;
00827
00828 GET_M_P_ARGUMENT(p,1)
00829 GET_M_L_ARGUMENT(c,2)
00830
00831 gdImageColorTransparent(p->im,(int)c);
00832 besEND