Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #define MAXXLAT 1228800
  5.  
  6. void pix(int frame, int alen, int achannels, short *abuf, double *fbuf,
  7.   int ww, int wh, int bpp, int *mbuf, unsigned char *dst, unsigned char *src,
  8.   unsigned char *buf2, unsigned char *buf3)
  9. {
  10. int i, o, o1, x, y, x1, y1, dx=bpp, dy=bpp*ww;
  11. int ww2=ww/2, wh2=wh/2;
  12. struct xlatr{
  13.   signed short xlatx;
  14.   signed short xlaty;
  15. }xlattable[MAXXLAT];
  16. float fx,fy,fr=0.0;
  17.  
  18. if(frame < 1)
  19. {
  20.   printf("\npix: generating %i,%i transform map...",ww,wh);
  21.   for(y=0; y<wh; y++) {
  22.     for(x=0; x<ww; x++) {
  23.       fx=(float)(x-ww2); fy=(float)(y-wh2);
  24.       fr=0.43*sqrt(fx*fx+fy*fy);
  25.       o=x+y*ww;  
  26.       xlattable[o].xlatx = (fx+-fr*sin(fy/16)+ww2)/57;
  27.       xlattable[o].xlaty = (fy+-fr*cos(fx/116)+wh2)/69;
  28.     }
  29.   }
  30.  printf("done\n");
  31. }
  32. // apply pixel translation with wrapping (toroidal) and fade out colors
  33. int odest, array_size, roff=0;
  34. o=0; array_size=ww*wh;
  35. for(y=0; y<wh; y++) { for(x=0; x<ww; x++) { // iterate through bitmap
  36.     o=(x+y*ww);  // o is an index to the x*y array
  37.     //roff=((rand()%64)-32)/8; // printf("%i\n",roff);
  38.     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
  39.     if (odest < 0) odest=(array_size-1)-((-odest-1)%array_size); else odest=odest%array_size;
  40.     for(i=2;i>=0;i--) { // loop through r,g,b
  41.       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
  42.     }
  43. } } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement