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