- CGrafPtr origPort ;
- GDHandle origDevice ;
-
- GetGWorld( &origPort , &origDevice ) ;
- SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ;
- LockPixels( GetGWorldPixMap( M_BITMAPDATA->m_hBitmap ) ) ;
-
-#ifdef __UNIX__
- // bits is a word aligned array?? Don't think so
- // bits is a char array on MAC OS X however using the benefit of the
- // doubt I replaced references to 16 with sizeof(unsigned char)*8
- unsigned char* linestart = (unsigned char*) bits ;
- int linesize = ( the_width / (sizeof(unsigned char) * 8)) ;
- if ( the_width % (sizeof(unsigned char) * 8) ) {
- linesize += sizeof(unsigned char);
- }
-#else
- // bits is a word aligned array
-
- unsigned char* linestart = (unsigned char*) bits ;
- int linesize = ( the_width / 16 ) * 2 ;
- if ( the_width % 16 )
- {
- linesize += 2 ;
- }
-#endif
-
- RGBColor colors[2] = {
- { 0xFFFF , 0xFFFF , 0xFFFF } ,
- { 0, 0 , 0 }
- } ;
-
- for ( int y = 0 ; y < the_height ; ++y , linestart += linesize )
- {
- for ( int x = 0 ; x < the_width ; ++x )
- {
- int index = x / 8 ;
- int bit = x % 8 ;
- int mask = 1 << bit ;
- if ( linestart[index] & mask )
- {
- SetCPixel( x , y , &colors[1] ) ;
- }
- else
- {
- SetCPixel( x , y , &colors[0] ) ;
- }
- }
-
- }
- UnlockPixels( GetGWorldPixMap( M_BITMAPDATA->m_hBitmap ) ) ;