summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@gmail.com>2016-01-11 21:32:55 +0100
committerMatúš Kukan <matus.kukan@gmail.com>2016-01-11 21:39:35 +0100
commitd5dcfe40ff3774d82a7b8f9f3d75b5b3cdac78ba (patch)
treefd4ed5d22f4c269c25cfc6d925391cee19c5e6ba
parent993d84f823c3d8e640f7219d5569c72d92b85b20 (diff)
tdf#94831: Check for null mpReadAccess before first use
There was erroneously added code before check in 45e8e0fbee40f9a8d91f4c559c8bbb16dd7b3f36. Change-Id: Ie2e84cfc061097c25e5d799e9c388abd9724bd93
-rw-r--r--vcl/source/filter/jpeg/JpegWriter.cxx39
1 files changed, 18 insertions, 21 deletions
diff --git a/vcl/source/filter/jpeg/JpegWriter.cxx b/vcl/source/filter/jpeg/JpegWriter.cxx
index cb1a67f90712..38c65a504027 100644
--- a/vcl/source/filter/jpeg/JpegWriter.cxx
+++ b/vcl/source/filter/jpeg/JpegWriter.cxx
@@ -199,32 +199,29 @@ bool JPEGWriter::Write( const Graphic& rGraphic )
}
mpReadAccess = aGraphicBmp.AcquireReadAccess();
+ if( mpReadAccess )
+ {
+ if ( !mbGreys ) // bitmap was not explicitly converted into greyscale,
+ { // check if source is greyscale only
+ bool bIsGrey = true;
- if ( !mbGreys ) // bitmap was not explicitly converted into greyscale,
- { // check if source is greyscale only
-
- bool bIsGrey = true;
-
- long nWidth = mpReadAccess->Width();
- for ( long nY = 0; bIsGrey && ( nY < mpReadAccess->Height() ); nY++ )
- {
- BitmapColor aColor;
- for( long nX = 0L; bIsGrey && ( nX < nWidth ); nX++ )
+ long nWidth = mpReadAccess->Width();
+ for ( long nY = 0; bIsGrey && ( nY < mpReadAccess->Height() ); nY++ )
{
- aColor = mpReadAccess->HasPalette() ? mpReadAccess->GetPaletteColor( mpReadAccess->GetPixelIndex( nY, nX ) )
- : mpReadAccess->GetPixel( nY, nX );
- bIsGrey = ( aColor.GetRed() == aColor.GetGreen() ) && ( aColor.GetRed() == aColor.GetBlue() );
+ BitmapColor aColor;
+ for( long nX = 0L; bIsGrey && ( nX < nWidth ); nX++ )
+ {
+ aColor = mpReadAccess->HasPalette() ? mpReadAccess->GetPaletteColor( mpReadAccess->GetPixelIndex( nY, nX ) )
+ : mpReadAccess->GetPixel( nY, nX );
+ bIsGrey = ( aColor.GetRed() == aColor.GetGreen() ) && ( aColor.GetRed() == aColor.GetBlue() );
+ }
}
+ if ( bIsGrey )
+ mbGreys = true;
}
- if ( bIsGrey )
- mbGreys = true;
- }
+ if( mpExpWasGrey )
+ *mpExpWasGrey = mbGreys;
- if( mpExpWasGrey )
- *mpExpWasGrey = mbGreys;
-
- if( mpReadAccess )
- {
mbNative = ( mpReadAccess->GetScanlineFormat() == BMP_FORMAT_24BIT_TC_RGB );
if( !mbNative )