// create the colorbuffer object, which is basically a simple // wrapper around the directx surface. the colorbuffer is the // interface which is used by the surfaceproxy to support any // kind of underlying structure for the pixel data container.
mpColorBuffer = std::make_shared<GDIColorBuffer>(mpGDIPlusBitmap, maSize);
} else
{
mpSurface = mpRenderModule->createSystemMemorySurface(maSize);
// create the colorbuffer object, which is basically a simple // wrapper around the directx surface. the colorbuffer is the // interface which is used by the surfaceproxy to support any // kind of underlying structure for the pixel data container.
mpColorBuffer = std::make_shared<DXColorBuffer>(mpSurface, maSize);
}
GraphicsSharedPtr DXSurfaceBitmap::getGraphics()
{ // since clients will most probably draw directly // to the GDI+ bitmap, we need to mark it as dirty // to ensure that the corresponding dxsurface will // be updated.
mbIsSurfaceDirty = true;
D3DLOCKED_RECT aLockedRect; if(SUCCEEDED(mpSurface->LockRect(&aLockedRect,nullptr,D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY)))
{ // decide about the format we pass the gdi+, the directx surface is always // 32bit, either with or without alpha component.
Gdiplus::PixelFormat nFormat = hasAlpha() ? PixelFormat32bppARGB : PixelFormat32bppRGB;
// construct a gdi+ bitmap from the raw pixel data.
pResult = std::make_shared<Gdiplus::Bitmap>(maSize.getWidth(), maSize.getHeight(),
aLockedRect.Pitch,
nFormat, static_cast<BYTE *>(aLockedRect.pBits) );
if( Gdiplus::Ok != mpGDIPlusBitmap->LockBits( &aRect,
Gdiplus::ImageLockModeWrite | Gdiplus::ImageLockModeUserInputBuf,
PixelFormat32bppARGB, // TODO: Adapt to // Graphics native // format/change // getMemoryLayout
&aBmpData ) )
{ throw uno::RuntimeException("GDIPlus method call was unsuccessful, problem with locking bitmap aRect object");
}
// commit data to bitmap
mpGDIPlusBitmap->UnlockBits( &aBmpData );
} else
{
sal_uInt32 nWidth = rect.X2-rect.X1;
sal_uInt32 nHeight = rect.Y2-rect.Y1;
// lock the directx surface to receive the pointer to the surface memory.
D3DLOCKED_RECT aLockedRect; if(FAILED(mpSurface->LockRect(&aLockedRect,nullptr,D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY))) throw uno::RuntimeException("failed to lock directx surface to surface memory");
ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < aSize.Width, "CanvasHelper::setPixel: X coordinate out of bounds" );
ENSURE_ARG_OR_THROW( pos.Y >= 0 && pos.Y < aSize.Height, "CanvasHelper::setPixel: Y coordinate out of bounds" );
ENSURE_ARG_OR_THROW( color.getLength() > 3, "CanvasHelper::setPixel: not enough color components" );
if( Gdiplus::Ok != mpGDIPlusBitmap->SetPixel( pos.X, pos.Y,
Gdiplus::Color( tools::sequenceToArgb( color ))))
{ throw uno::RuntimeException("Problem with setting the color of bitmap object");
}
} else
{
ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < maSize.getWidth(), "CanvasHelper::setPixel: X coordinate out of bounds" );
ENSURE_ARG_OR_THROW( pos.Y >= 0 && pos.Y < maSize.getHeight(), "CanvasHelper::setPixel: Y coordinate out of bounds" );
ENSURE_ARG_OR_THROW( color.getLength() > 3, "CanvasHelper::setPixel: not enough color components" );
// lock the directx surface to receive the pointer to the surface memory.
D3DLOCKED_RECT aLockedRect; if(FAILED(mpSurface->LockRect(&aLockedRect,nullptr,D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY))) throw uno::RuntimeException("cannot lock the directx surface to surface memory");
ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < aSize.Width, "CanvasHelper::getPixel: X coordinate out of bounds" );
ENSURE_ARG_OR_THROW( pos.Y >= 0 && pos.Y < aSize.Height, "CanvasHelper::getPixel: Y coordinate out of bounds" );
return tools::argbToIntSequence(aColor.GetValue());
} else
{
ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < maSize.getWidth(), "CanvasHelper::getPixel: X coordinate out of bounds" );
ENSURE_ARG_OR_THROW( pos.Y >= 0 && pos.Y < maSize.getHeight(), "CanvasHelper::getPixel: Y coordinate out of bounds" );
// lock the directx surface to receive the pointer to the surface memory.
D3DLOCKED_RECT aLockedRect; if(FAILED(mpSurface->LockRect(&aLockedRect,nullptr,D3DLOCK_NOSYSLOCK|D3DLOCK_READONLY))) throw uno::RuntimeException("failed to lock directX surface to surface memory");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.