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 bmpWidth = rBitmapEx.GetSizePixel().Width();
|
||||||
long bmpHeight = rBitmapEx.GetSizePixel().Height();
|
long bmpHeight = rBitmapEx.GetSizePixel().Height();
|
||||||
|
boost::scoped_array<sal_uInt8> bitmapBuf(OpenGLHelper::ConvertBitmapExToRGBABuffer(rBitmapEx));
|
||||||
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++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TextInfo aTextInfo;
|
TextInfo aTextInfo;
|
||||||
aTextInfo.rotation = -(double)rotation / 360.0 * 2* GL_PI;
|
aTextInfo.rotation = -(double)rotation / 360.0 * 2* GL_PI;
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <vcl/vclopengl_dllapi.hxx>
|
#include <vcl/vclopengl_dllapi.hxx>
|
||||||
|
#include <vcl/bitmapex.hxx>
|
||||||
|
|
||||||
#include <rtl/ustring.hxx>
|
#include <rtl/ustring.hxx>
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ class VCLOPENGL_DLLPUBLIC OpenGLHelper
|
|||||||
public:
|
public:
|
||||||
static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName);
|
static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName);
|
||||||
|
|
||||||
|
static sal_uInt8* ConvertBitmapExToRGBABuffer(const BitmapEx& rBitmapEx);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
#include <osl/file.hxx>
|
#include <osl/file.hxx>
|
||||||
#include <rtl/bootstrap.hxx>
|
#include <rtl/bootstrap.hxx>
|
||||||
#include <config_folders.h>
|
#include <config_folders.h>
|
||||||
|
#include <vcl/salbtype.hxx>
|
||||||
|
#include <vcl/bmpacc.hxx>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -140,4 +142,30 @@ GLint OpenGLHelper::LoadShaders(const OUString& rVertexShaderName,const OUString
|
|||||||
return ProgramID;
|
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: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
Reference in New Issue
Block a user