vcl/source/filter/graphicfilter.cxx |   51 +++---------------------------------
 1 file changed, 5 insertions(+), 46 deletions(-)

New commits:
commit 1d548a2bc70e0b38e32ccae8b15b04bda84f3576
Author:     offtkp <[email protected]>
AuthorDate: Sat Jul 16 19:10:19 2022 +0300
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Tue Jul 19 13:05:03 2022 +0200

    Replace old png writer in graphicfilter.cxx
    
    Change-Id: I68b35e82fd5ca4de87b3b9c3c6be5cf802f071ed
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137132
    Tested-by: Tomaž Vajngerl <[email protected]>
    Reviewed-by: Tomaž Vajngerl <[email protected]>

diff --git a/vcl/source/filter/graphicfilter.cxx 
b/vcl/source/filter/graphicfilter.cxx
index f7e3765f4e94..6aa2af7d23aa 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -34,7 +34,7 @@
 #include <vcl/salctype.hxx>
 #include <vcl/filter/PngImageReader.hxx>
 #include <vcl/filter/SvmWriter.hxx>
-#include <vcl/pngwrite.hxx>
+#include <vcl/filter/PngImageWriter.hxx>
 #include <vcl/vectorgraphicdata.hxx>
 #include <vcl/virdev.hxx>
 #include <impgraph.hxx>
@@ -1794,52 +1794,11 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& 
rGraphic, std::u16string_vi
             }
             else if ( aFilterName.equalsIgnoreAsciiCase( EXP_PNG ) )
             {
-                vcl::PNGWriter aPNGWriter( aGraphic.GetBitmapEx(), pFilterData 
);
+                auto aBitmapEx = aGraphic.GetBitmapEx();
+                vcl::PngImageWriter aPNGWriter( rOStm );
                 if ( pFilterData )
-                {
-                    for ( const auto& rPropVal : *pFilterData )
-                    {
-                        if ( rPropVal.Name == "AdditionalChunks" )
-                        {
-                            css::uno::Sequence< css::beans::PropertyValue > 
aAdditionalChunkSequence;
-                            if ( rPropVal.Value >>= aAdditionalChunkSequence )
-                            {
-                                for ( const auto& rAdditionalChunk : 
std::as_const(aAdditionalChunkSequence) )
-                                {
-                                    if ( rAdditionalChunk.Name.getLength() == 
4 )
-                                    {
-                                        sal_uInt32 nChunkType = 0;
-                                        for ( sal_Int32 k = 0; k < 4; k++ )
-                                        {
-                                            nChunkType <<= 8;
-                                            nChunkType |= 
static_cast<sal_uInt8>(rAdditionalChunk.Name[ k ]);
-                                        }
-                                        css::uno::Sequence< sal_Int8 > 
aByteSeq;
-                                        if ( rAdditionalChunk.Value >>= 
aByteSeq )
-                                        {
-                                            std::vector< 
vcl::PNGWriter::ChunkData >& rChunkData = aPNGWriter.GetChunks();
-                                            if ( !rChunkData.empty() )
-                                            {
-                                                sal_uInt32 nChunkLen = 
aByteSeq.getLength();
-
-                                                vcl::PNGWriter::ChunkData 
aChunkData;
-                                                aChunkData.nType = nChunkType;
-                                                if ( nChunkLen )
-                                                {
-                                                    aChunkData.aData.resize( 
nChunkLen );
-                                                    memcpy( 
aChunkData.aData.data(), aByteSeq.getConstArray(), nChunkLen );
-                                                }
-                                                std::vector< 
vcl::PNGWriter::ChunkData >::iterator aIter = rChunkData.end() - 1;
-                                                rChunkData.insert( aIter, 
aChunkData );
-                                            }
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-                aPNGWriter.Write( rOStm );
+                    aPNGWriter.setParameters( *pFilterData );
+                aPNGWriter.write( aBitmapEx );
 
                 if( rOStm.GetError() )
                     nStatus = ERRCODE_GRFILTER_IOERROR;

Reply via email to