summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-02-06 12:00:16 +0200
committerTomaž Vajngerl <quikee@gmail.com>2018-02-07 10:58:21 +0100
commite1d1bce72be34eb7ea4e3c72642736b378388c98 (patch)
tree0a770f98ace378edd1ccd197487213c2189b03ca /vcl
parentfa85592c0efba65f4a1b09fea950ec1c311bdd4c (diff)
move Bitmap::SetToData to BitmapTools
Change-Id: I0fc62d29d2044c2aa8af3742d4aeb9d782793713 Reviewed-on: https://gerrit.libreoffice.org/49280 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/bitmap/BitmapTools.cxx34
-rw-r--r--vcl/source/gdi/bitmap4.cxx26
2 files changed, 34 insertions, 26 deletions
diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx
index f0aa8ccecf33..94974f57746d 100644
--- a/vcl/source/bitmap/BitmapTools.cxx
+++ b/vcl/source/bitmap/BitmapTools.cxx
@@ -24,6 +24,8 @@
#include <unotools/resmgr.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
+#include <vcl/salbtype.hxx>
+#include <vcl/bitmapaccess.hxx>
using namespace css;
@@ -101,6 +103,38 @@ void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx,
}
+/** Copy block of image data into the bitmap.
+ Assumes that the Bitmap has been constructed with the desired size.
+
+ @param pData
+ The block of data to copy
+ @param nStride
+ The number of bytes in a scanline, must >= width
+*/
+BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, sal_uInt16 nBitCount )
+{
+ assert(nStride >= nWidth);
+ Bitmap aBmp( Size( nWidth, nHeight ), nBitCount );
+
+ Bitmap::ScopedWriteAccess pWrite(aBmp);
+ assert(pWrite.get());
+ if( pWrite.get() )
+ {
+ for( long y = 0; y < nHeight; ++y )
+ {
+ sal_uInt8 const *p = pData + y * nStride;
+ Scanline pScanline = pWrite->GetScanline(y);
+ for (long x = 0; x < nWidth; ++x)
+ {
+ BitmapColor col(p[0], p[1], p[2]);
+ pWrite->SetPixelOnData(pScanline, x, col);
+ p += 3;
+ }
+ }
+ }
+ return aBmp;
+}
+
}} // end vcl::bitmap
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/bitmap4.cxx b/vcl/source/gdi/bitmap4.cxx
index f71f48f31bbf..118fdf8916c4 100644
--- a/vcl/source/gdi/bitmap4.cxx
+++ b/vcl/source/gdi/bitmap4.cxx
@@ -112,32 +112,6 @@ bool Bitmap::Filter( BmpFilter eFilter, const BmpFilterParam* pFilterParam )
return bRet;
}
-void Bitmap::SetToData( sal_uInt8 const *pData, sal_Int32 nStride )
-{
- assert(mxImpBmp);
- auto nWidth = mxImpBmp->ImplGetSize().getWidth();
- auto nHeight = mxImpBmp->ImplGetSize().getHeight();
- assert(nStride >= nWidth);
-
- BitmapWriteAccess *pWrite = AcquireWriteAccess();
- assert(pWrite);
- if( pWrite )
- {
- for( long y = 0; y < nHeight; ++y )
- {
- sal_uInt8 const *p = pData + y * nStride;
- Scanline pScanline = pWrite->GetScanline(y);
- for (long x = 0; x < nWidth; ++x)
- {
- BitmapColor col(p[0], p[1], p[2]);
- pWrite->SetPixelOnData(pScanline, x, col);
- p += 3;
- }
- }
- }
- ReleaseAccess( pWrite );
-}
-
bool Bitmap::ImplConvolute3( const long* pMatrix )
{
const long nDivisor = 8;