Branch: Tag:

1999-09-05

1999-09-05 01:43:07 by Per Hedbor <ph@opera.com>

Can now be dumped to a .o file (some . changed to ->)

Rev: server/modules/graphics/graphic_text.pike:1.187

1: - constant cvs_version="$Id: graphic_text.pike,v 1.186 1999/08/09 15:09:44 nilsson Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.187 1999/09/05 01:43:07 per Exp $";   constant thread_safe=1;      #include <config.h>
69:    array res;    int i;    int j; -  res = Array.map(allocate(size), lambda(int s, int size){ -  return allocate(size); }, size); -  +  res = allocate(size)*size;    for(i=0; i<size; i++)    for(j=0; j<size; j++)    res[i][j] = (int)MAX((float)size/2.0-sqrt((size/2-i)*(size/2-i) + (size/2-j)*(size/2-j)),0);
110:    int h=in->ysize();    int w=in->xsize();    -  object corner = Image.image(width+1,width+1); -  object corner2 = Image.image(width+1,width+1); -  object pix = Image.image(1,1); +  object corner = Image.Image(width+1,width+1); +  object corner2 = Image.Image(width+1,width+1); +  object pix = Image.Image(1,1);       for(int i=-1; i<=width; i++) {    corner->line(i,width-i,i,-1, @white);
122:       if(!invert)    { -  in->paste_alpha(Image.image(width,h-width*2,@white), 160, 0, width); -  in->paste_alpha(Image.image(width,h-width*2,@black), 128, in->xsize()-width, width); -  in->paste_alpha(Image.image(w-width,width,@white), 160, 0, 0); -  in->paste_alpha(Image.image(w-width,width,@black), 128, width, in->ysize()-width); +  in->paste_alpha(Image.Image(width,h-width*2,@white), 160, 0, width); +  in->paste_alpha(Image.Image(width,h-width*2,@black), 128, in->xsize()-width, width); +  in->paste_alpha(Image.Image(w-width,width,@white), 160, 0, 0); +  in->paste_alpha(Image.Image(w-width,width,@black), 128, width, in->ysize()-width);    } else {    corner=corner->invert();    corner2=corner2->invert(); -  in->paste_alpha(Image.image(width,h-width*2,@black), 160, 0, width); -  in->paste_alpha(Image.image(width,h-width*2,@white), 128, in->xsize()-width, width); -  in->paste_alpha(Image.image(w-width,width,@black), 160, 0, 0); -  in->paste_alpha(Image.image(w-width,width,@white), 128, width, in->ysize()-width); +  in->paste_alpha(Image.Image(width,h-width*2,@black), 160, 0, width); +  in->paste_alpha(Image.Image(width,h-width*2,@white), 128, in->xsize()-width, width); +  in->paste_alpha(Image.Image(w-width,width,@black), 160, 0, 0); +  in->paste_alpha(Image.Image(w-width,width,@white), 128, width, in->ysize()-width);    }       in->paste_mask(corner, corner->color(95,95,95), in->xsize()-width,-1);
152:   object make_text_image(mapping args, object font, string text,object id)   {    // object text_alpha=font->write(@(text/"\n")); -  object text_alpha=font->write(@(args->encoding? -  (Locale.Charset.decoder(args->encoding)-> -  feed(text)->drain())/"\n" : -  text/"\n")); +  if( args->encoding ) +  text = roxen.decode_charset(args->encoding,text); +  object text_alpha=font->write(@(text/"\n"));    int xoffset=0, yoffset=0;       if(!text_alpha->xsize() || !text_alpha->ysize()) -  text_alpha = Image.image(10,10, 0,0,0); +  text_alpha = Image.Image(10,10, 0,0,0);      // perror("Making image of '%s', args=%O\n", text, args);   
261:    foreground = t;    if(args->tile)    { -  object b2 = Image.image(xsize,ysize); +  object b2 = Image.Image(xsize,ysize);    for(int x=0; x<xsize; x+=foreground->xsize())    for(int y=0; y<ysize; y+=foreground->ysize())    b2->paste(foreground, x, y);    foreground = b2;    } else if(args->mirrortile) { -  object b2 = Image.image(xsize,ysize); -  object b3 = Image.image(foreground->xsize()*2,foreground->ysize()*2); +  object b2 = Image.Image(xsize,ysize); +  object b3 = Image.Image(foreground->xsize()*2,foreground->ysize()*2);    b3->paste(foreground,0,0);    b3->paste(foreground->mirrorx(),foreground->xsize(),0);    b3->paste(foreground->mirrory(),0,foreground->ysize());
293:    if(args->background &&    ((background = roxen.load_image(args->background, id)) ||    (sizeof(args->background)>1 && -  (background=Image.image(xsize,ysize, @(parse_color(args->background[1..])))) +  (background=Image.Image(xsize,ysize, +  @(parse_color(args->background[1..]))))    && (background_is_color=1))))    {    object alpha;
303:    ysize=MAX(ysize,alpha->ysize());    if((float)args->scale)    alpha=alpha->scale(1/(float)args->scale); -  background=Image.image(xsize,ysize, @(parse_color(args->background[1..]))); +  background=Image.Image(xsize,ysize, @(parse_color(args->background[1..])));    }       if((float)args->scale >= 0.1 && !alpha)
311:       if(args->tile)    { -  object b2 = Image.image(xsize,ysize); +  object b2 = Image.Image(xsize,ysize);    for(int x=0; x<xsize; x+=background->xsize())    for(int y=0; y<ysize; y+=background->ysize())    b2->paste(background, x, y);    background = b2;    } else if(args->mirrortile) { -  object b2 = Image.image(xsize,ysize); -  object b3 = Image.image(background->xsize()*2,background->ysize()*2); +  object b2 = Image.Image(xsize,ysize); +  object b3 = Image.Image(background->xsize()*2,background->ysize()*2);    b3->paste(background,0,0);    b3->paste(background->mirrorx(),background->xsize(),0);    b3->paste(background->mirrory(),0,background->ysize());
353:    case "left":    }    } else -  background = Image.image(xsize, ysize, @bgcolor); +  background = Image.Image(xsize, ysize, @bgcolor);       if(args->border)    {
364:    {    // upper left -- upper right    background->line(b,b, xsize-b-1, b); -  +     // lower left -- lower right    background->line(b,ysize-b-1, xsize-b-1, ysize-b-1); -  +     // upper left -- lower left    background->line(b,b, b, ysize-b-1);    // upper right -- lower right
422:    alpha = (int)args->textbox;    sscanf(args->textbox, "%*[^,],%s", bg);    sscanf(bg,"%s,%d", bg,border); -  background->paste_alpha(Image.image(txsize+border*2,tysize+border*2, +  background->paste_alpha(Image.Image(txsize+border*2,tysize+border*2,    @parse_color(bg)),    255-(alpha*255/100),xoffset-border,yoffset-border);    }
467:    int xs,ys;    xs = text_alpha->xsize()+sdist*2+4;    ys = text_alpha->ysize()+sdist*2+4; -  object ta = Image.image(xs+sdist*2,ys+sdist*2); +  object ta = Image.Image(xs+sdist*2,ys+sdist*2);    array sc = parse_color(args->scolor||"black");       ta->paste_alpha_color(text_alpha,255,255,255,sdist,sdist);
493:    ->color(@fgcolor);       -  if(!foreground) foreground=Image.image(txsize, tysize, @fgcolor); +  if(!foreground) foreground=Image.Image(txsize, tysize, @fgcolor);    if(args->textscale)    {    string c1="black",c2="black",c3="black",c4="black";
658:    sscanf(args->fadein,"%d,%d,%d,%d", amount, steps, delay, initialdelay);    if(initialdelay)    { -  object foo=Image.image(img->xsize(),img->ysize(),@parse_color(args->bg)); +  object foo=Image.Image(img->xsize(),img->ysize(),@parse_color(args->bg));    res += foo->gif_add(0,0,initialdelay);    }    for(int i = 0; i<(steps-1); i++)
705:   {    if( strlen(f)>4 && query("gif") && f[-4]=='.') // Remove .ext    f = f[..strlen(f)-5]; -  if( strlen(f) && f[0..0]=="$" ) +  if( strlen(f) && f[0]=='$' )    {    array id_text = f/"/";    if( sizeof(id_text)==2 )    { // It's a gtext-id -  string second_key = roxen.argcache.store( (["":id_text[1]]) ); +  string second_key = roxen->argcache->store( (["":id_text[1]]) );    return image_cache->http_file_answer( id_text[0][1..] +"$"+ second_key, rid );    }    }
805:    if(arg->alpha)    arg->alpha = fix_relative(arg->alpha,id);    -  +     if(!short)    return query_internal_location()+image_cache->store( ({arg,ctn}), id )+    (query("gif")?".foo":"");
813:    return image_cache->store( ({arg,ctn}), id )+(query("gif")?".foo":"");   }    - string tag_gtext_id(string t, mapping arg, object id, object foo, -  mapping defines) + string tag_gtext_id(string t, mapping arg, object id, +  object foo, mapping defines)   {    int short=!!arg->short;    if(arg->help) return "Arguments are identical to the argumets to &lt;gtext&gt;. This tag returns a url-prefix that can be used to generate gtexts.";
875:    if(arg->alpha)    arg->alpha = fix_relative(arg->alpha,id);    -  +     string gif="";    if(query("gif")) gif="."+(arg->format?arg->format[..2]:"gif");