24 #include <com/sun/star/graphic/GraphicType.hpp>
25 #include <com/sun/star/graphic/XGraphicTransformer.hpp>
43 Graphic::~Graphic() noexcept
47 void Graphic::init(const ::Graphic& rGraphic)
57 aAny <<= uno::Reference< graphic::XGraphic >( this );
59 aAny <<= uno::Reference< awt::XBitmap >(
this );
61 aAny <<= uno::Reference< lang::XUnoTunnel >(
this);
71 if ( !aReturn.hasValue() )
76 void SAL_CALL Graphic::acquire()
82 void SAL_CALL Graphic::release() noexcept
87 OUString SAL_CALL Graphic::getImplementationName()
89 return "com.sun.star.comp.graphic.Graphic";
92 sal_Bool SAL_CALL Graphic::supportsService(
const OUString& rServiceName )
97 uno::Sequence< OUString > SAL_CALL Graphic::getSupportedServiceNames()
100 const uno::Sequence< OUString > aNew {
"com.sun.star.graphic.Graphic" };
101 sal_Int32 nOldCount = aRet.getLength();
103 aRet.realloc( nOldCount + aNew.getLength() );
105 std::copy(aNew.begin(), aNew.end(), std::next(aRet.getArray(), nOldCount));
110 uno::Sequence< uno::Type > SAL_CALL Graphic::getTypes()
119 uno::Sequence< sal_Int8 > SAL_CALL Graphic::getImplementationId()
121 return css::uno::Sequence<sal_Int8>();
126 sal_Int8 cRet = graphic::GraphicType::EMPTY;
131 : graphic::GraphicType::VECTOR;
139 awt::Size SAL_CALL Graphic::getSize()
148 return awt::Size(aVclSize.
Width(), aVclSize.
Height());
151 uno::Sequence<sal_Int8> SAL_CALL Graphic::getDIB()
160 return css::uno::Sequence<sal_Int8>(
static_cast<sal_Int8 const *
>(aMemoryStream.
GetData()), aMemoryStream.
Tell());
164 return uno::Sequence<sal_Int8>();
168 uno::Sequence<sal_Int8> SAL_CALL Graphic::getMaskDIB()
177 return css::uno::Sequence<sal_Int8>(
static_cast<sal_Int8 const *
>(aMemoryStream.
GetData()), aMemoryStream.
Tell() );
181 return uno::Sequence<sal_Int8>();
185 sal_Int64 SAL_CALL Graphic::getSomething(
const uno::Sequence< sal_Int8 >& rId )
192 uno::Reference< graphic::XGraphic > SAL_CALL Graphic::colorChange(
193 const uno::Reference< graphic::XGraphic >& rxGraphic, sal_Int32 nColorFrom,
sal_Int8 nTolerance, sal_Int32 nColorTo,
sal_Int8 nAlphaTo )
198 BitmapColor aBmpColorFrom(static_cast< sal_uInt8 >(nColorFrom), static_cast< sal_uInt8 >(nColorFrom >> 8), static_cast< sal_uInt8 >(nColorFrom >> 16));
199 BitmapColor aBmpColorTo( static_cast< sal_uInt8 >(nColorTo), static_cast< sal_uInt8 >(nColorTo >> 8), static_cast< sal_uInt8 >(nColorTo >> 16));
201 Color aColorFrom(aBmpColorFrom);
202 Color aColorTo(aBmpColorTo);
210 BitmapEx aBitmapEx(aGraphic.GetBitmapEx());
212 if (aBitmapEx.IsAlpha())
215 aBitmapEx.Replace(aColorFrom, aColorTo, nTolerance);
220 if ((nAlphaTo == 0) || (nAlphaTo == sal::static_int_cast< sal_Int8 >(0xff)))
222 Bitmap aBitmap(aBitmapEx.GetBitmap());
223 Bitmap aMask(aBitmap.CreateMask(aColorFrom, nTolerance));
224 aBitmap.
Replace(aColorFrom, aColorTo, nTolerance);
229 aBitmapEx.setAlphaFrom(cIndexFrom, nAlphaTo);
230 aBitmapEx.Replace(aColorFrom, aColorTo, nTolerance);
236 aReturnGraphic.setOriginURL(aGraphic.getOriginURL());
237 return aReturnGraphic.GetXGraphic();
240 uno::Reference< graphic::XGraphic > SAL_CALL Graphic::applyDuotone(
241 const uno::Reference< graphic::XGraphic >& rxGraphic, sal_Int32 nColorOne, sal_Int32 nColorTwo )
246 BitmapEx aBitmapEx( aGraphic.GetBitmapEx() );
249 BitmapEx aTmpBmpEx(aBitmapEx.GetBitmap());
256 aReturnGraphic.setOriginURL(aGraphic.getOriginURL());
257 return aReturnGraphic.GetXGraphic();
260 uno::Reference< graphic::XGraphic > SAL_CALL Graphic::applyBrightnessContrast(
261 const uno::Reference< graphic::XGraphic >& rxGraphic, sal_Int32 nBrightness, sal_Int32 nContrast,
sal_Bool mso )
266 BitmapEx aBitmapEx(aGraphic.GetBitmapEx());
267 aBitmapEx.
Adjust(nBrightness, nContrast, 0, 0, 0, 0,
false, mso);
269 aReturnGraphic.setOriginURL(aGraphic.getOriginURL());
270 return aReturnGraphic.GetXGraphic();
sal_uInt8 GetIndex() const
bool Adjust(short nLuminancePercent, short nContrastPercent, short nChannelRPercent, short nChannelGPercent, short nChannelBPercent, double fGamma=1.0, bool bInvert=false, bool msoBrightness=false)
Change various global color characteristics.
Size GetSizePixel(const OutputDevice *pRefDevice=nullptr) const
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &rType) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual void SAL_CALL release() noexcept override
constexpr tools::Long Width() const
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
static bool Filter(BitmapEx &rBmpEx, BitmapFilter const &rFilter)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
GraphicType GetType() const
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
virtual void SAL_CALL acquire() noexcept override
Bitmap GetBitmap(Color aTransparentReplaceColor) const
AlphaMask GetAlpha() const
constexpr tools::Long Height() const
sal_Int64 getSomethingImpl(const css::uno::Sequence< sal_Int8 > &rId, T *pThis, FallbackToGetSomethingOf< Base >={})
void init(const ::Graphic &rGraphic)
css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
void setAlphaFrom(sal_uInt8 cIndexFrom, sal_Int8 nAlphaTo)
bool Replace(const Bitmap &rMask, const Color &rReplaceColor)
Replace all pixel where the given mask is on with the specified color.
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override