pike.git / lib / modules / _Image_PSD.pmod

version» Context lines:

pike.git/lib/modules/_Image_PSD.pmod:148:    break;    case -1: /* alpha */    if(!l->alpha)    l->alpha = tmp;    else    l->alpha *= tmp;    break;    case -2: /* user mask */    if(!(l->mask_flags & 2 )) /* layer mask disabled */    { -  array pad_color = ({255,255,255}); -  if( (l->mask_flags & 4 ) ) /* invert mask */ +  array pad_color = ({ 0, 0, 0 }); +  if( (l->mask_flags & 4 ) ) { +  /* invert mask */    tmp = tmp->invert(); -  +  pad_color = ({ 255, 255, 255 }); +  }       tmp = tmp->copy( -l->mask_xoffset, -l->mask_yoffset,    l->image->xsize()-1, l->image->ysize()-1,    @pad_color )    ->copy(0,0,l->image->xsize()-1,l->image->ysize()-1,    @pad_color);    if(!l->alpha)    l->alpha = tmp;    else    l->alpha *= tmp;
pike.git/lib/modules/_Image_PSD.pmod:255:    werror("WARNING: PSD: Unsupported mode: "+mode+". Skipping layer\n");    return 0;    }   }      //! @decl array(Image.Layer) decode_layers( string data, mapping|void options )   //!   //! Decodes a PSD image to an array of Image.Layer objects   //!   //! Takes the same aptions mapping as @[_decode], note especially - //! "draw_all_layers":1. + //! "draw_all_layers":1, but implements "crop_to_bounds" which preserves + //! the bounding box for the whole image (i.e. discards data that extend + //! outside of the global bounds).   //!   //! The layer object have the following extra variables (to be queried   //! using @[Image.Layer()->get_misc_value]):   //!   //! @string   //! @value "image_guides"   //! Returns array containing guide definitions.   //! @value "name"   //! Returns string containing the name of the layer.   //! @value "visible"
pike.git/lib/modules/_Image_PSD.pmod:340:    float lo = l->opacity / 255.0;    if( lay->alpha() )    lay->set_image( lay->image(), lay->alpha()*lo );    else    lay->set_image( lay->image(), Image.Image( lay->xsize(),    lay->yszize(),    (int)(255*lo),    (int)(255*lo),    (int)(255*lo)));    } +  +  if (opts->crop_to_bounds) { +  // Crop/expand this layer so it matches the image bounds. +  // This will lose data which extends beyond the image bounds +  // but keeps the image dimensions consistent. +  int x0 = -l->xoffset, y0 = -l->yoffset; +  int x1 = x0 + what->width - 1, y1 = y0 + what->height - 1; +  Image.Image new_img = +  lay->image()->copy(x0, y0, x1, y1); +  Image.Image new_alpha = +  lay->alpha() && +  lay->alpha()->copy(x0, y0, x1, y1); +  lay->set_image(new_img, new_alpha); +  } else    lay->set_offset( l->xoffset, l->yoffset ); -  +     layers += ({ lay });    }    }    }   // werror("%O\n", layers );    layers->set_misc_value( "size", ({ what->width, what->height }) );    return layers;   }      //! @decl mapping _decode(string|mapping data, mapping|void options)