public OtaBitmap(BufferedImage img){
  int bitOffset=0;
  int data=0;
  int nByte=0;
  int nTotalBytes=0;
  Raster raster=img.getData();
  width_=img.getWidth();
  height_=img.getHeight();
  nTotalBytes=(width_ * height_) / 8;
  if (((width_ * height_) % 8) > 0) {
    nTotalBytes++;
  }
  otaImgData_=new byte[nTotalBytes];
  for (int y=0; y < height_; y++) {
    for (int x=0; x < width_; x++) {
      int color=img.getRGB(x,y);
      if (color != 0) {
        data|=((1 << (7 - bitOffset)) & 0xff);
      }
      bitOffset++;
      if (bitOffset >= 8) {
        otaImgData_[nByte]=(byte)(data & 0xff);
        bitOffset=0;
        data=0x00;
        nByte++;
      }
    }
  }
  if (bitOffset > 0) {
    otaImgData_[nByte]=(byte)(data & 0xff);
  }
}

public OtaBitmap ( BufferedImage img ) { int bitOffset = 0 ; int data = 0 ; int nByte = 0 ; int nTotalBytes = 0 ; Raster raster = img . getData ( ) ; width_ = img . getWidth ( ) ; height_ = img . getHeight ( ) ; nTotalBytes = ( width_ * height_ ) / 8 ; if ( ( ( width_ * height_ ) % 8 ) > 0 ) { nTotalBytes ++ ; } otaImgData_ = new byte [ nTotalBytes ] ; for ( int y = 0 ; y < height_ ; y ++ ) { for ( int x = 0 ; x < width_ ; x ++ ) { int color = img . getRGB ( x , y ) ; if ( color != 0 ) { data |= ( ( 1 << ( 7 - bitOffset ) ) & 0xff ) ; } bitOffset ++ ; if ( bitOffset >= 8 ) { otaImgData_ [ nByte ] = ( byte ) ( data & 0xff ) ; bitOffset = 0 ; data = 0x00 ; nByte ++ ; } } } if ( bitOffset > 0 ) { otaImgData_ [ nByte ] = ( byte ) ( data & 0xff ) ; } }
creates an otabitmap object from an bufferedimage . < p > every pixel that is not white will be converted to black .
