16d739b60SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 36d739b60SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 46d739b60SAndrew Rist * or more contributor license agreements. See the NOTICE file 56d739b60SAndrew Rist * distributed with this work for additional information 66d739b60SAndrew Rist * regarding copyright ownership. The ASF licenses this file 76d739b60SAndrew Rist * to you under the Apache License, Version 2.0 (the 86d739b60SAndrew Rist * "License"); you may not use this file except in compliance 96d739b60SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 116d739b60SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 136d739b60SAndrew Rist * Unless required by applicable law or agreed to in writing, 146d739b60SAndrew Rist * software distributed under the License is distributed on an 156d739b60SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 166d739b60SAndrew Rist * KIND, either express or implied. See the License for the 176d739b60SAndrew Rist * specific language governing permissions and limitations 186d739b60SAndrew Rist * under the License. 19cdf0e10cSrcweir * 206d739b60SAndrew Rist *************************************************************/ 216d739b60SAndrew Rist 226d739b60SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_framework.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <classes/imagewrapper.hxx> 28cdf0e10cSrcweir #include <osl/mutex.hxx> 29cdf0e10cSrcweir #include <vcl/svapp.hxx> 30cdf0e10cSrcweir #include <vcl/bitmap.hxx> 31cdf0e10cSrcweir #include <vcl/bitmapex.hxx> 32cdf0e10cSrcweir #include <tools/stream.hxx> 33cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 34*45fd3b9aSArmin Le Grand #include <vcl/dibtools.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir using namespace com::sun::star::lang; 37cdf0e10cSrcweir using namespace com::sun::star::uno; 38cdf0e10cSrcweir 39cdf0e10cSrcweir namespace framework 40cdf0e10cSrcweir { 41cdf0e10cSrcweir 42cdf0e10cSrcweir static Sequence< sal_Int8 > impl_getStaticIdentifier() 43cdf0e10cSrcweir { 44cdf0e10cSrcweir static sal_uInt8 pGUID[16] = { 0x46, 0xAD, 0x69, 0xFB, 0xA7, 0xBE, 0x44, 0x83, 0xB2, 0xA7, 0xB3, 0xEC, 0x59, 0x4A, 0xB7, 0x00 }; 45cdf0e10cSrcweir static ::com::sun::star::uno::Sequence< sal_Int8 > seqID((sal_Int8*)pGUID,16) ; 46cdf0e10cSrcweir return seqID ; 47cdf0e10cSrcweir } 48cdf0e10cSrcweir 49cdf0e10cSrcweir 50cdf0e10cSrcweir ImageWrapper::ImageWrapper( const Image& aImage ) : ThreadHelpBase( &Application::GetSolarMutex() ) 51cdf0e10cSrcweir , m_aImage( aImage ) 52cdf0e10cSrcweir { 53cdf0e10cSrcweir } 54cdf0e10cSrcweir 55cdf0e10cSrcweir 56cdf0e10cSrcweir ImageWrapper::~ImageWrapper() 57cdf0e10cSrcweir { 58cdf0e10cSrcweir } 59cdf0e10cSrcweir 60cdf0e10cSrcweir 61cdf0e10cSrcweir Sequence< sal_Int8 > ImageWrapper::GetUnoTunnelId() 62cdf0e10cSrcweir { 63cdf0e10cSrcweir return impl_getStaticIdentifier(); 64cdf0e10cSrcweir } 65cdf0e10cSrcweir 66cdf0e10cSrcweir // XBitmap 67cdf0e10cSrcweir com::sun::star::awt::Size SAL_CALL ImageWrapper::getSize() throw ( RuntimeException ) 68cdf0e10cSrcweir { 69cdf0e10cSrcweir vos::OGuard aGuard( Application::GetSolarMutex() ); 70cdf0e10cSrcweir 71cdf0e10cSrcweir BitmapEx aBitmapEx( m_aImage.GetBitmapEx() ); 72cdf0e10cSrcweir Size aBitmapSize( aBitmapEx.GetSizePixel() ); 73cdf0e10cSrcweir 74cdf0e10cSrcweir return com::sun::star::awt::Size( aBitmapSize.Width(), aBitmapSize.Height() ); 75cdf0e10cSrcweir } 76cdf0e10cSrcweir 77cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL ImageWrapper::getDIB() throw ( RuntimeException ) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir vos::OGuard aGuard( Application::GetSolarMutex() ); 80cdf0e10cSrcweir 81cdf0e10cSrcweir SvMemoryStream aMem; 82*45fd3b9aSArmin Le Grand WriteDIB(m_aImage.GetBitmapEx().GetBitmap(), aMem, false, true); 83cdf0e10cSrcweir return Sequence< sal_Int8 >( (sal_Int8*) aMem.GetData(), aMem.Tell() ); 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL ImageWrapper::getMaskDIB() throw ( RuntimeException ) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir vos::OGuard aGuard( Application::GetSolarMutex() ); 89cdf0e10cSrcweir BitmapEx aBmpEx( m_aImage.GetBitmapEx() ); 90cdf0e10cSrcweir 91cdf0e10cSrcweir if ( aBmpEx.IsAlpha() ) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir SvMemoryStream aMem; 94*45fd3b9aSArmin Le Grand WriteDIB(aBmpEx.GetAlpha().GetBitmap(), aMem, false, true); 95cdf0e10cSrcweir return Sequence< sal_Int8 >( (sal_Int8*) aMem.GetData(), aMem.Tell() ); 96cdf0e10cSrcweir } 97cdf0e10cSrcweir else if ( aBmpEx.IsTransparent() ) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir SvMemoryStream aMem; 100*45fd3b9aSArmin Le Grand WriteDIB(aBmpEx.GetMask(), aMem, false, true); 101cdf0e10cSrcweir return Sequence< sal_Int8 >( (sal_Int8*) aMem.GetData(), aMem.Tell() ); 102cdf0e10cSrcweir } 103cdf0e10cSrcweir 104cdf0e10cSrcweir return Sequence< sal_Int8 >(); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir // XUnoTunnel 108cdf0e10cSrcweir sal_Int64 SAL_CALL ImageWrapper::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw ( RuntimeException ) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir if ( aIdentifier == impl_getStaticIdentifier() ) 111cdf0e10cSrcweir return reinterpret_cast< sal_Int64 >( this ); 112cdf0e10cSrcweir else 113cdf0e10cSrcweir return 0; 114cdf0e10cSrcweir } 115cdf0e10cSrcweir 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118