pike.git / lib / modules / _Image_XPM.pmod

version» Context lines:

pike.git/lib/modules/_Image_XPM.pmod:1:   #pike __REAL_VERSION__    + //! @appears Image.XPM + //! X PixMap image format. +    inherit Image._XPM;   #if 0   # define TE( X ) werror("XPM profile: %-20s ... ", (X));   int old_time,start_time;   # define TI(X) start_time=old_time=gethrtime();TE(X)   # define TD( X ) do{\    werror("%3.02f (%3.02f)\n", (gethrtime()-old_time)/1000000.0,(gethrtime()-start_time)/1000000.0);\    TE(X); \    old_time = gethrtime(); \   } while(0);   #else   # define TI(X)   # define TD(X)   # define TE(X)   #endif    -  + //! @decl mapping _decode(string bytes, mapping|void options)   mapping _decode( string what, void|mapping opts )   { -  array e; +     array data;    mapping retopts = ([ ]);    if(!opts)    opts = ([]);    TI("Scan for header");    if(sscanf(what, "%*s/*%*[ \t]XPM%*[ \t]*/%*s{%s", what) != 5)    error("This is not a XPM image (1)\n");    -  if(strlen(what)<100000) +  if(sizeof(what)<100000)    {    TD("Extra scan for small images");    sscanf(what, "%s\n/* XPM */", what ) ||    sscanf(what, "%s\n/*\tXPM\t*/", what ) ||    sscanf(what, "%s\n/*\tXPM */", what )||    sscanf(what, "%s\n/* XPM */", what );       /* This is just a sanity check... */    what = reverse(what);    if(sscanf(what, "%*s}%s", what) != 2)    error("This is not a XPM image (3)\n");    what = reverse(what);    }       TD("Explode");    data = what/"\n";    what = 0;    int len = sizeof(data); -  int r, sp; +        TD("Trim");    _xpm_trim_rows( data );       array values = (array(int))(replace(data[0], "\t", " ")/" "-({""}));    int width = values[0];    int height = values[1];    if(!width || !height)    error("Width or height == 0\n");   
pike.git/lib/modules/_Image_XPM.pmod:61:    int cpp = values[3];    if(sizeof(values)>5)    {    retopts->hot_x = values[4];    retopts->hot_y = values[5];    }    TD("Colors");    if(sizeof(data) < ncolors+2)    error("Too few elements in array to decode color values\n");    array colors; -  if(cpp < 4) -  colors = data[1..ncolors]; -  else +  + // kludge? probable FIXME? + // I can't see why the colors not always must be sorted... + // /Mirar 2003-01-31 +  + // if(cpp < 4) + // colors = data[1..ncolors]; + // else    colors = sort(data[1..ncolors]);    TD("Creating images"); -  object i = Image.image( width, height ); -  object a = Image.image( width, height,255,255,255 ); +  object i = Image.Image( width, height ); +  object a = Image.Image( width, height,255,255,255 );    TD("Decoding image");   // for(int y = 0; y<height && y<sizeof(data); y++)    _xpm_write_rows( i,a,cpp,colors,data );   // _xpm_write_row( height, i, a, data[ncolors+y+1], cpp, colors );    TD("Done");       retopts->image = i;    retopts->alpha = a;    return retopts;   }
pike.git/lib/modules/_Image_XPM.pmod:93:    "'", ")", "!", "~", "{", "]", "^", "/", "(", "_", ":", "<", "[",    "}", "|", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a",    "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",    "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A",    "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",    "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", " ",   });      array cmap_t;    + //! @decl string encode(Image.Image image, mapping|void options)   string encode( object what, mapping|void options )   {    int x,y,q; -  array lcmapt; +     TI("Encode init");    if(!options) options = ([]);    if(!cmap_t)    {    cmap_t = allocate( 8100 );    for(x=0; x<90; x++)    for(y=0; y<90; y++)    cmap_t[q++] = ok[x]+ok[y];    }    TD("Encode CT");
pike.git/lib/modules/_Image_XPM.pmod:165:    foreach(colors, string c)    res += "\""+c+"\",\n";    TD(sprintf("Encode %d rows", sizeof(rows)));       q = sizeof(rows);    foreach(rows, string row)    {    string r = "";    int i;    r += "\""; -  for(i=0; i<strlen(row); i++) +  for(i=0; i<sizeof(row); i++)    r += cmap_t[row[i]];    res += r+"\",\n";    }       TD(sprintf("Encoded %d rows", sizeof(rows)));    res = res+"};\n";    TE("Done");    return res;   }    -  + //! @decl Image.Image decode(string bytes)   object decode( string what )   {    return _decode(what)->image;   }