home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / ABUSESRC.ZIP / AbuseSrc / macabuse / src / transp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-20  |  1.7 KB  |  96 lines

  1. #include "transp.hpp"
  2.  
  3.  
  4. void transp_put(image *im, image *screen, uchar *table, int x, int y)
  5. {
  6.   short cx1,cy1,cx2,cy2;
  7.   screen->get_clip(cx1,cy1,cx2,cy2);
  8.   int xs=0,ys=0,xl=im->width(),yl=im->height();
  9.   if (x<cx1) 
  10.   { 
  11.     int chop=cx1-x;
  12.     xs+=chop;
  13.     xl-=chop;
  14.     x+=chop;
  15.   }
  16.   if (y<cy1) 
  17.   { 
  18.     int chop=cy1-y;
  19.     ys+=chop;
  20.     yl-=chop;
  21.     y+=chop;
  22.   }
  23.   if (x+xl>cx2)
  24.     xl=cx2-x;
  25.   if (y+yl>cy2)
  26.     yl=cy2-y;
  27.  
  28.   if (xl<0 || yl<0) return ;
  29.   screen->add_dirty(x,y,x+xl-1,y+yl-1);
  30.  
  31.   int ye=ys+yl;
  32.   int xe=xs+xl;
  33.  
  34.   uchar *isl=im->scan_line(ys)+xs;
  35.   uchar *ssl=screen->scan_line(y)+x;
  36.   int iw=im->width(),sw=screen->width();
  37.  
  38.   for (int iy=ys;iy<ye;iy++,y++,isl+=iw,ssl+=sw)
  39.   {
  40.     uchar *s=ssl,*i=isl;
  41.     for (int ix=xs;ix<xe;ix++,s++,i++)
  42.     {
  43.       if (*i)
  44.         *s=*i;
  45.       else *s=table[*s];
  46.     }
  47.   }        
  48. }
  49.  
  50.  
  51. /*
  52. void transp_put(image *im, image *screen, uchar *table, int x, int y)
  53. {
  54.   short cx1,cy1,cx2,cy2;
  55.   screen->get_clip(cx1,cy1,cx2,cy2);
  56.   int xs=0,ys=0,xl=im->width(),yl=im->height();
  57.   if (x<cx1) 
  58.   { 
  59.     int chop=cx1-x;
  60.     xs+=chop;
  61.     xl-=chop;
  62.     x+=chop;
  63.   }
  64.   if (y<cy1) 
  65.   { 
  66.     int chop=cy1-y;
  67.     ys+=chop;
  68.     yl-=chop;
  69.     y+=chop;
  70.   }
  71.   if (x+xl>cx2)
  72.     xl=cx2-x;
  73.   if (y+yl>cy2)
  74.     yl=cy2-y;
  75.  
  76.   if (xl<0 || yl<0) return ;
  77.   screen->add_dirty(x,y,x+xl-1,y+yl-1);
  78.  
  79.   int ye=ys+yl;
  80.   int xe=xs+xl;
  81.  
  82.   uchar *isl=im->scan_line(ys)+xs;
  83.   uchar *ssl=screen->scan_line(y)+x;
  84.   int iw=im->width(),sw=screen->width();
  85.  
  86.   for (int iy=ys;iy<ye;iy++,y++,isl+=iw,ssl+=sw)
  87.   {
  88.     uchar *s=ssl,*i=isl;
  89.     for (int ix=xs;ix<xe;ix++,s++,i++)
  90.       *s=table[((*i)<<8)|(*s)];
  91.   }        
  92. }
  93.  
  94.  
  95. */
  96.