vcl: convert TGA to use ImportOutput
Change-Id: I4e30ac030863e987b9e817d068ed77e142b2fcbb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184399 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
committed by
Tomaž Vajngerl
parent
8bbc6fa88a
commit
557348bda5
@@ -19,8 +19,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vcl/graph.hxx>
|
||||
#include <vcl/dllapi.h>
|
||||
|
||||
VCL_DLLPUBLIC bool ImportTgaGraphic(SvStream& rStream, Graphic& rGraphic);
|
||||
class SvStream;
|
||||
class ImportOutput;
|
||||
|
||||
VCL_DLLPUBLIC bool ImportTgaGraphic(SvStream& rStream, ImportOutput& rImportOutput);
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <test/bootstrapfixture.hxx>
|
||||
#include <vcl/FilterConfigItem.hxx>
|
||||
#include <tools/stream.hxx>
|
||||
#include <vcl/graph.hxx>
|
||||
#include <vcl/filter/ImportOutput.hxx>
|
||||
#include <filter/TgaReader.hxx>
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
@@ -44,8 +44,8 @@ bool TgaFilterTest::load(const OUString &,
|
||||
SfxFilterFlags, SotClipboardFormatId, unsigned int)
|
||||
{
|
||||
SvFileStream aFileStream(rURL, StreamMode::READ);
|
||||
Graphic aGraphic;
|
||||
return ImportTgaGraphic(aFileStream, aGraphic);
|
||||
ImportOutput aImportOutput;
|
||||
return ImportTgaGraphic(aFileStream, aImportOutput);
|
||||
}
|
||||
|
||||
void TgaFilterTest::testCVEs()
|
||||
|
||||
@@ -1189,8 +1189,12 @@ ErrCode GraphicFilter::readBMP(SvStream & rStream, Graphic & rGraphic, GfxLinkTy
|
||||
|
||||
ErrCode GraphicFilter::readTGA(SvStream & rStream, Graphic & rGraphic)
|
||||
{
|
||||
if (ImportTgaGraphic(rStream, rGraphic))
|
||||
ImportOutput aImportOutput;
|
||||
if (ImportTgaGraphic(rStream, aImportOutput))
|
||||
{
|
||||
rGraphic = Graphic(*aImportOutput.moBitmap);
|
||||
return ERRCODE_NONE;
|
||||
}
|
||||
else
|
||||
return ERRCODE_GRFILTER_FILTERERROR;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
|
||||
|
||||
#include <vcl/graph.hxx>
|
||||
#include <vcl/filter/ImportOutput.hxx>
|
||||
#include <vcl/BitmapTools.hxx>
|
||||
#include <tools/stream.hxx>
|
||||
#include <memory>
|
||||
@@ -110,7 +109,7 @@ private:
|
||||
|
||||
public:
|
||||
explicit TGAReader(SvStream &rTGA);
|
||||
bool ReadTGA(Graphic &rGraphic);
|
||||
bool ReadTGA(ImportOutput& rImportOutput);
|
||||
};
|
||||
|
||||
}
|
||||
@@ -127,7 +126,7 @@ TGAReader::TGAReader(SvStream &rTGA)
|
||||
{
|
||||
}
|
||||
|
||||
bool TGAReader::ReadTGA(Graphic & rGraphic)
|
||||
bool TGAReader::ReadTGA(ImportOutput& rImportOutput)
|
||||
{
|
||||
if ( m_rTGA.GetError() )
|
||||
return false;
|
||||
@@ -155,7 +154,7 @@ bool TGAReader::ReadTGA(Graphic & rGraphic)
|
||||
mbStatus = ImplReadBody();
|
||||
|
||||
if ( mbStatus )
|
||||
rGraphic = vcl::bitmap::CreateFromData(std::move(*mpBitmap));
|
||||
rImportOutput.moBitmap = vcl::bitmap::CreateFromData(std::move(*mpBitmap));
|
||||
}
|
||||
}
|
||||
return mbStatus;
|
||||
@@ -780,11 +779,10 @@ bool TGAReader::ImplReadPalette()
|
||||
|
||||
//================== GraphicImport - the exported function ================
|
||||
|
||||
bool ImportTgaGraphic(SvStream & rStream, Graphic & rGraphic)
|
||||
bool ImportTgaGraphic(SvStream& rStream, ImportOutput& rImportOutput)
|
||||
{
|
||||
TGAReader aTGAReader(rStream);
|
||||
|
||||
return aTGAReader.ReadTGA(rGraphic);
|
||||
return aTGAReader.ReadTGA(rImportOutput);
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -238,9 +238,9 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
|
||||
}
|
||||
else if (strcmp(argv[2], "tga") == 0)
|
||||
{
|
||||
Graphic aGraphic;
|
||||
ImportOutput aImportOutput;
|
||||
SvFileStream aFileStream(out, StreamMode::READ);
|
||||
ret = static_cast<int>(ImportTgaGraphic(aFileStream, aGraphic));
|
||||
ret = static_cast<int>(ImportTgaGraphic(aFileStream, aImportOutput));
|
||||
}
|
||||
else if (strcmp(argv[2], "tif") == 0)
|
||||
{
|
||||
|
||||
@@ -49,8 +49,8 @@ extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
|
||||
Graphic aGraphic;
|
||||
(void)ImportTgaGraphic(aStream, aGraphic);
|
||||
ImportOutput aImportOutput;
|
||||
(void)ImportTgaGraphic(aStream, aImportOutput);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user