Branch: Tag:

2000-11-16

2000-11-16 18:26:29 by Per Hedbor <ph@opera.com>

Decode layer names and visibility for Photoshop images

Rev: lib/modules/_Image_PSD.pmod:1.11
Rev: lib/modules/_Image_XCF.pmod:1.16
Rev: src/modules/Image/encodings/psd.c:1.23
Rev: src/modules/Image/encodings/psd_constant_strings.h:1.3

4:      class Layer   { -  string mode; +  string mode, name;    int opacity;    object image;    object alpha;
16:    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 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(); +  int stt = gethrtime();    Layer l = Layer();    int use_cmap;    l->opacity = layer->opacity;
63:    l->image = Image.image( l->width, l->height );    l->mode = layer->mode;    l->flags = layer->flags; +  l->name = layer->name;       l->mask_width = layer->mask_right-layer->mask_left;    l->mask_height = layer->mask_bottom-layer->mask_top;
98:    }    if( mode )    { - // int st = gethrtime(); +  int st = gethrtime();    if( !sizeof(lays) )    lays += ({ -  Image.Layer(___decode_image_channel(l->width, l->height, +  Image.Layer(___decode_image_channel(l->width, +  l->height,    c->data))    });    else
111:    "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,}),
140:    })*24;    break;    } - // int st = gethrtime(); +  int st = gethrtime();    foreach(layer->channels, mapping c)    {    object tmp;
193:    }    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;   }   
306:       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->set_misc_value( "visible", !(l->flags & LAYER_FLAG_INVISIBLE) ); +  lay->set_misc_value( "name", l->name ); +     l->image = 0; l->alpha = 0;    if( l->opacity != 255 )    lay->set_alpha_value( 1.0 - l->opacity / 255.0 );
316:    layers += ({ lay });    }    } +  }    return layers;   }