avmedia: move BitmapWriteAccess inside Bitmap
part of a larger project to hide BitmapWriteAccess inside Bitmap Change-Id: Ia46c12b3297107892a6236633c11ca9ada6edbd4 Reviewed-on: https://gerrit.libreoffice.org/49106 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
parent
d60d2973ec
commit
61064b56bf
3 changed files with 38 additions and 18 deletions
|
@ -174,24 +174,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL FrameGrabber::grabFrame( double fMe
|
|||
|
||||
int nStride = GST_ROUND_UP_4( nWidth * 3 );
|
||||
Bitmap aBmp( Size( nWidth, nHeight ), 24 );
|
||||
|
||||
BitmapWriteAccess *pWrite = aBmp.AcquireWriteAccess();
|
||||
if( pWrite )
|
||||
{
|
||||
// yet another cheesy pixel copying loop
|
||||
for( int y = 0; y < nHeight; ++y )
|
||||
{
|
||||
sal_uInt8 *p = pData + y * nStride;
|
||||
Scanline pScanline = pWrite->GetScanline(y);
|
||||
for (int x = 0; x < nWidth; ++x)
|
||||
{
|
||||
BitmapColor col(p[0], p[1], p[2]);
|
||||
pWrite->SetPixelOnData(pScanline, x, col);
|
||||
p += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
Bitmap::ReleaseAccess( pWrite );
|
||||
aBmp.SetToData( pData, nStride );
|
||||
|
||||
#ifndef AVMEDIA_GST_0_10
|
||||
gst_buffer_unmap( pBuf, &aMapInfo );
|
||||
|
|
|
@ -650,6 +650,16 @@ public:
|
|||
BmpFilter eFilter,
|
||||
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:
|
||||
|
||||
SAL_DLLPRIVATE void ImplMakeUnique();
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <osl/diagnose.h>
|
||||
#include <vcl/bitmapaccess.hxx>
|
||||
#include <vcl/bitmap.hxx>
|
||||
#include <impbmp.hxx>
|
||||
|
||||
#define S2(a,b) { long t; if( ( t = b - a ) < 0 ) { a += t; b -= t; } }
|
||||
#define MN3(a,b,c) S2(a,b); S2(a,c);
|
||||
|
@ -111,6 +112,32 @@ 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;
|
||||
|
|
Loading…
Reference in a new issue