LibreOffice Module vcl (master) 1
canvastools.cxx
Go to the documentation of this file.
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#include <com/sun/star/geometry/RealSize2D.hpp>
21#include <com/sun/star/geometry/IntegerSize2D.hpp>
22#include <com/sun/star/geometry/IntegerPoint2D.hpp>
23#include <com/sun/star/geometry/IntegerRectangle2D.hpp>
24
25#include <com/sun/star/rendering/ColorSpaceType.hpp>
26#include <com/sun/star/rendering/RenderingIntent.hpp>
27#include <com/sun/star/rendering/VolatileContentDestroyedException.hpp>
28#include <com/sun/star/rendering/XBitmap.hpp>
29#include <com/sun/star/rendering/IntegerBitmapLayout.hpp>
30#include <com/sun/star/rendering/ColorComponentTag.hpp>
31
37
38#include <sal/log.hxx>
39#include <tools/helpers.hxx>
41
42#include <vcl/bitmapex.hxx>
43
44#include <canvasbitmap.hxx>
45#include <vcl/canvastools.hxx>
47
48using namespace ::com::sun::star;
49
51{
52 uno::Reference< rendering::XBitmap > xBitmapFromBitmapEx(const ::BitmapEx& inputBitmap )
53 {
54 SAL_INFO( "vcl.helper", "vcl::unotools::xBitmapFromBitmapEx()" );
55
56 return new vcl::unotools::VclCanvasBitmap( inputBitmap );
57 }
58
59 namespace
60 {
61 bool equalsLayout( const rendering::IntegerBitmapLayout& rLHS,
62 const rendering::IntegerBitmapLayout& rRHS )
63 {
64 return
65 rLHS.ScanLineBytes == rRHS.ScanLineBytes &&
66 rLHS.ScanLineStride == rRHS.ScanLineStride &&
67 rLHS.PlaneStride == rRHS.PlaneStride &&
68 rLHS.ColorSpace == rRHS.ColorSpace &&
69 rLHS.Palette == rRHS.Palette &&
70 rLHS.IsMsbFirst == rRHS.IsMsbFirst;
71 }
72 bool readBmp( sal_Int32 nWidth,
73 sal_Int32 nHeight,
74 const rendering::IntegerBitmapLayout& rLayout,
75 const uno::Reference< rendering::XIntegerReadOnlyBitmap >& xInputBitmap,
76 BitmapScopedWriteAccess& rWriteAcc,
77 BitmapScopedWriteAccess& rAlphaAcc )
78 {
79 rendering::IntegerBitmapLayout aCurrLayout;
80 geometry::IntegerRectangle2D aRect;
81 uno::Sequence<sal_Int8> aPixelData;
82 uno::Sequence<rendering::RGBColor> aRGBColors;
83 uno::Sequence<rendering::ARGBColor> aARGBColors;
84
85 for( aRect.Y1=0; aRect.Y1<nHeight; ++aRect.Y1 )
86 {
87 aRect.X1 = 0; aRect.X2 = nWidth; aRect.Y2 = aRect.Y1+1;
88 try
89 {
90 aPixelData = xInputBitmap->getData(aCurrLayout,aRect);
91 }
92 catch( rendering::VolatileContentDestroyedException& )
93 {
94 // re-read bmp from the start
95 return false;
96 }
97 if( !equalsLayout(aCurrLayout, rLayout) )
98 return false; // re-read bmp from the start
99
100 Scanline pScanline = rWriteAcc->GetScanline( aRect.Y1 );
101 if( rAlphaAcc.get() )
102 {
103 Scanline pScanlineAlpha = rAlphaAcc->GetScanline( aRect.Y1 );
104 // read ARGB color
105 aARGBColors = rLayout.ColorSpace->convertIntegerToARGB(aPixelData);
106
107 if( rWriteAcc->HasPalette() )
108 {
109 for( sal_Int32 x=0; x<nWidth; ++x )
110 {
111 const rendering::ARGBColor& rColor=aARGBColors[x];
112 rWriteAcc->SetPixelOnData( pScanline, x,
113 BitmapColor(static_cast<sal_uInt8>(rWriteAcc->GetBestPaletteIndex(
114 BitmapColor( toByteColor(rColor.Red),
115 toByteColor(rColor.Green),
116 toByteColor(rColor.Blue))))) );
117 rAlphaAcc->SetPixelOnData( pScanlineAlpha, x,
118 BitmapColor( 255 - toByteColor(rColor.Alpha) ));
119 }
120 }
121 else
122 {
123 for( sal_Int32 x=0; x<nWidth; ++x )
124 {
125 const rendering::ARGBColor& rColor=aARGBColors[x];
126 rWriteAcc->SetPixelOnData( pScanline, x,
127 BitmapColor( toByteColor(rColor.Red),
128 toByteColor(rColor.Green),
129 toByteColor(rColor.Blue) ));
130 rAlphaAcc->SetPixelOnData( pScanlineAlpha, x,
131 BitmapColor( 255 - toByteColor(rColor.Alpha) ));
132 }
133 }
134 }
135 else
136 {
137 // read RGB color
138 aRGBColors = rLayout.ColorSpace->convertIntegerToRGB(aPixelData);
139 if( rWriteAcc->HasPalette() )
140 {
141 for( sal_Int32 x=0; x<nWidth; ++x )
142 {
143 const rendering::RGBColor& rColor=aRGBColors[x];
144 rWriteAcc->SetPixelOnData( pScanline, x,
145 BitmapColor(static_cast<sal_uInt8>(rWriteAcc->GetBestPaletteIndex(
146 BitmapColor( toByteColor(rColor.Red),
147 toByteColor(rColor.Green),
148 toByteColor(rColor.Blue))))) );
149 }
150 }
151 else
152 {
153 for( sal_Int32 x=0; x<nWidth; ++x )
154 {
155 const rendering::RGBColor& rColor=aRGBColors[x];
156 rWriteAcc->SetPixelOnData( pScanline, x,
157 BitmapColor( toByteColor(rColor.Red),
158 toByteColor(rColor.Green),
159 toByteColor(rColor.Blue) ));
160 }
161 }
162 }
163 }
164
165 return true;
166 }
167 }
168
169 ::BitmapEx bitmapExFromXBitmap( const uno::Reference< rendering::XIntegerReadOnlyBitmap >& xInputBitmap )
170 {
171 SAL_INFO( "vcl.helper", "vcl::unotools::bitmapExFromXBitmap()" );
172
173 if( !xInputBitmap.is() )
174 return ::BitmapEx();
175
176 // tunnel directly for known implementation
177 VclCanvasBitmap* pImplBitmap = dynamic_cast<VclCanvasBitmap*>(xInputBitmap.get());
178 if( pImplBitmap )
179 return pImplBitmap->getBitmapEx();
180
181 // retrieve data via UNO interface
182
183 // volatile bitmaps are a bit more complicated to read
184 // from...
185
186 // loop a few times, until successfully read (for XVolatileBitmap)
187 for( int i=0; i<10; ++i )
188 {
189 sal_Int32 nDepth=0;
190 sal_Int32 nAlphaDepth=0;
191 const rendering::IntegerBitmapLayout aLayout(
192 xInputBitmap->getMemoryLayout());
193
194 OSL_ENSURE(aLayout.ColorSpace.is(),
195 "Cannot convert image without color space!");
196 if( !aLayout.ColorSpace.is() )
197 return ::BitmapEx();
198
199 nDepth = aLayout.ColorSpace->getBitsPerPixel();
200
201 if( xInputBitmap->hasAlpha() )
202 {
203 // determine alpha channel depth
204 const uno::Sequence<sal_Int8> aTags(
205 aLayout.ColorSpace->getComponentTags() );
206 const sal_Int8* pStart(aTags.getConstArray());
207 const std::size_t nLen(aTags.getLength());
208 const sal_Int8* pEnd(pStart+nLen);
209
210 const std::ptrdiff_t nAlphaIndex =
211 std::find(pStart,pEnd,
212 rendering::ColorComponentTag::ALPHA) - pStart;
213
214 if( nAlphaIndex < sal::static_int_cast<std::ptrdiff_t>(nLen) )
215 {
216 nAlphaDepth = aLayout.ColorSpace->getComponentBitCounts()[nAlphaIndex] > 1 ? 8 : 1;
217 nDepth -= nAlphaDepth;
218 }
219 }
220
221 BitmapPalette aPalette;
222 if( aLayout.Palette.is() )
223 {
224 uno::Reference< rendering::XColorSpace > xPaletteColorSpace(
225 aLayout.Palette->getColorSpace());
226 ENSURE_OR_THROW(xPaletteColorSpace.is(),
227 "Palette without color space");
228
229 const sal_Int32 nEntryCount( aLayout.Palette->getNumberOfEntries() );
230 if( nEntryCount <= 256 )
231 {
232 if( nEntryCount <= 2 )
233 nDepth = 1;
234 else
235 nDepth = 8;
236
237 const sal_uInt16 nPaletteEntries(
238 sal::static_int_cast<sal_uInt16>(
239 std::min(sal_Int32(255), nEntryCount)));
240
241 // copy palette entries
242 aPalette.SetEntryCount(nPaletteEntries);
243 uno::Reference<rendering::XBitmapPalette> xPalette( aLayout.Palette );
244 uno::Reference<rendering::XColorSpace> xPalColorSpace( xPalette->getColorSpace() );
245
246 uno::Sequence<double> aPaletteEntry;
247 for( sal_uInt16 j=0; j<nPaletteEntries; ++j )
248 {
249 if( !xPalette->getIndex(aPaletteEntry,j) &&
250 nAlphaDepth == 0 )
251 {
252 nAlphaDepth = 1;
253 }
254 uno::Sequence<rendering::RGBColor> aColors=xPalColorSpace->convertToRGB(aPaletteEntry);
255 ENSURE_OR_THROW(aColors.getLength() == 1,
256 "Palette returned more or less than one entry");
257 const rendering::RGBColor& rColor=aColors[0];
258 aPalette[j] = BitmapColor(toByteColor(rColor.Red),
259 toByteColor(rColor.Green),
260 toByteColor(rColor.Blue));
261 }
262 }
263 }
264
265 const ::Size aPixelSize(
266 sizeFromIntegerSize2D(xInputBitmap->getSize()));
267
268 // normalize bitcount
269 auto ePixelFormat =
270 ( nDepth <= 1 ) ? vcl::PixelFormat::N1_BPP :
271 ( nDepth <= 8 ) ? vcl::PixelFormat::N8_BPP :
273 auto eAlphaPixelFormat =
274 ( nAlphaDepth <= 1 ) ? vcl::PixelFormat::N1_BPP :
276
277 ::Bitmap aBitmap( aPixelSize,
278 ePixelFormat,
279 aLayout.Palette.is() ? &aPalette : nullptr );
280 ::Bitmap aAlpha;
281 if( nAlphaDepth )
282 aAlpha = Bitmap(aPixelSize,
283 eAlphaPixelFormat,
285 sal::static_int_cast<sal_uInt16>(1 << nAlphaDepth)) );
286
287 { // limit scoped access
288 BitmapScopedWriteAccess pWriteAccess( aBitmap );
289 BitmapScopedWriteAccess pAlphaWriteAccess( nAlphaDepth ? aAlpha.AcquireWriteAccess() : nullptr,
290 aAlpha );
291
292 ENSURE_OR_THROW(pWriteAccess.get() != nullptr,
293 "Cannot get write access to bitmap");
294
295 const sal_Int32 nWidth(aPixelSize.Width());
296 const sal_Int32 nHeight(aPixelSize.Height());
297
298 if( !readBmp(nWidth,nHeight,aLayout,xInputBitmap,
299 pWriteAccess,pAlphaWriteAccess) )
300 continue;
301 } // limit scoped access
302
303 if( nAlphaDepth )
304 return ::BitmapEx( aBitmap,
305 AlphaMask( aAlpha ) );
306 else
307 return ::BitmapEx( aBitmap );
308 }
309
310 // failed to read data 10 times - bail out
311 return ::BitmapEx();
312 }
313
314 geometry::RealSize2D size2DFromSize( const Size& rSize )
315 {
316 return geometry::RealSize2D( rSize.Width(),
317 rSize.Height() );
318 }
319
320 Size sizeFromRealSize2D( const geometry::RealSize2D& rSize )
321 {
322 return Size( static_cast<tools::Long>(rSize.Width + .5),
323 static_cast<tools::Long>(rSize.Height + .5) );
324 }
325
327 {
328 return ::Size( FRound( rVec.getX() ),
329 FRound( rVec.getY() ) );
330 }
331
332 ::Point pointFromB2DPoint( const basegfx::B2DPoint& rPoint )
333 {
334 return pointFromB2IPoint(basegfx::fround(rPoint));
335 }
336
338 {
340 }
341
343 {
344 return ::Point( rPoint.getX(),
345 rPoint.getY() );
346 }
347
349 {
350 return basegfx::B2IPoint(rPoint.X(), rPoint.Y());
351 }
352
354 {
355 return ::tools::Rectangle( rRect.getMinX(),
356 rRect.getMinY(),
357 rRect.getMaxX(),
358 rRect.getMaxY() );
359 }
360
362 {
363 // although B2IRange internally has separate height/width emptiness, it doesn't
364 // expose any API to let us set them separately, so just do the best we can.
365 if (rRect.IsWidthEmpty() && rRect.IsHeightEmpty())
366 return basegfx::B2IRange( basegfx::B2ITuple( rRect.Left(), rRect.Top() ) );
367 return basegfx::B2IRange( rRect.Left(),
368 rRect.Top(),
369 rRect.IsWidthEmpty() ? rRect.Left() : rRect.Right(),
370 rRect.IsHeightEmpty() ? rRect.Top() : rRect.Bottom() );
371 }
372
374 {
375 return basegfx::B2DSize(rSize.Width(), rSize.Height());
376 }
377
379 {
380 return basegfx::B2DVector(rSize.Width(), rSize.Height());
381 }
382
383 basegfx::B2DPoint b2DPointFromPoint( const ::Point& rPoint )
384 {
385 return basegfx::B2DPoint( rPoint.X(),
386 rPoint.Y() );
387 }
388
389 basegfx::B2DRange b2DRectangleFromRectangle( const ::tools::Rectangle& rRect )
390 {
391 // although B2DRange internally has separate height/width emptiness, it doesn't
392 // expose any API to let us set them separately, so just do the best we can.
393 if (rRect.IsWidthEmpty() && rRect.IsHeightEmpty())
394 return basegfx::B2DRange( basegfx::B2DTuple( rRect.Left(), rRect.Top() ) );
395 return basegfx::B2DRectangle( rRect.Left(),
396 rRect.Top(),
397 rRect.IsWidthEmpty() ? rRect.Left() : rRect.Right(),
398 rRect.IsHeightEmpty() ? rRect.Top() : rRect.Bottom() );
399 }
400
401 geometry::IntegerSize2D integerSize2DFromSize( const Size& rSize )
402 {
403 return geometry::IntegerSize2D( rSize.Width(),
404 rSize.Height() );
405 }
406
407 Size sizeFromIntegerSize2D( const geometry::IntegerSize2D& rSize )
408 {
409 return Size( rSize.Width,
410 rSize.Height );
411 }
412
413 Point pointFromIntegerPoint2D( const geometry::IntegerPoint2D& rPoint )
414 {
415 return Point( rPoint.X,
416 rPoint.Y );
417 }
418
419 tools::Rectangle rectangleFromIntegerRectangle2D( const geometry::IntegerRectangle2D& rRectangle )
420 {
421 return tools::Rectangle( rRectangle.X1, rRectangle.Y1,
422 rRectangle.X2, rRectangle.Y2 );
423 }
424
425 namespace
426 {
427 class StandardColorSpace : public cppu::WeakImplHelper< css::rendering::XColorSpace >
428 {
429 private:
430 uno::Sequence< sal_Int8 > m_aComponentTags;
431
432 virtual ::sal_Int8 SAL_CALL getType( ) override
433 {
434 return rendering::ColorSpaceType::RGB;
435 }
436 virtual uno::Sequence< ::sal_Int8 > SAL_CALL getComponentTags( ) override
437 {
438 return m_aComponentTags;
439 }
440 virtual ::sal_Int8 SAL_CALL getRenderingIntent( ) override
441 {
442 return rendering::RenderingIntent::PERCEPTUAL;
443 }
444 virtual uno::Sequence< beans::PropertyValue > SAL_CALL getProperties( ) override
445 {
446 return uno::Sequence< beans::PropertyValue >();
447 }
448 virtual uno::Sequence< double > SAL_CALL convertColorSpace( const uno::Sequence< double >& deviceColor,
449 const uno::Reference< rendering::XColorSpace >& targetColorSpace ) override
450 {
451 // TODO(P3): if we know anything about target
452 // colorspace, this can be greatly sped up
453 uno::Sequence<rendering::ARGBColor> aIntermediate(
454 convertToARGB(deviceColor));
455 return targetColorSpace->convertFromARGB(aIntermediate);
456 }
457 virtual uno::Sequence< rendering::RGBColor > SAL_CALL convertToRGB( const uno::Sequence< double >& deviceColor ) override
458 {
459 const double* pIn( deviceColor.getConstArray() );
460 const std::size_t nLen( deviceColor.getLength() );
461 ENSURE_ARG_OR_THROW2(nLen%4==0,
462 "number of channels no multiple of 4",
463 static_cast<rendering::XColorSpace*>(this), 0);
464
465 uno::Sequence< rendering::RGBColor > aRes(nLen/4);
466 rendering::RGBColor* pOut( aRes.getArray() );
467 for( std::size_t i=0; i<nLen; i+=4 )
468 {
469 *pOut++ = rendering::RGBColor(pIn[0],pIn[1],pIn[2]);
470 pIn += 4;
471 }
472 return aRes;
473 }
474 virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToARGB( const uno::Sequence< double >& deviceColor ) override
475 {
476 const double* pIn( deviceColor.getConstArray() );
477 const std::size_t nLen( deviceColor.getLength() );
478 ENSURE_ARG_OR_THROW2(nLen%4==0,
479 "number of channels no multiple of 4",
480 static_cast<rendering::XColorSpace*>(this), 0);
481
482 uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
483 rendering::ARGBColor* pOut( aRes.getArray() );
484 for( std::size_t i=0; i<nLen; i+=4 )
485 {
486 *pOut++ = rendering::ARGBColor(pIn[3],pIn[0],pIn[1],pIn[2]);
487 pIn += 4;
488 }
489 return aRes;
490 }
491 virtual uno::Sequence< rendering::ARGBColor > SAL_CALL convertToPARGB( const uno::Sequence< double >& deviceColor ) override
492 {
493 const double* pIn( deviceColor.getConstArray() );
494 const std::size_t nLen( deviceColor.getLength() );
495 ENSURE_ARG_OR_THROW2(nLen%4==0,
496 "number of channels no multiple of 4",
497 static_cast<rendering::XColorSpace*>(this), 0);
498
499 uno::Sequence< rendering::ARGBColor > aRes(nLen/4);
500 rendering::ARGBColor* pOut( aRes.getArray() );
501 for( std::size_t i=0; i<nLen; i+=4 )
502 {
503 *pOut++ = rendering::ARGBColor(pIn[3],pIn[3]*pIn[0],pIn[3]*pIn[1],pIn[3]*pIn[2]);
504 pIn += 4;
505 }
506 return aRes;
507 }
508 virtual uno::Sequence< double > SAL_CALL convertFromRGB( const uno::Sequence< rendering::RGBColor >& rgbColor ) override
509 {
510 const std::size_t nLen( rgbColor.getLength() );
511
512 uno::Sequence< double > aRes(nLen*4);
513 double* pColors=aRes.getArray();
514 for( const auto& rIn : rgbColor )
515 {
516 *pColors++ = rIn.Red;
517 *pColors++ = rIn.Green;
518 *pColors++ = rIn.Blue;
519 *pColors++ = 1.0;
520 }
521 return aRes;
522 }
523 virtual uno::Sequence< double > SAL_CALL convertFromARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) override
524 {
525 const std::size_t nLen( rgbColor.getLength() );
526
527 uno::Sequence< double > aRes(nLen*4);
528 double* pColors=aRes.getArray();
529 for( const auto& rIn : rgbColor )
530 {
531 *pColors++ = rIn.Red;
532 *pColors++ = rIn.Green;
533 *pColors++ = rIn.Blue;
534 *pColors++ = rIn.Alpha;
535 }
536 return aRes;
537 }
538 virtual uno::Sequence< double > SAL_CALL convertFromPARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) override
539 {
540 const std::size_t nLen( rgbColor.getLength() );
541
542 uno::Sequence< double > aRes(nLen*4);
543 double* pColors=aRes.getArray();
544 for( const auto& rIn : rgbColor )
545 {
546 *pColors++ = rIn.Red/rIn.Alpha;
547 *pColors++ = rIn.Green/rIn.Alpha;
548 *pColors++ = rIn.Blue/rIn.Alpha;
549 *pColors++ = rIn.Alpha;
550 }
551 return aRes;
552 }
553
554 public:
555 StandardColorSpace() : m_aComponentTags(4)
556 {
557 sal_Int8* pTags = m_aComponentTags.getArray();
558 pTags[0] = rendering::ColorComponentTag::RGB_RED;
559 pTags[1] = rendering::ColorComponentTag::RGB_GREEN;
560 pTags[2] = rendering::ColorComponentTag::RGB_BLUE;
561 pTags[3] = rendering::ColorComponentTag::ALPHA;
562 }
563 };
564 }
565
566 uno::Reference<rendering::XColorSpace> createStandardColorSpace()
567 {
568 return new StandardColorSpace();
569 }
570
571 uno::Sequence< double > colorToStdColorSpaceSequence( const Color& rColor )
572 {
573 return
574 {
575 toDoubleColor(rColor.GetRed()),
576 toDoubleColor(rColor.GetGreen()),
577 toDoubleColor(rColor.GetBlue()),
578 toDoubleColor(rColor.GetAlpha())
579 };
580 }
581
582 Color stdColorSpaceSequenceToColor( const uno::Sequence< double >& rColor )
583 {
584 ENSURE_ARG_OR_THROW( rColor.getLength() == 4,
585 "color must have 4 channels" );
586
587 Color aColor;
588
589 aColor.SetRed ( toByteColor(rColor[0]) );
590 aColor.SetGreen( toByteColor(rColor[1]) );
591 aColor.SetBlue ( toByteColor(rColor[2]) );
592 aColor.SetAlpha( toByteColor(rColor[3]) );
593
594 return aColor;
595 }
596
597 uno::Sequence< double > colorToDoubleSequence(
598 const Color& rColor,
599 const uno::Reference< rendering::XColorSpace >& xColorSpace )
600 {
601 uno::Sequence<rendering::ARGBColor> aSeq
602 {
603 {
604 toDoubleColor(rColor.GetAlpha()),
605 toDoubleColor(rColor.GetRed()),
606 toDoubleColor(rColor.GetGreen()),
607 toDoubleColor(rColor.GetBlue())
608 }
609 };
610
611 return xColorSpace->convertFromARGB(aSeq);
612 }
613
615 const uno::Sequence< double >& rColor,
616 const uno::Reference< rendering::XColorSpace >& xColorSpace )
617 {
618 const rendering::ARGBColor aARGBColor(
619 xColorSpace->convertToARGB(rColor)[0]);
620
621 return Color( ColorAlpha, toByteColor(aARGBColor.Alpha),
622 toByteColor(aARGBColor.Red),
623 toByteColor(aARGBColor.Green),
624 toByteColor(aARGBColor.Blue) );
625 }
626
627} // namespace canvas
628
629/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt8 * Scanline
Definition: Scanline.hxx:26
uno::Sequence< sal_Int8 > m_aComponentTags
void SetEntryCount(sal_uInt16 nCount)
BitmapWriteAccess * AcquireWriteAccess()
static const BitmapPalette & GetGreyPalette(int nEntries)
sal_uInt8 GetBlue() const
void SetGreen(sal_uInt8 nGreen)
void SetRed(sal_uInt8 nRed)
sal_uInt8 GetAlpha() const
sal_uInt8 GetRed() const
sal_uInt8 GetGreen() const
void SetAlpha(sal_uInt8 nAlpha)
void SetBlue(sal_uInt8 nBlue)
constexpr tools::Long Height() const
constexpr tools::Long Width() const
TYPE getMaxX() const
TYPE getMinX() const
TYPE getMinY() const
TYPE getMaxY() const
TYPE getX() const
TYPE getY() const
constexpr tools::Long Top() const
constexpr tools::Long Right() const
constexpr bool IsWidthEmpty() const
constexpr bool IsHeightEmpty() const
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
This template handles BitmapAccess the RAII way.
const BitmapEx & getBitmapEx() const
Retrieve contained bitmap. Call me with locked Solar mutex!
ColorAlpha
#define ENSURE_ARG_OR_THROW2(c, m, ifc, arg)
#define ENSURE_OR_THROW(c, m)
#define ENSURE_ARG_OR_THROW(c, m)
float x
tools::Long FRound(double fVal)
Sequence< sal_Int8 > aSeq
#define SAL_INFO(area, stream)
B2DRange B2DRectangle
B2IRange fround(const B2DRange &rRange)
int i
long Long
Point pointFromB2IPoint(const basegfx::B2IPoint &rPoint)
Size sizeFromRealSize2D(const geometry::RealSize2D &rSize)
basegfx::B2IPoint b2IPointFromPoint(Point const &rPoint)
basegfx::B2DRange b2DRectangleFromRectangle(const ::tools::Rectangle &rRect)
tools::Rectangle rectangleFromB2IRectangle(const basegfx::B2IRange &rRect)
basegfx::B2DVector b2DVectorFromSize(const Size &rSize)
basegfx::B2IRectangle b2IRectangleFromRectangle(tools::Rectangle const &rRect)
Color stdColorSpaceSequenceToColor(const uno::Sequence< double > &rColor)
basegfx::B2DPoint b2DPointFromPoint(const ::Point &rPoint)
Size sizeFromIntegerSize2D(const geometry::IntegerSize2D &rSize)
Point pointFromIntegerPoint2D(const geometry::IntegerPoint2D &rPoint)
geometry::IntegerSize2D integerSize2DFromSize(const Size &rSize)
sal_Int8 toByteColor(double val)
Convert [0,1] double value to [0,255] int.
basegfx::B2DSize b2DSizeFromSize(const Size &rSize)
Color doubleSequenceToColor(const uno::Sequence< double > &rColor, const uno::Reference< rendering::XColorSpace > &xColorSpace)
double toDoubleColor(sal_uInt8 val)
Convert [0,255] int value to [0,1] double value.
uno::Sequence< double > colorToDoubleSequence(const Color &rColor, const uno::Reference< rendering::XColorSpace > &xColorSpace)
::Point pointFromB2DPoint(const basegfx::B2DPoint &rPoint)
uno::Reference< rendering::XColorSpace > createStandardColorSpace()
Create a standard color space suitable for VCL RGB color.
tools::Rectangle rectangleFromIntegerRectangle2D(const geometry::IntegerRectangle2D &rRectangle)
geometry::RealSize2D size2DFromSize(const Size &rSize)
::tools::Rectangle rectangleFromB2DRectangle(const basegfx::B2DRange &rRect)
::BitmapEx bitmapExFromXBitmap(const uno::Reference< rendering::XIntegerReadOnlyBitmap > &xInputBitmap)
uno::Sequence< double > colorToStdColorSpaceSequence(const Color &rColor)
Create a device-specific color sequence from VCL/Tools color.
uno::Reference< rendering::XBitmap > xBitmapFromBitmapEx(const ::BitmapEx &inputBitmap)
Create an XBitmap from VCL BitmapEx.
Definition: canvastools.cxx:52
::Size sizeFromB2DSize(const basegfx::B2DVector &rVec)
bool getType(BSTR name, Type &type)
unsigned char sal_uInt8
signed char sal_Int8
oslFileHandle & pOut