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++) { //printf("%d ",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; // o is an index to the destination
- //xlattable[o].xlatx = (int)((ww2-fx-fr*sin(fy))+ww2)/64;
- xlattable[o].xlatx = (int)((-ww2-fx-fr*cos(fy/16))+ww2)/57;
- xlattable[o].xlaty = (int)((-wh2-fy-fr*sin(fx/16))+wh2)/69;
- }
- }
- printf("done\n");
- }
- // apply pixel translation with wrapping (toroidal) and fade out colors
- int odest, array_size;
- o=0; array_size=ww*wh;
- for(y=0; y<wh; y++) { for(x=0; x<ww; x++) {
- o=(x+y*ww); // o is an index to the destination array (4 packed bytes for rgb)
- odest=o+(xlattable[o].xlatx+ww*xlattable[o].xlaty);
- if (odest < 0) {
- odest=(array_size-1)-((-odest-1)%array_size);
- }
- else {
- odest=odest%array_size;
- }
- for(i=2;i>=0;i--) {
- //copy xlated r,g,b src to dst and subtract a bit
- if(src[i+odest*4]<3) dst[i+o*4]=0; else dst[i+o*4]=src[i+odest*4]-3;
- }
- } } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement