xref: /aoo41x/main/vcl/unx/generic/dtrans/bmp.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _DTRANS_BMP_HXX_
29 #define _DTRANS_BMP_HXX_
30 
31 #include "tools/prex.h"
32 #include <X11/Xatom.h>
33 #include <X11/keysym.h>
34 #include <X11/Xlib.h>
35 #include <X11/Xutil.h>
36 #include "tools/postx.h"
37 
38 #include <sal/types.h>
39 #include <com/sun/star/awt/XBitmap.hpp>
40 #include <cppuhelper/compbase1.hxx>
41 
42 
43 
44 namespace x11 {
45 
46 // helper methods
47 sal_uInt8* X11_getBmpFromPixmap( Display* pDisplay,
48                                  Drawable aDrawable,
49                                  Colormap aColormap,
50                                  sal_Int32& rOutSize );
51 
52 void X11_freeBmp( sal_uInt8* pBmp );
53 
54 class PixmapHolder
55 {
56     Display*		m_pDisplay;
57     Colormap		m_aColormap;
58     Pixmap			m_aPixmap;
59     Pixmap			m_aBitmap;
60     XVisualInfo		m_aInfo;
61 
62     int				m_nRedShift, m_nRedShift2;
63     int				m_nGreenShift, m_nGreenShift2;
64     int				m_nBlueShift, m_nBlueShift2;
65     unsigned long	m_nBlueShift2Mask, m_nRedShift2Mask, m_nGreenShift2Mask;
66 
67     // these expect data pointers to bitmapinfo header
68     void setBitmapDataTC( const sal_uInt8* pData, XImage* pImage );
69     void setBitmapDataTCDither( const sal_uInt8* pData, XImage* pImage );
70     void setBitmapDataPalette( const sal_uInt8* pData, XImage* pImage );
71 
72     unsigned long getTCPixel( sal_uInt8 r, sal_uInt8 g, sal_uInt8 b ) const;
73 public:
74     PixmapHolder( Display* pDisplay );
75     ~PixmapHolder();
76 
77     // accepts bitmap file (including bitmap file header)
78     Pixmap setBitmapData( const sal_uInt8* pData );
79     bool needsConversion( const sal_uInt8* pData );
80 
81     Colormap getColormap() const { return m_aColormap; }
82     Pixmap getPixmap() const { return m_aPixmap; }
83     Pixmap getBitmap() const { return m_aBitmap; }
84     VisualID getVisualID() const { return m_aInfo.visualid; }
85     int getClass() const { return m_aInfo.c_class; }
86     int getDepth() const { return m_aInfo.depth; }
87 };
88 
89 class BmpTransporter :
90         public cppu::WeakImplHelper1< com::sun::star::awt::XBitmap >
91 {
92     com::sun::star::uno::Sequence<sal_Int8>			m_aBM;
93     com::sun::star::awt::Size						m_aSize;
94 public:
95     BmpTransporter( const com::sun::star::uno::Sequence<sal_Int8>& rBmp );
96     virtual  ~BmpTransporter();
97 
98     virtual com::sun::star::awt::Size SAL_CALL getSize() throw();
99     virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getDIB() throw();
100     virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getMaskDIB() throw();
101 };
102 
103 }
104 
105 #endif
106