MUNGE.C (767B)
1 2 /* 3 ================= 4 = 5 = VL_MungePic 6 = 7 ================= 8 */ 9 10 void VL_MungePic (unsigned char far *source, unsigned width, unsigned height) 11 { 12 unsigned x,y,plane,size,pwidth; 13 unsigned char far *temp, far *dest, far *srcline; 14 15 size = width*height; 16 17 if (width&3) 18 errout ("VL_MungePic: Not divisable by 4!\n"); 19 20 // 21 // copy the pic to a temp buffer 22 // 23 temp = (unsigned char far *)farmalloc (size); 24 if (!temp) 25 errout ("Non enough memory for munge buffer!\n"); 26 27 _fmemcpy (temp,source,size); 28 29 // 30 // munge it back into the original buffer 31 // 32 dest = source; 33 pwidth = width/4; 34 35 for (plane=0;plane<4;plane++) 36 { 37 srcline = temp; 38 for (y=0;y<height;y++) 39 { 40 for (x=0;x<pwidth;x++) 41 *dest++ = *(srcline+x*4+plane); 42 srcline+=width; 43 } 44 } 45 46 free (temp); 47 } 48