12123d757SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 32123d757SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 42123d757SAndrew Rist * or more contributor license agreements. See the NOTICE file 52123d757SAndrew Rist * distributed with this work for additional information 62123d757SAndrew Rist * regarding copyright ownership. The ASF licenses this file 72123d757SAndrew Rist * to you under the Apache License, Version 2.0 (the 82123d757SAndrew Rist * "License"); you may not use this file except in compliance 92123d757SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 112123d757SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 132123d757SAndrew Rist * Unless required by applicable law or agreed to in writing, 142123d757SAndrew Rist * software distributed under the License is distributed on an 152123d757SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 162123d757SAndrew Rist * KIND, either express or implied. See the License for the 172123d757SAndrew Rist * specific language governing permissions and limitations 182123d757SAndrew Rist * under the License. 19cdf0e10cSrcweir * 202123d757SAndrew Rist *************************************************************/ 212123d757SAndrew Rist 222123d757SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _SV_SALBMP_H 25cdf0e10cSrcweir #define _SV_SALBMP_H 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <tools/gen.hxx> 28cdf0e10cSrcweir #include <win/wincomp.hxx> 29cdf0e10cSrcweir #include <salbmp.hxx> 30*5f27b83cSArmin Le Grand #include <boost/shared_ptr.hpp> 31cdf0e10cSrcweir 32cdf0e10cSrcweir // -------------- 33cdf0e10cSrcweir // - SalBitmap - 34cdf0e10cSrcweir // -------------- 35cdf0e10cSrcweir 36cdf0e10cSrcweir struct BitmapBuffer; 37cdf0e10cSrcweir class BitmapColor; 38cdf0e10cSrcweir class BitmapPalette; 39cdf0e10cSrcweir class SalGraphics; 40*5f27b83cSArmin Le Grand namespace Gdiplus { class Bitmap; } 41*5f27b83cSArmin Le Grand typedef boost::shared_ptr< Gdiplus::Bitmap > GdiPlusBmpPtr; 42cdf0e10cSrcweir 43cdf0e10cSrcweir class WinSalBitmap : public SalBitmap 44cdf0e10cSrcweir { 45cdf0e10cSrcweir private: 46*5f27b83cSArmin Le Grand friend class GdiPlusBuffer; // allow buffer to remove maGdiPlusBitmap eventually 47cdf0e10cSrcweir 48cdf0e10cSrcweir Size maSize; 49cdf0e10cSrcweir HGLOBAL mhDIB; 50cdf0e10cSrcweir HBITMAP mhDDB; 51*5f27b83cSArmin Le Grand 52*5f27b83cSArmin Le Grand // the buffered evtl. used Gdiplus::Bitmap instance. It is managed by 53*5f27b83cSArmin Le Grand // GdiPlusBuffer. To make this safe, it is only handed out as shared 54*5f27b83cSArmin Le Grand // pointer; the GdiPlusBuffer may delete the local instance 55*5f27b83cSArmin Le Grand GdiPlusBmpPtr maGdiPlusBitmap; 56*5f27b83cSArmin Le Grand 57cdf0e10cSrcweir sal_uInt16 mnBitCount; 58cdf0e10cSrcweir 59*5f27b83cSArmin Le Grand Gdiplus::Bitmap* ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlphaSource); 60*5f27b83cSArmin Le Grand Gdiplus::Bitmap* ImplCreateGdiPlusBitmap(); 61*5f27b83cSArmin Le Grand 62cdf0e10cSrcweir public: 63cdf0e10cSrcweir 64cdf0e10cSrcweir HGLOBAL ImplGethDIB() const { return mhDIB; } 65cdf0e10cSrcweir HBITMAP ImplGethDDB() const { return mhDDB; } 66cdf0e10cSrcweir 67*5f27b83cSArmin Le Grand GdiPlusBmpPtr ImplGetGdiPlusBitmap(const WinSalBitmap* pAlphaSource = 0) const; 68*5f27b83cSArmin Le Grand 69cdf0e10cSrcweir static HGLOBAL ImplCreateDIB( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal ); 70cdf0e10cSrcweir static HANDLE ImplCopyDIBOrDDB( HANDLE hHdl, bool bDIB ); 71cdf0e10cSrcweir static sal_uInt16 ImplGetDIBColorCount( HGLOBAL hDIB ); 72cdf0e10cSrcweir static void ImplDecodeRLEBuffer( const BYTE* pSrcBuf, BYTE* pDstBuf, 73cdf0e10cSrcweir const Size& rSizePixel, bool bRLE4 ); 74cdf0e10cSrcweir 75cdf0e10cSrcweir public: 76cdf0e10cSrcweir 77cdf0e10cSrcweir WinSalBitmap(); 78cdf0e10cSrcweir virtual ~WinSalBitmap(); 79cdf0e10cSrcweir 80cdf0e10cSrcweir public: 81cdf0e10cSrcweir 82cdf0e10cSrcweir bool Create( HANDLE hBitmap, bool bDIB, bool bCopyHandle ); 83cdf0e10cSrcweir virtual bool Create( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal ); 84cdf0e10cSrcweir virtual bool Create( const SalBitmap& rSalBmpImpl ); 85cdf0e10cSrcweir virtual bool Create( const SalBitmap& rSalBmpImpl, SalGraphics* pGraphics ); 86cdf0e10cSrcweir virtual bool Create( const SalBitmap& rSalBmpImpl, sal_uInt16 nNewBitCount ); 87cdf0e10cSrcweir 88cdf0e10cSrcweir virtual void Destroy(); 89cdf0e10cSrcweir 90cdf0e10cSrcweir virtual Size GetSize() const { return maSize; } 91cdf0e10cSrcweir virtual sal_uInt16 GetBitCount() const { return mnBitCount; } 92cdf0e10cSrcweir 93cdf0e10cSrcweir virtual BitmapBuffer* AcquireBuffer( bool bReadOnly ); 94cdf0e10cSrcweir virtual void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ); 95cdf0e10cSrcweir virtual bool GetSystemData( BitmapSystemData& rData ); 96cdf0e10cSrcweir }; 97cdf0e10cSrcweir 98cdf0e10cSrcweir #endif // _SV_SALBMP_HXX 99