1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <classes/imagewrapper.hxx>
21 #include <osl/mutex.hxx>
22 #include <vcl/svapp.hxx>
23 #include <vcl/bitmap.hxx>
24 #include <vcl/bitmapex.hxx>
25 #include <tools/stream.hxx>
26 #include <cppuhelper/typeprovider.hxx>
27 #include <vcl/dibtools.hxx>
29 using namespace com::sun::star::lang
;
30 using namespace com::sun::star::uno
;
35 static Sequence
< sal_Int8
> impl_getStaticIdentifier()
37 static const sal_uInt8 pGUID
[16] = { 0x46, 0xAD, 0x69, 0xFB, 0xA7, 0xBE, 0x44, 0x83, 0xB2, 0xA7, 0xB3, 0xEC, 0x59, 0x4A, 0xB7, 0x00 };
38 static ::com::sun::star::uno::Sequence
< sal_Int8
> seqID(reinterpret_cast<const sal_Int8
*>(pGUID
), 16);
42 ImageWrapper::ImageWrapper( const Image
& aImage
) : m_aImage( aImage
)
46 ImageWrapper::~ImageWrapper()
50 Sequence
< sal_Int8
> ImageWrapper::GetUnoTunnelId()
52 return impl_getStaticIdentifier();
56 com::sun::star::awt::Size SAL_CALL
ImageWrapper::getSize() throw ( RuntimeException
, std::exception
)
58 SolarMutexGuard aGuard
;
60 BitmapEx
aBitmapEx( m_aImage
.GetBitmapEx() );
61 Size
aBitmapSize( aBitmapEx
.GetSizePixel() );
63 return com::sun::star::awt::Size( aBitmapSize
.Width(), aBitmapSize
.Height() );
66 Sequence
< sal_Int8
> SAL_CALL
ImageWrapper::getDIB() throw ( RuntimeException
, std::exception
)
68 SolarMutexGuard aGuard
;
71 WriteDIB(m_aImage
.GetBitmapEx().GetBitmap(), aMem
, false, true);
72 return Sequence
< sal_Int8
>( static_cast<sal_Int8
const *>(aMem
.GetData()), aMem
.Tell() );
75 Sequence
< sal_Int8
> SAL_CALL
ImageWrapper::getMaskDIB() throw ( RuntimeException
, std::exception
)
77 SolarMutexGuard aGuard
;
78 BitmapEx
aBmpEx( m_aImage
.GetBitmapEx() );
80 if ( aBmpEx
.IsAlpha() )
83 WriteDIB(aBmpEx
.GetAlpha().GetBitmap(), aMem
, false, true);
84 return Sequence
< sal_Int8
>( static_cast<sal_Int8
const *>(aMem
.GetData()), aMem
.Tell() );
86 else if ( aBmpEx
.IsTransparent() )
89 WriteDIB(aBmpEx
.GetMask(), aMem
, false, true);
90 return Sequence
< sal_Int8
>( static_cast<sal_Int8
const *>(aMem
.GetData()), aMem
.Tell() );
93 return Sequence
< sal_Int8
>();
97 sal_Int64 SAL_CALL
ImageWrapper::getSomething( const Sequence
< sal_Int8
>& aIdentifier
) throw ( RuntimeException
, std::exception
)
99 if ( aIdentifier
== impl_getStaticIdentifier() )
100 return reinterpret_cast< sal_Int64
>( this );
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */