Example #1
0
void Window::Refresh(int x, int y, int w, int h) {
  int32* d = (int32*)_offscreen->Bits();
  int32* dl = d;
  uint8* s = (uint8*)_bitmap->Bits();
  uint8* sl = s;
  if (Lock()) {
    switch(_surface->root.bitmap.mode) {
	case gr_pixel_mode_mono:
	  for (y = 0; y < _surface->root.bitmap.rows; y++) {
	    sl = s;
	    dl = d;
	    for (x = 0; x < _surface->root.bitmap.width; x++) {
	      *dl = *sl ? -1 : 0;
	      sl++; dl++;
	    }
	    s += _bitmap->BytesPerRow();
	    d = (int32*)(((char*)d) + _offscreen->BytesPerRow());
	  }
	  break;
	case gr_pixel_mode_gray:
	  for (y = 0; y < _surface->root.bitmap.rows; y++) {
	    sl = s;
	    int8* dx = (int8*)d;
	    for (x = 0; x < _surface->root.bitmap.width; x++) {
	      *dx = *sl; dx++;
	      *dx = *sl; dx++;
	      *dx = *sl; dx++;
	      *dx = *sl; dx++;
	      sl++;
	    }
	    s += _bitmap->BytesPerRow();
	    d = (int32*)(((char*)d) + _offscreen->BytesPerRow());
	  }
	  break;
	default:
	  fprintf(stderr, "unsupported mode: %d\n", _surface->root.bitmap.mode);
	  break;
    }
    _view->Invalidate();
    Unlock();
  }
}