pike.git / src / post_modules / GTK2 / source / support.c

version» Context lines:

pike.git/src/post_modules/GTK2/source/support.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: support.c,v 1.3 2005/11/04 19:07:34 grubba Exp $ + || $Id: support.c,v 1.4 2005/11/12 21:22:53 nilsson Exp $   */      #include <version.h>   #include <bignum.h>   #include <stdarg.h>      void pgtk_encode_grey(struct image *i, unsigned char *dest, int bpp, int bpl);      void pgtk_verify_setup() {    if (!pigtk_is_setup)
pike.git/src/post_modules/GTK2/source/support.c:53:      void pgtk_index_stack(char *what) {    push_text(what);    f_index(2);   #ifdef PIKE_DEBUG    if (Pike_sp[-1].type==PIKE_T_INT)    Pike_error("Internal indexing error.\n");   #endif   }    + #ifdef DYNAMIC_MODULE + struct program *image_color_program = NULL; + #else + extern struct program *image_color_program; + #endif +    int get_color_from_pikecolor(struct object *o, INT_TYPE *r, INT_TYPE *g, INT_TYPE *b) {    struct color_struct *col; -  static struct program *pike_color_program; -  if (!pike_color_program) { -  pgtk_get_image_module(); -  pgtk_index_stack("Color"); -  pgtk_index_stack("Color"); -  pike_color_program=program_from_svalue(--Pike_sp); +  + #ifdef DYNAMIC_MODULE +  if (!image_color_program) { +  image_color_program = PIKE_MODULE_IMPORT(Image, image_color_program); +  if(!image_color_program) +  Pike_error("Could not load Image module.\n");    } -  + #endif    -  col=(struct color_struct *)get_storage(o,pike_color_program); +  col=(struct color_struct *)get_storage(o,image_color_program);    if (!col)    return 0;    *r=col->rgbl.r/(COLORLMAX/65535);    *g=col->rgbl.g/(COLORLMAX/65535);    *b=col->rgbl.b/(COLORLMAX/65535);    return 1;   }    -  + #ifdef DYNAMIC_MODULE + struct program *image_program = NULL; + #else + extern struct program *image_program; + #endif      GdkImage *gdkimage_from_pikeimage(struct object *img, int fast, GdkImage *i) {    GdkColormap *col=gdk_colormap_get_system();    GdkVisual *vis=gdk_visual_get_system(); -  +  struct image *img_data;    INT_TYPE x,y;    -  /* 1a: create the actual image... */ +     TIMER_INIT("Getting extents"); -  apply(img,"xsize",0); -  apply(img,"ysize",0); -  get_all_args("internal",2,"%i%i",&x,&y); -  pop_n_elems(2); +     -  + #ifdef DYNAMIC_MODULE +  if(!image_program) { +  image_program = PIKE_MODULE_IMPORT(Image, image_program); +  if(!image_program) +  Pike_error("Could not load Image module.\n"); +  } + #endif    -  +  img_data=(struct image*)get_storage(img, image_program); +  +  /* 1a: create the actual image... */ +  x = img_data->xsize; +  y = img_data->ysize; +  +     if (x==0 || y==0)    Pike_error("Size of image must be > 0x0\n");    if (i) {    if ((i->width!=x) || (i->height!=y)) {    gdk_image_destroy((void *)i);    i=NULL;    }    }    if (!i) {    PFTIME("Create");
pike.git/src/post_modules/GTK2/source/support.c:111:       /* 1b: do the work.. */       if (vis->type==GDK_VISUAL_TRUE_COLOR || vis->type==GDK_VISUAL_STATIC_GRAY)    /* no colormap.. */    {    int pad=0;    int native_byteorder;    PFTIME("Convert");    if (vis->type==GDK_VISUAL_STATIC_GRAY) -  pgtk_encode_grey((void *)img->storage,i->mem,i->bpp,i->bpl); +  pgtk_encode_grey(img_data,i->mem,i->bpp,i->bpl);    else {    if (i->bpl!=(i->bpp*x))    switch(i->bpl & 3) {    case 0: pad = 4; break;    case 1: pad = 1; break;    case 2: pad = 2; break;    case 3: pad = 1; break;    }    else    pad=0; -  pgtk_encode_truecolor_masks((void *)img->storage,i->bpp*8,pad*8, +  pgtk_encode_truecolor_masks(img_data,i->bpp*8,pad*8,    (i->byte_order!=1),vis->red_mask,    vis->green_mask,vis->blue_mask,    i->mem, i->bpl*y);    }    } else {    static int colors_allocated=0;    static struct object *pike_cmap;    /* I hate this... colormaps, here we come.. */    /* This is rather complicated, but:    1/ build an array of the colors in the colormap