void LKBitmapSurface::Create(const LKSurface& Surface, unsigned width, unsigned height) { #ifdef USE_GDI Attach(::CreateCompatibleDC(Surface.GetAttribDC())); SetAttribDC(Surface.GetAttribDC()); _Size = { (LONG)width, (LONG)height }; _hBitmap = LKBitmap (::CreateCompatibleBitmap(GetAttribDC(), width, height)); _oldBitmap = LKBitmap((HBITMAP)::SelectObject(_OutputDC, _hBitmap)); #else _pCanvas = new BufferCanvas(Surface, {width, height}); #endif }
void LKBitmapSurface::Resize(unsigned width, unsigned height) { #ifdef USE_GDI if (_oldBitmap) { ::SelectObject(_OutputDC, _oldBitmap); _oldBitmap.Release(); } if (_hBitmap) { _hBitmap.Release(); } _Size = { (LONG)width, (LONG)height }; _hBitmap = LKBitmap (::CreateCompatibleBitmap(GetAttribDC(), width, height)); _oldBitmap = LKBitmap((HBITMAP)::SelectObject(_OutputDC, _hBitmap)); #else if(_pCanvas) { static_cast<BufferCanvas*>(_pCanvas)->Resize({width, height}); } #endif }
HDC LKSurface::GetTempDC() { if (!_TempDC) { _TempDC = ::CreateCompatibleDC(GetAttribDC()); } return _TempDC; }