Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #define MAXXLAT 1228800
- void pix(int frame, int alen, int achannels, short *abuf, double *fbuf,
- int ww, int wh, int bpp, int *mbuf, unsigned char *dst, unsigned char *src,
- unsigned char *buf2, unsigned char *buf3)
- {
- int i, o, o1, x, y, x1, y1, dx=bpp, dy=bpp*ww;
- int ww2=ww/2, wh2=wh/2;
- struct xlatr{
- signed short xlatx;
- signed short xlaty;
- }xlattable[MAXXLAT];
- float fx,fy,fr=0.0;
- if(frame < 1)
- {
- printf("\npix: generating %i,%i transform map...",ww,wh);
- for(y=0; y<wh; y++) {
- for(x=0; x<ww; x++) {
- fx=(float)(x-ww2); fy=(float)(y-wh2);
- fr=0.43*sqrt(fx*fx+fy*fy);
- o=x+y*ww;
- xlattable[o].xlatx = (fx+-fr*sin(fy/16)+ww2)/57;
- xlattable[o].xlaty = (fy+-fr*cos(fx/116)+wh2)/69;
- }
- }
- printf("done\n");
- }
- // apply pixel translation with wrapping (toroidal) and fade out colors
- int odest, array_size, roff=0;
- o=0; array_size=ww*wh;
- for(y=0; y<wh; y++) { for(x=0; x<ww; x++) { // iterate through bitmap
- o=(x+y*ww); // o is an index to the x*y array
- //roff=((rand()%64)-32)/8; // printf("%i\n",roff);
- odest=(int)(o+xlattable[o].xlatx +(cos(frame/12.1))*1.21 +ww*((int)(cos(frame/12.1)*6.18*sin(x/200.0))+ xlattable[o].xlaty) ); // calculate source pixel via xlation table
- if (odest < 0) odest=(array_size-1)-((-odest-1)%array_size); else odest=odest%array_size;
- for(i=2;i>=0;i--) { // loop through r,g,b
- if(src[i+odest*4]<4) dst[i+o*4]=0; else dst[i+o*4]=src[i+odest*4]-4; //copy xlated src to dest
- }
- } } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement