pike.git / src / modules / Image / encodings / xcf.c

version» Context lines:

pike.git/src/modules/Image/encodings/xcf.c:1:   #include "global.h" - RCSID("$Id: xcf.c,v 1.3 1999/04/11 07:21:23 per Exp $"); + RCSID("$Id: xcf.c,v 1.4 1999/04/12 01:53:42 per Exp $");      #include "config.h"      #include "pike_macros.h"   #include "object.h"   #include "constants.h"   #include "module_support.h"   #include "interpret.h"   #include "object.h"   #include "svalue.h"
pike.git/src/modules/Image/encodings/xcf.c:26:      extern struct program *image_colortable_program;   extern struct program *image_program;      /*   **! module Image   **! submodule XCF   **!   */    + #define TILE_WIDTH 64 + #define TILE_HEIGHT 64 +  + #define MIN(X,Y) ((X)<(Y)?(X):(Y))   #define STRING(X) static struct pike_string *s_##X;   #include "xcf_constant_strings.h"   #undef STRING         struct buffer   {    unsigned int len;    unsigned char *str;   };
pike.git/src/modules/Image/encodings/xcf.c:375:    res.first_tile = tile;    if(offset2)    all_tiles_eq = offset2-offset;    }    if(all_tiles_eq && offset2 && offset2-offset != all_tiles_eq)    all_tiles_eq = 0;    if(all_tiles_eq)    ob.len = all_tiles_eq;    else if(offset2)    ob.len = offset2-offset; +  else +  ob.len = MIN((TILE_WIDTH*TILE_HEIGHT*5),ob.len);    tile->data = ob;    tile->next = NULL;   /* fprintf(stderr, "tile, o=%d; o2=%d; l=%d\n", offset, offset2,ob.len); */    offset = offset2;    }    UNSET_ONERROR( err );    return res;   }      static struct hierarchy read_hierarchy( struct buffer *buff,
pike.git/src/modules/Image/encodings/xcf.c:719:       ref_push_string( s_layers );    l = i->first_layer;    while(l)    {    nitems++;    push_layer( l );    l = l->next;    }    f_aggregate( nitems ); -  f_reverse(1); +        ref_push_string( s_channels );    nitems=0;    c = i->first_channel;    while(c)    {    nitems++;    push_channel( c );    c = c->next;    }    f_aggregate( nitems ); -  f_reverse(1); +     f_aggregate_mapping( sp-osp );   }         static void image_xcf____decode( INT32 args )   {    struct pike_string *s;    struct buffer b;    struct gimp_image res;    ONERROR err;
pike.git/src/modules/Image/encodings/xcf.c:757:    res = read_image( &b );    SET_ONERROR( err, free_image, &res );    push_image( &res );    UNSET_ONERROR( err );    free_image( &res );    stack_swap();    pop_stack();   }       - #define TILE_WIDTH 64 - #define TILE_HEIGHT 64 -  +    unsigned char read_char( struct buffer *from )   {    unsigned char res = 0;    if(from->len)    {    res = from->str[0];    from->str++;    from->len--;    }    return res;
pike.git/src/modules/Image/encodings/xcf.c:850:   **! method object decode(string data)   **! Decodes a XCF image to a single image object.   **!   **! note   **! Throws upon error in data, you will loose quite a lot of   **! information by doing this. See Image.XCF._decode and Image.XCF.__decode   */         /* - **! method mapping _decode(string|object data) + **! method mapping _decode(string|object data,mapping|void options)   **! Decodes a XCF image to a mapping, with at least an - **! 'image' and an 'alpha' object. Data is either a XCF image, or + **! 'image' and possibly an 'alpha' object. Data is either a XCF image, or   **! a XCF.GimpImage object structure (as received from __decode)   **! -  + **! <pre> Supported options + **! ([ + **! "background":({r,g,b})||Image.color object + **! "draw_all_layers":1, + **! Draw invisible layers as well + **! + **! "draw_guides":1, + **! Draw the guides + **! + **! "draw_selection":1, + **! Mark the selection using an overlay + **! + **! "ignore_unknown_layer_modes":1 + **! Do not asume 'Normal' for unknown layer modes. + **! + **! "mark_layers":1, + **! Draw an outline around all (drawn) layers + **! + **! "mark_layer_names":Image.font object, + **! Write the name of all layers using the font object, + **! + **! "mark_active_layer":1, + **! Draw an outline around the active layer + **! ])</pre> + **!   **! note   **! Throws upon error in data. For more information, see Image.XCF.__decode   */      /* - **! method object __decode(string|mapping data) + **! method object __decode(string|mapping data, mapping|void options)   **! Decodes a XCF image to a Image.XCF.GimpImage object.   **! - **! <pre>Structure reference + **! <pre>Returned structure reference   **!   **! class GimpImage   **! {   **! int width;   **! int height;   **! int compression;   **! int type;   **! int tattoo_state;   **! float xres = 72.0;   **! float yres = 72.0;
pike.git/src/modules/Image/encodings/xcf.c:933:   **! int bpp;   **! }   **!   **! class Parasite   **! {   **! string name;   **! int flags;   **! string data;   **! }   **! - **! +    **! class Guide   **! {   **! int pos;   **! int vertical;   **! }   **!   **! class Path   **! {   **! string name;   **! int ptype;
pike.git/src/modules/Image/encodings/xcf.c:1049:   **! "tiles":({   **! string,   **! ...   **! }),   **! ]),   **! }),   **! ])   **!</pre>   */    - #define MIN(X,Y) ((X)<(Y)?(X):(Y)) +    void image_xcf_f__decode_tiles( INT32 args )   {    extern void check_signals();    struct object *io,*ao, *cmapo;    struct array *tiles; -  struct image *i, *a; +  struct image *i, *a=NULL;    struct neo_colortable *cmap = NULL;    rgb_group *colortable=NULL;    int rle, bpp, span;    unsigned int l, x=0, y=0, cx, cy; -  get_all_args( "_decode_tiles", args, "%o%o%a%i%i%O", +  get_all_args( "_decode_tiles", args, "%o%O%a%i%i%O",    &io, &ao, &tiles, &rle, &bpp, &cmapo);    if( !(i = (struct image *)get_storage( io, image_program )))    error("Wrong type object argument 1 (image)\n"); -  if( !(a = (struct image *)get_storage( ao, image_program ))) +  if(ao && !(a = (struct image *)get_storage( ao, image_program )))    error("Wrong type object argument 2 (image)\n");    if( cmapo &&    !(cmap=(struct neo_colortable *)get_storage(cmapo,    image_colortable_program)))    error("Wrong type object argument 4 (colortable)\n");    for(l=0; l<(unsigned int)tiles->size; l++)    if(tiles->item[l].type != T_STRING)    error("Wrong type array argument 3 (tiles)\n"); -  if(i->xsize != a->xsize ||i->ysize != a->ysize) +  if(a && (i->xsize != a->xsize ||i->ysize != a->ysize))    error("Image and alpha objects are not identically sized.\n");       if(cmap)    {    colortable = malloc(sizeof(rgb_group)*image_colortable_size( cmap ));    image_colortable_write_rgb( cmap, (unsigned char *)colortable );    }       -  + /* switch(bpp) */ + /* { */ + /* case 1: */ + /* case 3: */ + /* if(ao) */ + /* { */ + /* destruct( ao ); */ + /* a=0; */ + /* ao=0; */ + /* } */ + /* break; */ + /* } */ +     x=y=0;    for(l=0; l<(unsigned)tiles->size; l++)    {    struct pike_string *tile = tiles->item[l].u.string;    unsigned int eheight, ewidth;    unsigned char *s;    ewidth = MIN(TILE_WIDTH, i->xsize-x);    eheight = MIN(TILE_HEIGHT, i->ysize-y);    tile->refs++;   
pike.git/src/modules/Image/encodings/xcf.c:1122:       s = tile->str;       check_signals(); /* Allow ^C */       for(cy=0; cy<eheight; cy++)    {    for(cx=0; cx<ewidth; cx++)    {    rgb_group pix; -  rgb_group apix = {255,255,255}; +  rgb_group apix;    int ind = (cx+cy*ewidth);       if(rle)    span = ewidth*eheight;    else    span = 1;    if(cx+x > (unsigned)i->xsize) continue;    if(cy+y > (unsigned)i->ysize) continue;       switch( bpp )
pike.git/src/modules/Image/encodings/xcf.c:1161:    break;    case 4: /* rgb with alpha */    pix.r = s[ind];    pix.g = s[ind+span*1];    pix.b = s[ind+span*2];    apix.r = apix.g = apix.b = s[ind+span*3];    break;    }    ind = i->xsize*(cy+y)+(cx+x);    i->img[ind] = pix; -  a->img[ind] = apix; +  if(a) a->img[ind] = apix;    }    }    x += TILE_WIDTH;    if( x >= (unsigned)i->xsize )    {    x = 0;    y += TILE_HEIGHT;    }    if(y>=(unsigned)i->ysize)    {