EPS import: convert to BMP instead of PNG

This speeds up rendering of EPS figures by approximately 10%

Change-Id: Ie7d39bab4a7ea5f9350f989c25364f70bd8b8453
Reviewed-on: https://gerrit.libreoffice.org/6124
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Björgvin Ragnarsson
2013-10-04 01:21:56 +03:00
committed by Caolán McNamara
parent df1076965f
commit f3123d396c

View File

@@ -245,7 +245,7 @@ static bool RenderAsEMF(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &r
return bRet; return bRet;
} }
static bool RenderAsPNGThroughHelper(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, static bool RenderAsBMPThroughHelper(const sal_uInt8* pBuf, sal_uInt32 nBytesRead,
Graphic &rGraphic, OUString &rProgName, rtl_uString *pArgs[], size_t nArgs) Graphic &rGraphic, OUString &rProgName, rtl_uString *pArgs[], size_t nArgs)
{ {
oslProcess aProcess; oslProcess aProcess;
@@ -276,7 +276,7 @@ static bool RenderAsPNGThroughHelper(const sal_uInt8* pBuf, sal_uInt32 nBytesRea
aMemStm.Seek(0); aMemStm.Seek(0);
if ( if (
aMemStm.GetEndOfData() && aMemStm.GetEndOfData() &&
GraphicConverter::Import(aMemStm, rGraphic, CVT_PNG) == ERRCODE_NONE GraphicConverter::Import(aMemStm, rGraphic, CVT_BMP) == ERRCODE_NONE
) )
{ {
MakeAsMeta(rGraphic); MakeAsMeta(rGraphic);
@@ -290,7 +290,7 @@ static bool RenderAsPNGThroughHelper(const sal_uInt8* pBuf, sal_uInt32 nBytesRea
return bRet; return bRet;
} }
static bool RenderAsPNGThroughConvert(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, static bool RenderAsBMPThroughConvert(const sal_uInt8* pBuf, sal_uInt32 nBytesRead,
Graphic &rGraphic) Graphic &rGraphic)
{ {
OUString fileName("convert" EXESUFFIX); OUString fileName("convert" EXESUFFIX);
@@ -301,17 +301,17 @@ static bool RenderAsPNGThroughConvert(const sal_uInt8* pBuf, sal_uInt32 nBytesRe
OUString arg2("300x300"); OUString arg2("300x300");
// read eps from STDIN // read eps from STDIN
OUString arg3("eps:-"); OUString arg3("eps:-");
// write png to STDOUT // write bmp to STDOUT
OUString arg4("png:-"); OUString arg4("bmp:-");
rtl_uString *args[] = rtl_uString *args[] =
{ {
arg1.pData, arg2.pData, arg3.pData, arg4.pData arg1.pData, arg2.pData, arg3.pData, arg4.pData
}; };
return RenderAsPNGThroughHelper(pBuf, nBytesRead, rGraphic, fileName, args, return RenderAsBMPThroughHelper(pBuf, nBytesRead, rGraphic, fileName, args,
sizeof(args)/sizeof(rtl_uString *)); sizeof(args)/sizeof(rtl_uString *));
} }
static bool RenderAsPNGThroughGS(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, static bool RenderAsBMPThroughGS(const sal_uInt8* pBuf, sal_uInt32 nBytesRead,
Graphic &rGraphic) Graphic &rGraphic)
{ {
#ifdef WNT #ifdef WNT
@@ -327,7 +327,7 @@ static bool RenderAsPNGThroughGS(const sal_uInt8* pBuf, sal_uInt32 nBytesRead,
OUString arg6("-dTextAlphaBits=4"); OUString arg6("-dTextAlphaBits=4");
OUString arg7("-dGraphicsAlphaBits=4"); OUString arg7("-dGraphicsAlphaBits=4");
OUString arg8("-r300x300"); OUString arg8("-r300x300");
OUString arg9("-sDEVICE=png256"); OUString arg9("-sDEVICE=bmp256");
OUString arg10("-sOutputFile=-"); OUString arg10("-sOutputFile=-");
OUString arg11("-"); OUString arg11("-");
rtl_uString *args[] = rtl_uString *args[] =
@@ -336,16 +336,16 @@ static bool RenderAsPNGThroughGS(const sal_uInt8* pBuf, sal_uInt32 nBytesRead,
arg6.pData, arg7.pData, arg8.pData, arg9.pData, arg10.pData, arg6.pData, arg7.pData, arg8.pData, arg9.pData, arg10.pData,
arg11.pData arg11.pData
}; };
return RenderAsPNGThroughHelper(pBuf, nBytesRead, rGraphic, fileName, args, return RenderAsBMPThroughHelper(pBuf, nBytesRead, rGraphic, fileName, args,
sizeof(args)/sizeof(rtl_uString *)); sizeof(args)/sizeof(rtl_uString *));
} }
static bool RenderAsPNG(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &rGraphic) static bool RenderAsBMP(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &rGraphic)
{ {
if (RenderAsPNGThroughGS(pBuf, nBytesRead, rGraphic)) if (RenderAsBMPThroughGS(pBuf, nBytesRead, rGraphic))
return true; return true;
else else
return RenderAsPNGThroughConvert(pBuf, nBytesRead, rGraphic); return RenderAsBMPThroughConvert(pBuf, nBytesRead, rGraphic);
} }
// this method adds a replacement action containing the original wmf or tiff replacement, // this method adds a replacement action containing the original wmf or tiff replacement,
@@ -679,7 +679,7 @@ GraphicImport(SvStream & rStream, Graphic & rGraphic, FilterConfigItem*, sal_Boo
{ {
bHasPreview = RenderAsEMF(pBuf, nBytesRead, aGraphic); bHasPreview = RenderAsEMF(pBuf, nBytesRead, aGraphic);
if (!bHasPreview) if (!bHasPreview)
bHasPreview = RenderAsPNG(pBuf, nBytesRead, aGraphic); bHasPreview = RenderAsBMP(pBuf, nBytesRead, aGraphic);
} }
// if there is no preview -> make a red box // if there is no preview -> make a red box