Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef _DTRANS_BMP_HXX_
21 : : #define _DTRANS_BMP_HXX_
22 : :
23 : : #include "tools/prex.h"
24 : : #include <X11/Xatom.h>
25 : : #include <X11/keysym.h>
26 : : #include <X11/Xlib.h>
27 : : #include <X11/Xutil.h>
28 : : #include "tools/postx.h"
29 : :
30 : : #include <sal/types.h>
31 : : #include <com/sun/star/awt/XBitmap.hpp>
32 : : #include <cppuhelper/compbase1.hxx>
33 : :
34 : :
35 : :
36 : : namespace x11 {
37 : :
38 : : // helper methods
39 : : sal_uInt8* X11_getBmpFromPixmap( Display* pDisplay,
40 : : Drawable aDrawable,
41 : : Colormap aColormap,
42 : : sal_Int32& rOutSize );
43 : :
44 : : void X11_freeBmp( sal_uInt8* pBmp );
45 : :
46 : : class PixmapHolder
47 : : {
48 : : Display* m_pDisplay;
49 : : Colormap m_aColormap;
50 : : Pixmap m_aPixmap;
51 : : Pixmap m_aBitmap;
52 : : XVisualInfo m_aInfo;
53 : :
54 : : int m_nRedShift, m_nRedShift2;
55 : : int m_nGreenShift, m_nGreenShift2;
56 : : int m_nBlueShift, m_nBlueShift2;
57 : : unsigned long m_nBlueShift2Mask, m_nRedShift2Mask, m_nGreenShift2Mask;
58 : :
59 : : // these expect data pointers to bitmapinfo header
60 : : void setBitmapDataTC( const sal_uInt8* pData, XImage* pImage );
61 : : void setBitmapDataTCDither( const sal_uInt8* pData, XImage* pImage );
62 : : void setBitmapDataPalette( const sal_uInt8* pData, XImage* pImage );
63 : :
64 : : unsigned long getTCPixel( sal_uInt8 r, sal_uInt8 g, sal_uInt8 b ) const;
65 : : public:
66 : : PixmapHolder( Display* pDisplay );
67 : : ~PixmapHolder();
68 : :
69 : : // accepts bitmap file (including bitmap file header)
70 : : Pixmap setBitmapData( const sal_uInt8* pData );
71 : : bool needsConversion( const sal_uInt8* pData );
72 : :
73 : 0 : Colormap getColormap() const { return m_aColormap; }
74 : 0 : Pixmap getPixmap() const { return m_aPixmap; }
75 : 0 : Pixmap getBitmap() const { return m_aBitmap; }
76 : 0 : VisualID getVisualID() const { return m_aInfo.visualid; }
77 : : int getClass() const { return m_aInfo.c_class; }
78 : 0 : int getDepth() const { return m_aInfo.depth; }
79 : : };
80 : :
81 : : class BmpTransporter :
82 : : public cppu::WeakImplHelper1< com::sun::star::awt::XBitmap >
83 : : {
84 : : com::sun::star::uno::Sequence<sal_Int8> m_aBM;
85 : : com::sun::star::awt::Size m_aSize;
86 : : public:
87 : : BmpTransporter( const com::sun::star::uno::Sequence<sal_Int8>& rBmp );
88 : : virtual ~BmpTransporter();
89 : :
90 : : virtual com::sun::star::awt::Size SAL_CALL getSize() throw();
91 : : virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getDIB() throw();
92 : : virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getMaskDIB() throw();
93 : : };
94 : :
95 : : }
96 : :
97 : : #endif
98 : :
99 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|