44 "CanvasBitmap::CanvasBitmap(): Invalid surface or device" );
46 maCanvasHelper.setDevice( *
mpDevice );
47 maCanvasHelper.setTarget(
mpBitmap );
56 CanvasBitmap_Base::disposeThis();
66 :
bmiHeader({0,0,0,1,8,BI_RGB,0,0,0,0,0})
68 for (
size_t i = 0;
i < 256; ++
i)
90 aRes <<= reinterpret_cast<sal_Int64>(
nullptr );
98 mpBitmap->getBitmap()->GetHBITMAP(Gdiplus::Color(), &aHBmp );
100 uno::Sequence< uno::Any >
args{
uno::Any(
reinterpret_cast<sal_Int64
>(aHBmp)) };
107 HDC hScreenDC=
GetDC(
nullptr);
109 HBITMAP hBmpBitmap = CreateCompatibleBitmap( hScreenDC,
115 BITMAPINFOHEADER aBIH;
117 aBIH.biSize =
sizeof( BITMAPINFOHEADER );
121 aBIH.biBitCount = 32;
122 aBIH.biCompression = BI_RGB;
125 aBIH.biSizeImage = 0;
126 aBIH.biXPelsPerMeter = 0;
127 aBIH.biYPelsPerMeter = 0;
129 aBIH.biClrImportant = 0;
135 aBmpData.PixelFormat = PixelFormat32bppARGB;
139 if( Gdiplus::Ok != pGDIPlusBitmap->LockBits( &aRect,
140 Gdiplus::ImageLockModeRead,
141 PixelFormat32bppARGB,
150 SetDIBits( hScreenDC, hBmpBitmap, 0, aSize.
getHeight(),
aBmpData.Scan0,
reinterpret_cast<PBITMAPINFO
>(&aBIH), DIB_RGB_COLORS );
152 pGDIPlusBitmap->UnlockBits( &
aBmpData );
154 uno::Sequence< uno::Any >
args{
uno::Any(
reinterpret_cast<sal_Int64
>(hBmpBitmap)) };
168 static AlphaDIB aDIB;
172 HDC hScreenDC=
GetDC(
nullptr);
174 HBITMAP hBmpBitmap = CreateCompatibleBitmap( hScreenDC, aSize.
getWidth(), aSize.
getHeight() );
178 aDIB.bmiHeader.biSize =
sizeof( BITMAPINFOHEADER );
179 aDIB.bmiHeader.biWidth = aSize.
getWidth();
180 aDIB.bmiHeader.biHeight = -aSize.
getHeight();
181 aDIB.bmiHeader.biPlanes = 1;
182 aDIB.bmiHeader.biBitCount = 8;
183 aDIB.bmiHeader.biCompression = BI_RGB;
184 aDIB.bmiHeader.biSizeImage = 0;
185 aDIB.bmiHeader.biXPelsPerMeter = 0;
186 aDIB.bmiHeader.biYPelsPerMeter = 0;
187 aDIB.bmiHeader.biClrUsed = 0;
188 aDIB.bmiHeader.biClrImportant = 0;
194 aBmpData.PixelFormat = PixelFormat32bppARGB;
198 if( Gdiplus::Ok != pGDIPlusBitmap->LockBits( &aRect,
199 Gdiplus::ImageLockModeRead,
200 PixelFormat32bppARGB,
208 const sal_Int32 nScanWidth((aSize.
getWidth() + 3) & ~3);
209 std::unique_ptr<sal_uInt8[]> pAlphaBits(
new sal_uInt8[nScanWidth*aSize.
getHeight()] );
214 sal_uInt8* pOutBits=pAlphaBits.get()+
y*nScanWidth;
217 *pOutBits++ = *pInBits;
222 pGDIPlusBitmap->UnlockBits( &
aBmpData );
225 SetDIBits( hScreenDC, hBmpBitmap, 0,
227 reinterpret_cast<PBITMAPINFO
>(&aDIB), DIB_RGB_COLORS );
229 uno::Sequence< uno::Any >
args{
uno::Any(
reinterpret_cast<sal_Int64
>(hBmpBitmap)) };
241 return "DXCanvas.CanvasBitmap";
251 return {
"com.sun.star.rendering.CanvasBitmap" };
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) override
CanvasBitmap(const IBitmapSharedPtr &rSurface, const DeviceRef &rDevice)
Create a canvas bitmap for the given surface.
IBitmapSharedPtr mpBitmap
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
DeviceRef mpDevice
MUST hold here, too, since CanvasHelper only contains a raw pointer (without refcounting)
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void disposeThis() override
Dispose all internal references.
#define ENSURE_OR_THROW(c, m)
sal::systools::COMReference< IDirect3DDevice9 > mpDevice
BITMAPINFOHEADER bmiHeader
Gdiplus::BitmapData aBmpData
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
std::shared_ptr< IBitmap > IBitmapSharedPtr
std::shared_ptr< Gdiplus::Bitmap > BitmapSharedPtr