3d89251997-11-02Mirar (Pontus Hagland) /* $Id: pnm.c,v 1.7 1997/11/02 03:42:36 mirar Exp $ */
e3cb4b1997-04-03Mirar (Pontus Hagland)  /* **! module Image
4ce7411997-05-29Mirar (Pontus Hagland) **! note
3d89251997-11-02Mirar (Pontus Hagland) **! $Id: pnm.c,v 1.7 1997/11/02 03:42:36 mirar Exp $
e3cb4b1997-04-03Mirar (Pontus Hagland) **! class image */
ab6aec1997-02-11Fredrik Hübinette (Hubbe)  #include "global.h" #include <math.h> #include <ctype.h> #include "stralloc.h" #include "global.h"
bb55f81997-03-16Fredrik Hübinette (Hubbe) #include "pike_macros.h"
ab6aec1997-02-11Fredrik Hübinette (Hubbe) #include "object.h" #include "constants.h" #include "interpret.h" #include "svalue.h" #include "array.h" #include "error.h" #include "image.h" #define THIS ((struct image *)(fp->current_storage)) #define THISOBJ (fp->current_object)
3d89251997-11-02Mirar (Pontus Hagland) extern struct program *image_program;
ab6aec1997-02-11Fredrik Hübinette (Hubbe) 
e3cb4b1997-04-03Mirar (Pontus Hagland) /* **! method string toppm()
3d89251997-11-02Mirar (Pontus Hagland) **! <b>compability method</b> - do not use in new programs. **! **! See <ref>Image.PNM.encode</ref>(). **!
e3cb4b1997-04-03Mirar (Pontus Hagland) **! returns PPM data **! **! method object|string frompnm(string pnm) **! method object|string fromppm(string pnm)
3d89251997-11-02Mirar (Pontus Hagland) **! <b>compability method</b> - do not use in new programs. **! **! See <ref>Image.PNM.decode</ref>().
e3cb4b1997-04-03Mirar (Pontus Hagland) **! **! returns the called object or a hint of what wronged. **! arg string pnm **! pnm data, as a string */
ab6aec1997-02-11Fredrik Hübinette (Hubbe) void image_toppm(INT32 args) { pop_n_elems(args);
3d89251997-11-02Mirar (Pontus Hagland)  THISOBJ->refs++; push_object(THISOBJ); img_pnm_encode_binary(1);
ab6aec1997-02-11Fredrik Hübinette (Hubbe) } void image_frompnm(INT32 args) {
3d89251997-11-02Mirar (Pontus Hagland)  struct image *img; img_pnm_decode(args); img=(struct image*)get_storage(sp[-1].u.object,image_program); if (THIS->img) free(THIS->img); *THIS=*img; THIS->img=malloc(img->xsize*img->ysize*sizeof(rgb_group)+1); if (!THIS->img) error("out of memory\n"); MEMCPY(THIS->img,img->img,img->xsize*img->ysize*sizeof(rgb_group)); pop_n_elems(1); THISOBJ->refs++; push_object(THISOBJ);
ab6aec1997-02-11Fredrik Hübinette (Hubbe) }