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)
73 bmiColors[
i] = { b,b,b,b };
90 aRes <<= reinterpret_cast<sal_Int64>( nullptr );
98 mpBitmap->getBitmap()->GetHBITMAP(Gdiplus::Color(), &aHBmp );
100 uno::Sequence< uno::Any >
args(1);
101 args[0] <<=
reinterpret_cast<sal_Int64
>(aHBmp);
109 HDC hScreenDC=
GetDC(
nullptr);
111 HBITMAP hBmpBitmap = CreateCompatibleBitmap( hScreenDC,
117 BITMAPINFOHEADER aBIH;
119 aBIH.biSize =
sizeof( BITMAPINFOHEADER );
120 aBIH.biWidth = aSize.getX();
121 aBIH.biHeight = -aSize.getY();
123 aBIH.biBitCount = 32;
124 aBIH.biCompression = BI_RGB;
127 aBIH.biSizeImage = 0;
128 aBIH.biXPelsPerMeter = 0;
129 aBIH.biYPelsPerMeter = 0;
131 aBIH.biClrImportant = 0;
134 aBmpData.Width = aSize.getX();
135 aBmpData.Height = aSize.getY();
136 aBmpData.Stride = 4*aBmpData.Width;
137 aBmpData.PixelFormat = PixelFormat32bppARGB;
138 aBmpData.Scan0 =
nullptr;
139 const Gdiplus::Rect aRect( 0,0,aSize.getX(),aSize.getY() );
141 if( Gdiplus::Ok != pGDIPlusBitmap->LockBits( &aRect,
142 Gdiplus::ImageLockModeRead,
143 PixelFormat32bppARGB,
152 SetDIBits( hScreenDC, hBmpBitmap, 0, aSize.getY(), aBmpData.Scan0,
reinterpret_cast<PBITMAPINFO
>(&aBIH), DIB_RGB_COLORS );
154 pGDIPlusBitmap->UnlockBits( &aBmpData );
156 uno::Sequence< uno::Any >
args(1);
157 args[0] <<=
reinterpret_cast<sal_Int64
>(hBmpBitmap);
172 static AlphaDIB aDIB;
176 HDC hScreenDC=
GetDC(
nullptr);
178 HBITMAP hBmpBitmap = CreateCompatibleBitmap( hScreenDC, aSize.getX(), aSize.getY() );
182 aDIB.bmiHeader.biSize =
sizeof( BITMAPINFOHEADER );
183 aDIB.bmiHeader.biWidth = aSize.getX();
184 aDIB.bmiHeader.biHeight = -aSize.getY();
185 aDIB.bmiHeader.biPlanes = 1;
186 aDIB.bmiHeader.biBitCount = 8;
187 aDIB.bmiHeader.biCompression = BI_RGB;
188 aDIB.bmiHeader.biSizeImage = 0;
189 aDIB.bmiHeader.biXPelsPerMeter = 0;
190 aDIB.bmiHeader.biYPelsPerMeter = 0;
191 aDIB.bmiHeader.biClrUsed = 0;
192 aDIB.bmiHeader.biClrImportant = 0;
195 aBmpData.Width = aSize.getX();
196 aBmpData.Height = aSize.getY();
197 aBmpData.Stride = 4*aBmpData.Width;
198 aBmpData.PixelFormat = PixelFormat32bppARGB;
199 aBmpData.Scan0 =
nullptr;
200 const Gdiplus::Rect aRect( 0,0,aSize.getX(),aSize.getY() );
202 if( Gdiplus::Ok != pGDIPlusBitmap->LockBits( &aRect,
203 Gdiplus::ImageLockModeRead,
204 PixelFormat32bppARGB,
212 const sal_Int32 nScanWidth((aSize.getX() + 3) & ~3);
213 std::unique_ptr<sal_uInt8[]> pAlphaBits(
new sal_uInt8[nScanWidth*aSize.getY()] );
216 for( sal_Int32
y=0;
y<aSize.getY(); ++
y )
218 sal_uInt8* pOutBits=pAlphaBits.get()+
y*nScanWidth;
219 for( sal_Int32
x=0;
x<aSize.getX(); ++
x )
221 *pOutBits++ = 255-*pInBits;
226 pGDIPlusBitmap->UnlockBits( &aBmpData );
229 SetDIBits( hScreenDC, hBmpBitmap, 0,
230 aSize.getY(), pAlphaBits.get(),
231 reinterpret_cast<PBITMAPINFO
>(&aDIB), DIB_RGB_COLORS );
233 uno::Sequence< uno::Any >
args(1);
234 args[0] <<=
reinterpret_cast<sal_Int64
>(hBmpBitmap);
247 return "DXCanvas.CanvasBitmap";
257 return {
"com.sun.star.rendering.CanvasBitmap" };
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
std::shared_ptr< IBitmap > IBitmapSharedPtr
IBitmapSharedPtr mpBitmap
CanvasBitmap(const IBitmapSharedPtr &rSurface, const DeviceRef &rDevice)
Create a canvas bitmap for the given surface.
COMReference< IDirect3DDevice9 > mpDevice
virtual css::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) override
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual void disposeThis() override
Dispose all internal references.
Gdiplus::BitmapData aBmpData
std::shared_ptr< Gdiplus::Bitmap > BitmapSharedPtr
#define ENSURE_OR_THROW(c, m)
BITMAPINFOHEADER bmiHeader
DeviceRef mpDevice
MUST hold here, too, since CanvasHelper only contains a raw pointer (without refcounting) ...
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override