Extract code of BitmapEx -> RGBA buffer conversion to OpenGLHelper
Needed by gltf rendering. Change-Id: I1aa974f3c515c5fb19a07b54ff655331138553cb
This commit is contained in:
@@ -900,26 +900,7 @@ int OpenGLRender::CreateTextTexture(const BitmapEx& rBitmapEx, const awt::Point&
|
||||
|
||||
long bmpWidth = rBitmapEx.GetSizePixel().Width();
|
||||
long bmpHeight = rBitmapEx.GetSizePixel().Height();
|
||||
|
||||
Bitmap aBitmap (rBitmapEx.GetBitmap());
|
||||
AlphaMask aAlpha (rBitmapEx.GetAlpha());
|
||||
boost::scoped_array<sal_uInt8> bitmapBuf(new sal_uInt8[4* bmpWidth * bmpHeight ]);
|
||||
Bitmap::ScopedReadAccess pReadAccces( aBitmap );
|
||||
AlphaMask::ScopedReadAccess pAlphaReadAccess( aAlpha );
|
||||
|
||||
size_t i = 0;
|
||||
for (long ny = 0; ny < bmpHeight; ny++)
|
||||
{
|
||||
Scanline pAScan = pAlphaReadAccess->GetScanline(ny);
|
||||
for(long nx = 0; nx < bmpWidth; nx++)
|
||||
{
|
||||
BitmapColor aCol = pReadAccces->GetColor( ny, nx );
|
||||
bitmapBuf[i++] = aCol.GetRed();
|
||||
bitmapBuf[i++] = aCol.GetGreen();
|
||||
bitmapBuf[i++] = aCol.GetBlue();
|
||||
bitmapBuf[i++] = 255 - *pAScan++;
|
||||
}
|
||||
}
|
||||
boost::scoped_array<sal_uInt8> bitmapBuf(OpenGLHelper::ConvertBitmapExToRGBABuffer(rBitmapEx));
|
||||
|
||||
TextInfo aTextInfo;
|
||||
aTextInfo.rotation = -(double)rotation / 360.0 * 2* GL_PI;
|
||||
|
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include <vcl/vclopengl_dllapi.hxx>
|
||||
#include <vcl/bitmapex.hxx>
|
||||
|
||||
#include <rtl/ustring.hxx>
|
||||
|
||||
@@ -20,6 +21,7 @@ class VCLOPENGL_DLLPUBLIC OpenGLHelper
|
||||
public:
|
||||
static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName);
|
||||
|
||||
static sal_uInt8* ConvertBitmapExToRGBABuffer(const BitmapEx& rBitmapEx);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -12,6 +12,8 @@
|
||||
#include <osl/file.hxx>
|
||||
#include <rtl/bootstrap.hxx>
|
||||
#include <config_folders.h>
|
||||
#include <vcl/salbtype.hxx>
|
||||
#include <vcl/bmpacc.hxx>
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -140,4 +142,30 @@ GLint OpenGLHelper::LoadShaders(const OUString& rVertexShaderName,const OUString
|
||||
return ProgramID;
|
||||
}
|
||||
|
||||
sal_uInt8* OpenGLHelper::ConvertBitmapExToRGBABuffer(const BitmapEx& rBitmapEx)
|
||||
{
|
||||
long nBmpWidth = rBitmapEx.GetSizePixel().Width();
|
||||
long nBmpHeight = rBitmapEx.GetSizePixel().Height();
|
||||
|
||||
Bitmap aBitmap (rBitmapEx.GetBitmap());
|
||||
AlphaMask aAlpha (rBitmapEx.GetAlpha());
|
||||
sal_uInt8* pBitmapBuf(new sal_uInt8[4* nBmpWidth * nBmpHeight ]);
|
||||
Bitmap::ScopedReadAccess pReadAccces( aBitmap );
|
||||
AlphaMask::ScopedReadAccess pAlphaReadAccess( aAlpha );
|
||||
size_t i = 0;
|
||||
for (long ny = 0; ny < nBmpHeight; ny++)
|
||||
{
|
||||
Scanline pAScan = pAlphaReadAccess ? pAlphaReadAccess->GetScanline(ny) : 0;
|
||||
for(long nx = 0; nx < nBmpWidth; nx++)
|
||||
{
|
||||
BitmapColor aCol = pReadAccces->GetColor( ny, nx );
|
||||
pBitmapBuf[i++] = aCol.GetRed();
|
||||
pBitmapBuf[i++] = aCol.GetGreen();
|
||||
pBitmapBuf[i++] = aCol.GetBlue();
|
||||
pBitmapBuf[i++] = pAScan ? 255 - *pAScan++ : 255;
|
||||
}
|
||||
}
|
||||
return pBitmapBuf;
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
Reference in New Issue
Block a user