pike.git / lib / modules / _Image_PSD.pmod

version» Context lines:

pike.git/lib/modules/_Image_PSD.pmod:8:    object alpha;       int flags;    int xoffset, yoffset;    int width, height;       int mask_flags;    int mask_xoffset, mask_yoffset;    int mask_width, mask_height;    -  -  Layer copy() -  { -  Layer l = Layer(); -  l->mode = mode; -  l->opacity = opacity; -  l->image = image; -  l->alpha = alpha; -  l->flags = flags; -  l->xoffset = xoffset; -  l->yoffset = yoffset; -  l->width = width; -  l->height = height; -  return l; + // Layer copy() + // { + // Layer l = Layer(); + // l->mode = mode; + // l->opacity = opacity; + // l->image = image; + // l->alpha = alpha; + // l->flags = flags; + // l->xoffset = xoffset; + // l->yoffset = yoffset; + // l->width = width; + // l->height = height; + // return l; + // }   }    -  -  Layer get_opaqued( int opaque_value ) -  { -  Layer res = copy(); -  if(opaque_value != 255) -  { -  if(res->alpha) -  res->alpha *= opaque_value/255.0; -  else -  res->alpha = Image.image(width,height, -  opaque_value,opaque_value,opaque_value); -  } -  return res; -  } - } -  +    int foo;   Layer decode_layer(mapping layer, mapping i)   {   // int stt = gethrtime();    Layer l = Layer();    int use_cmap;    l->opacity = layer->opacity;    l->width = layer->right-layer->left;    l->height = layer->bottom-layer->top;    l->xoffset = layer->left;
pike.git/lib/modules/_Image_PSD.pmod:266:   }      array decode_layers( string|mapping what, mapping|void opts )   {       if(!opts) opts = ([]);       if(!mappingp( what ) )    what = __decode( what );    -  mapping lopts = ([ "tiled":1, ]); +  mapping lopts = ([ ]);       if( opts->background )    { -  +  lopts->tiled = 1;    lopts->image = Image.Image( 32, 32, opts->background ); -  lopts->alpha = Image.Image( 32, 32, Image.Color.white ); -  lopts->alpha_value = 1.0; + // lopts->alpha = Image.Image( 32, 32, Image.Color.white ); + // lopts->alpha_value = 1.0;    }       object img, alpha;    if( !what->layers || !sizeof(what->layers))    {    [ img, alpha ] = decode_background( what );    if( img )    {    lopts->image = img;    if( alpha )    lopts->alpha = alpha;    else    lopts->alpha = 0; -  lopts->alpha_value = 1.0; + // lopts->alpha_value = 1.0;    }    }    array layers;    if( lopts->image )    layers = ({ Image.Layer( lopts ) });    else    layers = ({});       foreach(reverse(what->layers), object l)    { -  if( string m = translate_mode( l->mode ) ) +  string m; +  if( (m = translate_mode( l->mode )) +  && l->opacity +  && l->image->xsize() +  && l->image->ysize() )    {    Image.Layer lay = Image.Layer( l->image, l->alpha, m );    l->image = 0; l->alpha = 0; -  + #if 0 +  // Dumps core in Pike 7.0 at least...    if( l->opacity != 255 )    lay->set_alpha_value( 1.0 - l->opacity / 255.0 ); -  + #else +  if( lay->alpha() ) +  lay->set_image( lay->image(), lay->alpha()->color(l->opacity, +  l->opacity, +  l->opacity ) ); +  else +  lay->set_image( lay->image(), +  lay->image()->clear(l->opacity, +  l->opacity, +  l->opacity) ); + #endif    lay->set_offset( l->xoffset, l->yoffset );    layers += ({ lay });    }    }    return layers;   }      mapping _decode( string|mapping what, mapping|void opts )   {   // mixed e = catch{    mapping data;    if(!opts) opts = ([]);    if(mappingp(what))    data = what;    else    data = __decode( what );    what=0;       Image.Layer res = Image.lay(decode_layers( data, opts ),    0,0,data->width,data->height ); -  Image.Image img = res->image(); -  Image.Image alpha = res->alpha(); -  +     return    ([ -  "image":img, -  "alpha":alpha, +  "image":res->image(), +  "alpha":res->alpha(),    ]);   // };   // werror(describe_backtrace(e));   }