Roxen.git/
server/
base_server/
roxen.pike
Branch:
Tag:
Non-build tags
All tags
No tags
1999-11-02
1999-11-02 10:12:26 by Per Hedbor <ph@opera.com>
e9d7c50b50e537ad7aae2f56afda87fddc68075d (
35
lines) (+
25
/-
10
)
[
Show
|
Annotate
]
Branch:
5.2
Added support for 'background' attribute in image cache
Rev: server/base_server/roxen.pike:1.343
1:
/*
-
* $Id: roxen.pike,v 1.
342
1999/11/02
01
:
37
:
22
per Exp $
+
* $Id: roxen.pike,v 1.
343
1999/11/02
10
:
12
:
26
per Exp $
* * The Roxen Challenger main program. *
7:
*/ // ABS and suicide systems contributed freely by Francesco Chemolli
-
constant cvs_version="$Id: roxen.pike,v 1.
342
1999/11/02
01
:
37
:
22
per Exp $";
+
constant cvs_version="$Id: roxen.pike,v 1.
343
1999/11/02
10
:
12
:
26
per Exp $";
object backend_thread; object argcache;
1532:
string format = lower_case(args->format || "gif"); string dither = args->dither; Image.Colortable ct;
+
Image.Color.Color bgcolor;
object alpha; int true_alpha;
1556:
if( args["true-alpha"] ) true_alpha = 1;
+
if( args["background"] )
+
bgcolor = Image.Color( args["background"] );
+
if( args["opaque-value"] ) { true_alpha = 1;
1567:
if( alpha ) { object i = Image.image( reply->xsize(), reply->ysize(), ov,ov,ov );
-
i->paste_alpha( alpha, ov );
+
i
= i
->paste_alpha( alpha, ov );
alpha = i; } else
1612:
if( quant || (format=="gif") ) {
-
int ncols = quant||id->misc->defquant||
16
;
+
int ncols = quant||id->misc->defquant||
32
;
if( ncols > 250 ) ncols = 250; ct = Image.Colortable( reply, ncols );
1633:
if( alpha ) enc_args->alpha = alpha;
+
if( bgcolor && alpha )
+
{
+
reply = Image.Image( reply->xsize(),
+
reply->ysize(), bgcolor )
+
->paste_mask( reply, alpha );
+
}
+
foreach( glob( "*-*", indices(args)), string n ) if(sscanf(n, "%*[^-]-%s", string opt ) == 2) enc_args[opt] = (int)args[n];
1642:
case "gif": if( alpha && true_alpha ) {
-
object
ct
=Image.Colortable( ({ ({ 0,0,0 }), ({ 255,255,255 }) }) );
-
ct
->floyd_steinberg();
-
alpha =
ct
->map( alpha );
+
object
bw
=Image.Colortable( ({ ({ 0,0,0 }), ({ 255,255,255 }) }) );
+
bw
->floyd_steinberg();
+
alpha =
bw
->map( alpha );
} if( catch { if( alpha )
1654:
}) data = Image.GIF.encode( reply ); break;
+
case "png":
-
if( ct )
-
enc_args->palette = ct;
+
if( ct ) enc_args->palette = ct;
m_delete( enc_args, "colortable" );
-
+
if( !enc_args->alpha ) m_delete( enc_args, "alpha" );
+
default: data = Image[upper_case( format )]->encode( reply, enc_args ); }
-
meta = ([
+
meta =
+
([
"xsize":reply->xsize(), "ysize":reply->ysize(), "type":"image/"+format,