pike.git / lib / modules / _Image_PSD.pmod

version» Context lines:

pike.git/lib/modules/_Image_PSD.pmod:14:    int width, height;       int mask_flags;    int mask_xoffset, mask_yoffset;    int mask_width, mask_height;   }      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:61:    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;       case Indexed:    use_cmap = 1;    break;    default: -  werror("Unsupported layer format mode (for now), using greyscale\n"); +  werror("Unsupported layer format mode ("+i->mode+"), 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:156:    @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 );
pike.git/lib/modules/_Image_PSD.pmod:224:       case "smud":    werror("WARNING: Unsupported mode (smudge). Skipping layer\n");    return 0;      // WARNING: PSD: Unsupported mode: sLit   // WARNING: PSD: Unsupported mode: hLit          default: -  werror("WARNING: PSD: Unsupported mode: "+mode+"\n"); -  werror("Skipping layer\n"); +  werror("WARNING: PSD: Unsupported mode: "+mode+". Skipping layer\n"); + // werror("Skipping layer\n");    return 0;    }   }      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 );
pike.git/lib/modules/_Image_PSD.pmod:262:    {    lopts->image = img;    if( alpha )    lopts->alpha = alpha;    else    lopts->alpha = 0;    lopts->alpha_value = 1.0;    }    }    array layers; +  Image.Layer lay;    if( lopts->image ) -  layers = ({ Image.Layer( lopts ) }); +  { +  layers = ({ (lay=Image.Layer( lopts )) }); +  lay->set_misc_value( "visible", 1 ); +  lay->set_misc_value( "name", "Background" ); +  lay->set_misc_value( "image_guides", what->resources->guides ); +  }    else    layers = ({});       foreach(reverse(what->layers), object l)    {    if( !(l->flags & LAYER_FLAG_INVISIBLE) || opts->draw_all_layers )    {    if( string m = translate_mode( l->mode ) )    { -  Image.Layer lay = Image.Layer( l->image, l->alpha, m ); +  lay = Image.Layer( l->image, l->alpha, m );       lay->set_misc_value( "visible", !(l->flags & LAYER_FLAG_INVISIBLE) );    lay->set_misc_value( "name", l->name ); -  +  lay->set_misc_value( "image_guides", what->resources->guides );       l->image = 0; l->alpha = 0;    if( l->opacity != 255 )    lay->set_alpha_value( 1.0 - l->opacity / 255.0 );    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,    ]); - // }; - // werror(describe_backtrace(e)); +    } -  +  + Image.Image decode( string|mapping what, mapping|void opts ) + { +  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 ); +  return res->image(); + }