summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chart2/source/view/main/OpenGLRender.cxx21
-rw-r--r--include/vcl/opengl/OpenGLHelper.hxx2
-rw-r--r--vcl/source/opengl/OpenGLHelper.cxx28
3 files changed, 31 insertions, 20 deletions
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 8ab05b7d136f..79e408cf26dc 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -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;
diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx
index 77d1b2840c45..5cb1078fbb2d 100644
--- a/include/vcl/opengl/OpenGLHelper.hxx
+++ b/include/vcl/opengl/OpenGLHelper.hxx
@@ -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
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 0042231779d8..35760f2de72c 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -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: */