pike.git / lib / modules / _Image_PSD.pmod

version» Context lines:

pike.git/lib/modules/_Image_PSD.pmod:43:    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(); + // 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;    l->yoffset = layer->top;    l->image = Image.image( l->width, l->height );    l->mode = layer->mode;    l->flags = layer->flags;
pike.git/lib/modules/_Image_PSD.pmod:89:    break;    case 1:    mode = "green";    break;    case 2:    mode = "blue";    break;    }    if( mode )    { -  int st = gethrtime(); + // int st = gethrtime();    if( !sizeof(lays) )    lays += ({    Image.Layer(___decode_image_channel(l->width, l->height,    c->data))    });    else    lays += (({ Image.Layer( ([    "image":___decode_image_channel(l->width, l->height, c->data),    "alpha_value":1.0,    "mode":mode,    ]) )    })); -  werror(mode+" took %4.5f seconds\n", (gethrtime()-st)/1000000.0 ); + // werror(mode+" took %4.5f seconds\n", (gethrtime()-st)/1000000.0 );    c->data = 0;    }    } -  int st = gethrtime(); + // int st = gethrtime();    l->image = Image.lay( lays )->image(); -  werror("combine took %4.5f seconds\n", (gethrtime()-st)/1000000.0 ); + // werror("combine took %4.5f seconds\n", (gethrtime()-st)/1000000.0 );    break;       case CMYK:    inverted = 1;    colors = ({ ({255,0,0,}),    ({0,255,0,}),    ({0,0,255,}),    }) + ({ 255,255,255 }) * 24;    l->image = Image.image( l->width, l->height, 255, 255, 255);    break;
pike.git/lib/modules/_Image_PSD.pmod:131:    use_cmap = 1;    break;    default:    werror("Unsupported layer format mode (for now), using greyscale\n");    case Greyscale:    colors = ({    255,255,255    })*24;    break;    } -  int st = gethrtime(); + // int st = gethrtime();    foreach(layer->channels, mapping c)    {    object tmp;       if( !colors && (c->id >= 0 ))    continue;       if( c->id != -2)    tmp = ___decode_image_channel(l->width, l->height, c->data);    else
pike.git/lib/modules/_Image_PSD.pmod:184:    @pad_color);    if(!l->alpha)    l->alpha = tmp;    else    l->alpha *= tmp;    break;    }    }    c->data = 0;    } -  werror("alpha/mask took %4.5f seconds\n", (gethrtime()-st)/1000000.0 ); -  werror("TOTAL took %4.5f seconds\n\n", (gethrtime()-stt)/1000000.0 ); + // werror("alpha/mask took %4.5f seconds\n", (gethrtime()-st)/1000000.0 ); + // werror("TOTAL took %4.5f seconds\n\n", (gethrtime()-stt)/1000000.0 );    return l;   }      mapping __decode( mapping|string what, mapping|void options )   {    mapping data;    if(mappingp(what))    data = what;    else    data = ___decode( what );    what=0;    array rl = ({});    foreach( data->layers, mapping l )    rl += ({ decode_layer( l, data ) });       data->layers = rl;    return data;   }       - array(object) decode_background( mapping data, array bg ) + array(object) decode_background( mapping data )   {    object img; -  +  if( data->depth == 1 && +  data->mode != Greyscale ) +  return ({ 0, 0 }); +     if( data->image_data )    img = ___decode_image_data(data->width, data->height,    data->channels, data->mode,    data->compression, data->image_data, -  +     data->color_data);    return ({ img, 0 });   }      string translate_mode( string mode )   {    switch( mode )    {    case "norm": return "normal";    case "mul ": return "multiply";
pike.git/lib/modules/_Image_PSD.pmod:265:      array decode_layers( string|mapping what, mapping|void opts )   {       if(!opts) opts = ([]);       if(!mappingp( what ) )    what = __decode( what );       mapping lopts = ([ "tiled":1, ]); +     if( opts->background )    {    lopts->image = Image.Image( 32, 32, opts->background );    lopts->alpha = Image.Image( 32, 32, Image.Color.white );    lopts->alpha_value = 1.0; -  } else { -  lopts->image = Image.Image( 32, 32, Image.Color.black ); -  lopts->alpha = Image.Image( 32, 32, Image.Color.black ); -  lopts->alpha_value = 0.0; +     }    -  [object img,object alpha] = decode_background( what, opts->background ); +  [object img,object alpha] = decode_background( what );    if( img )    {    lopts->image = img;    if( alpha )    lopts->alpha = alpha;    else    lopts->alpha = 0;    lopts->alpha_value = 1.0;    } -  array layers = ({ Image.Layer( lopts ) }); +  array layers; +  if( lopts->image ) +  layers = ({ Image.Layer( lopts ) }); +  else +  layers = ({});       foreach(reverse(what->layers), object l)    {    if( string m = translate_mode( l->mode ) )    { -  Image.Layer lay = Image.Layer( l->image, -  l->alpha, -  m ); +  Image.Layer lay = Image.Layer( l->image, l->alpha, m );    l->image = 0; l->alpha = 0;    lay->set_alpha_value( l->opacity / 255.0 );    lay->set_offset( l->xoffset, l->yoffset );    layers += ({ lay });    }    }    return layers;   }      mapping _decode( string|mapping what, mapping|void opts )