pike.git / src / modules / Image / dct.c

version» Context lines:

pike.git/src/modules/Image/dct.c:1: - /* $Id: dct.c,v 1.4 1997/03/17 03:07:59 hubbe Exp $ */ + /* $Id: dct.c,v 1.5 1997/04/03 07:00:13 mirar Exp $ */    -  + /* + **! module Image + **! class image + */ +    #include "global.h"      #include <math.h>   #include <ctype.h>      #include "stralloc.h"   #include "global.h"   #include "types.h"   #include "pike_macros.h"   #include "object.h"
pike.git/src/modules/Image/dct.c:22:   #define THIS ((struct image *)(fp->current_storage))   #define THISOBJ (fp->current_object)      #define min(a,b) ((a)<(b)?(a):(b))   #define max(a,b) ((a)<(b)?(b):(a))   #define testrange(x) max(min((x),255),0)      static const double c0=0.70710678118654752440;   static const double pi=3.14159265358979323846;    + /* + **! method object dct(int newx,int newy) + **! Scales the image to a new size. + **! + **! Method for scaling is rather complex; + **! the image is transformed via a cosine transform, + **! and then resampled back. + **! + **! This gives a quality-conserving upscale, + **! but the algorithm used is n*n+n*m, where n + **! and m is pixels in the original and new image. + **! + **! Recommended wrapping algorithm is to scale + **! overlapping parts of the image-to-be-scaled. + **! + **! This functionality is actually added as an + **! true experiment, but works... + **! returns the new image object + **! arg int newx + **! arg int newy + **! new image size in pixels + **! + */ +    void image_dct(INT32 args)   {    rgbd_group *area,*val;    struct object *o;    struct image *img;    INT32 x,y,u,v;    double xsz2,ysz2,enh,xp,yp,dx,dy;    double *costbl;    rgb_group *pix;   
pike.git/src/modules/Image/dct.c:60:       if (args>=2    && sp[-args].type==T_INT    && sp[1-args].type==T_INT)    {    img->xsize=max(1,sp[-args].u.integer);    img->ysize=max(1,sp[1-args].u.integer);    }    else error("Illegal arguments to image->dct()\n");    -  if (!(img->img=malloc(sizeof(rgb_group)*img->xsize*img->ysize+1))) +  if (!(img->img=(rgb_group*)malloc(sizeof(rgb_group)* +  img->xsize*img->ysize+1)))    {    free(area);    free(costbl);    free_object(o);    error("Out of memory\n");    }       xsz2=THIS->xsize*2.0;    ysz2=THIS->ysize*2.0;