xref: /aoo42x/main/vcl/unx/generic/dtrans/bmp.hxx (revision ebfcd9af)
1*ebfcd9afSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ebfcd9afSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ebfcd9afSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ebfcd9afSAndrew Rist  * distributed with this work for additional information
6*ebfcd9afSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ebfcd9afSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ebfcd9afSAndrew Rist  * "License"); you may not use this file except in compliance
9*ebfcd9afSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ebfcd9afSAndrew Rist  *
11*ebfcd9afSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ebfcd9afSAndrew Rist  *
13*ebfcd9afSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ebfcd9afSAndrew Rist  * software distributed under the License is distributed on an
15*ebfcd9afSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ebfcd9afSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ebfcd9afSAndrew Rist  * specific language governing permissions and limitations
18*ebfcd9afSAndrew Rist  * under the License.
19*ebfcd9afSAndrew Rist  *
20*ebfcd9afSAndrew Rist  *************************************************************/
21*ebfcd9afSAndrew Rist 
22*ebfcd9afSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _DTRANS_BMP_HXX_
25cdf0e10cSrcweir #define _DTRANS_BMP_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "tools/prex.h"
28cdf0e10cSrcweir #include <X11/Xatom.h>
29cdf0e10cSrcweir #include <X11/keysym.h>
30cdf0e10cSrcweir #include <X11/Xlib.h>
31cdf0e10cSrcweir #include <X11/Xutil.h>
32cdf0e10cSrcweir #include "tools/postx.h"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <sal/types.h>
35cdf0e10cSrcweir #include <com/sun/star/awt/XBitmap.hpp>
36cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir 
39cdf0e10cSrcweir 
40cdf0e10cSrcweir namespace x11 {
41cdf0e10cSrcweir 
42cdf0e10cSrcweir // helper methods
43cdf0e10cSrcweir sal_uInt8* X11_getBmpFromPixmap( Display* pDisplay,
44cdf0e10cSrcweir                                  Drawable aDrawable,
45cdf0e10cSrcweir                                  Colormap aColormap,
46cdf0e10cSrcweir                                  sal_Int32& rOutSize );
47cdf0e10cSrcweir 
48cdf0e10cSrcweir void X11_freeBmp( sal_uInt8* pBmp );
49cdf0e10cSrcweir 
50cdf0e10cSrcweir class PixmapHolder
51cdf0e10cSrcweir {
52cdf0e10cSrcweir     Display*		m_pDisplay;
53cdf0e10cSrcweir     Colormap		m_aColormap;
54cdf0e10cSrcweir     Pixmap			m_aPixmap;
55cdf0e10cSrcweir     Pixmap			m_aBitmap;
56cdf0e10cSrcweir     XVisualInfo		m_aInfo;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir     int				m_nRedShift, m_nRedShift2;
59cdf0e10cSrcweir     int				m_nGreenShift, m_nGreenShift2;
60cdf0e10cSrcweir     int				m_nBlueShift, m_nBlueShift2;
61cdf0e10cSrcweir     unsigned long	m_nBlueShift2Mask, m_nRedShift2Mask, m_nGreenShift2Mask;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     // these expect data pointers to bitmapinfo header
64cdf0e10cSrcweir     void setBitmapDataTC( const sal_uInt8* pData, XImage* pImage );
65cdf0e10cSrcweir     void setBitmapDataTCDither( const sal_uInt8* pData, XImage* pImage );
66cdf0e10cSrcweir     void setBitmapDataPalette( const sal_uInt8* pData, XImage* pImage );
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     unsigned long getTCPixel( sal_uInt8 r, sal_uInt8 g, sal_uInt8 b ) const;
69cdf0e10cSrcweir public:
70cdf0e10cSrcweir     PixmapHolder( Display* pDisplay );
71cdf0e10cSrcweir     ~PixmapHolder();
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     // accepts bitmap file (including bitmap file header)
74cdf0e10cSrcweir     Pixmap setBitmapData( const sal_uInt8* pData );
75cdf0e10cSrcweir     bool needsConversion( const sal_uInt8* pData );
76cdf0e10cSrcweir 
getColormap() const77cdf0e10cSrcweir     Colormap getColormap() const { return m_aColormap; }
getPixmap() const78cdf0e10cSrcweir     Pixmap getPixmap() const { return m_aPixmap; }
getBitmap() const79cdf0e10cSrcweir     Pixmap getBitmap() const { return m_aBitmap; }
getVisualID() const80cdf0e10cSrcweir     VisualID getVisualID() const { return m_aInfo.visualid; }
getClass() const81cdf0e10cSrcweir     int getClass() const { return m_aInfo.c_class; }
getDepth() const82cdf0e10cSrcweir     int getDepth() const { return m_aInfo.depth; }
83cdf0e10cSrcweir };
84cdf0e10cSrcweir 
85cdf0e10cSrcweir class BmpTransporter :
86cdf0e10cSrcweir         public cppu::WeakImplHelper1< com::sun::star::awt::XBitmap >
87cdf0e10cSrcweir {
88cdf0e10cSrcweir     com::sun::star::uno::Sequence<sal_Int8>			m_aBM;
89cdf0e10cSrcweir     com::sun::star::awt::Size						m_aSize;
90cdf0e10cSrcweir public:
91cdf0e10cSrcweir     BmpTransporter( const com::sun::star::uno::Sequence<sal_Int8>& rBmp );
92cdf0e10cSrcweir     virtual  ~BmpTransporter();
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     virtual com::sun::star::awt::Size SAL_CALL getSize() throw();
95cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getDIB() throw();
96cdf0e10cSrcweir     virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getMaskDIB() throw();
97cdf0e10cSrcweir };
98cdf0e10cSrcweir 
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
101cdf0e10cSrcweir #endif
102