Kaydet (Commit) 8d924bab authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Caolán McNamara

opengl: take row stride into account when reading to 1-bit bitmap

Opengl doesn't support 1-bit bitmaps so we read back the texture
as RGB bitmap and transform it to 1-bit bitmap. Previously the
implementation did this but naively by converting the buffer without
taking row strides into account. Now on row change the writing is
reset into a new byte.

(cherry picked from commit 11b2e2e8)

Change-Id: Iaa67b209d5b6ab0d9c567a71dee0684a85f53f6b
Reviewed-on: https://gerrit.libreoffice.org/19161Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 2a145c51
...@@ -513,25 +513,31 @@ bool OpenGLSalBitmap::ReadTexture() ...@@ -513,25 +513,31 @@ bool OpenGLSalBitmap::ReadTexture()
sal_uInt8* pCurrent = pBuffer; sal_uInt8* pCurrent = pBuffer;
for (size_t i = 0; i < aBuffer.size(); i += 3) for (int y = 0; y < mnHeight; ++y)
{ {
sal_uInt8 nR = *pCurrent++; for (int x = 0; x < mnWidth; ++x)
sal_uInt8 nG = *pCurrent++;
sal_uInt8 nB = *pCurrent++;
if (nR > 0 && nG > 0 && nB > 0)
{
pData[nIndex] |= (1 << nShift);
}
nShift--;
if (nShift < 0)
{ {
nShift = 7; if (nShift < 0)
nIndex++; {
pData[nIndex] = 0; nShift = 7;
nIndex++;
pData[nIndex] = 0;
}
sal_uInt8 nR = *pCurrent++;
sal_uInt8 nG = *pCurrent++;
sal_uInt8 nB = *pCurrent++;
if (nR > 0 && nG > 0 && nB > 0)
{
pData[nIndex] |= (1 << nShift);
}
nShift--;
} }
nShift = 7;
nIndex++;
pData[nIndex] = 0;
} }
mnBufWidth = mnWidth; mnBufWidth = mnWidth;
mnBufHeight = mnHeight; mnBufHeight = mnHeight;
return true; return true;
......
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