Kaydet (Commit) e1d1bce7 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Tomaž Vajngerl

move Bitmap::SetToData to BitmapTools

Change-Id: I0fc62d29d2044c2aa8af3742d4aeb9d782793713
Reviewed-on: https://gerrit.libreoffice.org/49280Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
Tested-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst fa85592c
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <gst/video/gstvideosink.h> #include <gst/video/gstvideosink.h>
#include <vcl/graph.hxx> #include <vcl/graph.hxx>
#include <vcl/bitmapaccess.hxx> #include <vcl/BitmapTools.hxx>
#include <string> #include <string>
...@@ -173,8 +173,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL FrameGrabber::grabFrame( double fMe ...@@ -173,8 +173,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL FrameGrabber::grabFrame( double fMe
#endif #endif
int nStride = GST_ROUND_UP_4( nWidth * 3 ); int nStride = GST_ROUND_UP_4( nWidth * 3 );
Bitmap aBmp( Size( nWidth, nHeight ), 24 ); BitmapEx aBmp = vcl::bitmap::CreateFromData(pData, nWidth, nHeight, nStride, 24 );
aBmp.SetToData( pData, nStride );
#ifndef AVMEDIA_GST_0_10 #ifndef AVMEDIA_GST_0_10
gst_buffer_unmap( pBuf, &aMapInfo ); gst_buffer_unmap( pBuf, &aMapInfo );
......
...@@ -22,6 +22,17 @@ BitmapEx VCL_DLLPUBLIC loadFromName(const OUString& rFileName, const ImageLoadFl ...@@ -22,6 +22,17 @@ BitmapEx VCL_DLLPUBLIC loadFromName(const OUString& rFileName, const ImageLoadFl
void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx, double fScaleFactor); void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx, double fScaleFactor);
/** 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 VCL_DLLPUBLIC CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, sal_uInt16 nBitCount );
}} // end vcl::bitmap }} // end vcl::bitmap
#endif // INCLUDED_VCL_BITMAP_TOOLS_HXX #endif // INCLUDED_VCL_BITMAP_TOOLS_HXX
......
...@@ -650,16 +650,6 @@ public: ...@@ -650,16 +650,6 @@ public:
BmpFilter eFilter, BmpFilter eFilter,
const BmpFilterParam* pFilterParam = nullptr ); const BmpFilterParam* pFilterParam = nullptr );
/** 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
*/
void SetToData( sal_uInt8 const *pData, sal_Int32 nStride );
public: public:
SAL_DLLPRIVATE void ImplMakeUnique(); SAL_DLLPRIVATE void ImplMakeUnique();
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include <unotools/resmgr.hxx> #include <unotools/resmgr.hxx>
#include <vcl/settings.hxx> #include <vcl/settings.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <vcl/salbtype.hxx>
#include <vcl/bitmapaccess.hxx>
using namespace css; using namespace css;
...@@ -101,6 +103,38 @@ void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx, ...@@ -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 }} // end vcl::bitmap
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -112,32 +112,6 @@ bool Bitmap::Filter( BmpFilter eFilter, const BmpFilterParam* pFilterParam ) ...@@ -112,32 +112,6 @@ bool Bitmap::Filter( BmpFilter eFilter, const BmpFilterParam* pFilterParam )
return bRet; 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 ) bool Bitmap::ImplConvolute3( const long* pMatrix )
{ {
const long nDivisor = 8; const long nDivisor = 8;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment