src/rawcolor.c
/************************************************************************/
/*									*/
/*			U n c o l o r i z e _ B i t m a p		*/
/*									*/
/*	Uncolorize bitmap from 8bpp to 1bpp.				*/
/*									*/
/************************************************************************/
U n c o l o r i z e _ B i t m a p

Uncolorize bitmap from 8bpp to 1bpp.
U n c o l o r i z e _ B i t m a p Uncolorize bitmap from 8bpp to 1bpp .
void Uncolorize_Bitmap(LispPTR args[])
{
  BITMAP *s_bitmap, *d_bitmap;
  register DLword *OnOff;
  register u_char *s_base;
  register DLword *d_base;
  register int y;
  int s_height, s_width, s_bitsperpixel, s_rasterwidth, d_rasterwidth;
  s_bitmap = (BITMAP *)Addr68k_from_LADDR(args[0]);
  d_bitmap = (BITMAP *)Addr68k_from_LADDR(args[1]);
  OnOff = (DLword *)Addr68k_from_LADDR(args[2]);
  s_height = s_bitmap->bmheight;
  s_width = s_bitmap->bmwidth;
  s_bitsperpixel = s_bitmap->bmbitperpixel;
  if (s_bitsperpixel != 8) return;
  s_base = (u_char *)Addr68k_from_LADDR(s_bitmap->bmbase);
  d_base = (DLword *)Addr68k_from_LADDR(d_bitmap->bmbase);
  s_rasterwidth = s_bitmap->bmrasterwidth;
  d_rasterwidth = d_bitmap->bmrasterwidth;
  for (y = 0; y < s_height; y++) {
    register int x;
    register DLword word;
    word = 0;
    for (x = 0; x < s_width; x++) {
      if (OnOff[*(s_base + x)]) {
        switch (x & 0xF) {
          case 0: word |= 0x8000; break;
          case 1: word |= 0x4000; break;
          case 2: word |= 0x2000; break;
          case 3: word |= 0x1000; break;
          case 4: word |= 0x800; break;
          case 5: word |= 0x400; break;
          case 6: word |= 0x200; break;
          case 7: word |= 0x100; break;
          case 8: word |= 0x80; break;
          case 9: word |= 0x40; break;
          case 10: word |= 0x20; break;
          case 11: word |= 0x10; break;
          case 12: word |= 0x8; break;
          case 13: word |= 0x4; break;
          case 14: word |= 0x2; break;
          case 15:
            word |= 0x1;
            break;
          defaults:
            break;
        } 
      }   
      if ((x & 0xF) == 0xF) {
        *(d_base++) = word;
        word = 0;
      } 
    }   
    if ((x & 0xF) != 0) *(d_base++) = word;
    if (y != (s_height - 1)) { (DLword *)s_base += s_rasterwidth; } 
  } 
}
void Uncolorize_Bitmap ( LispPTR args [ ] ) { BITMAP * s_bitmap , * d_bitmap ; register DLword * OnOff ; register u_char * s_base ; register DLword * d_base ; register int y ; int s_height , s_width , s_bitsperpixel , s_rasterwidth , d_rasterwidth ; s_bitmap = ( BITMAP * ) Addr68k_from_LADDR ( args [ 0 ] ) ; d_bitmap = ( BITMAP * ) Addr68k_from_LADDR ( args [ 1 ] ) ; OnOff = ( DLword * ) Addr68k_from_LADDR ( args [ 2 ] ) ; s_height = s_bitmap -> bmheight ; s_width = s_bitmap -> bmwidth ; s_bitsperpixel = s_bitmap -> bmbitperpixel ; if ( s_bitsperpixel != 8 ) return ; s_base = ( u_char * ) Addr68k_from_LADDR ( s_bitmap -> bmbase ) ; d_base = ( DLword * ) Addr68k_from_LADDR ( d_bitmap -> bmbase ) ; s_rasterwidth = s_bitmap -> bmrasterwidth ; d_rasterwidth = d_bitmap -> bmrasterwidth ; for ( y = 0 ; y < s_height ; y ++ ) { register int x ; register DLword word ; word = 0 ; for ( x = 0 ; x < s_width ; x ++ ) { if ( OnOff [ * ( s_base + x ) ] ) { switch ( x & 0xF ) { case 0 : word |= 0x8000 ; break ; case 1 : word |= 0x4000 ; break ; case 2 : word |= 0x2000 ; break ; case 3 : word |= 0x1000 ; break ; case 4 : word |= 0x800 ; break ; case 5 : word |= 0x400 ; break ; case 6 : word |= 0x200 ; break ; case 7 : word |= 0x100 ; break ; case 8 : word |= 0x80 ; break ; case 9 : word |= 0x40 ; break ; case 10 : word |= 0x20 ; break ; case 11 : word |= 0x10 ; break ; case 12 : word |= 0x8 ; break ; case 13 : word |= 0x4 ; break ; case 14 : word |= 0x2 ; break ; case 15 : word |= 0x1 ; break ; defaults : break ; } } if ( ( x & 0xF ) == 0xF ) { * ( d_base ++ ) = word ; word = 0 ; } } if ( ( x & 0xF ) != 0 ) * ( d_base ++ ) = word ; if ( y != ( s_height - 1 ) ) { ( DLword * ) s_base += s_rasterwidth ; } } }
U n c o l o r i z e _ B i t m a p
U n c o l o r i z e _ B i t m a p
/* end switch( x ) */ /* end if( ) */ /* end if( x ) */ /* end for( x ) */ /* end if( y ) */ /* end for( y ) */