1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "pdfioutdev_gpl.hxx"
21 #include "pnghelper.hxx"
28 #include <boost/shared_array.hpp>
31 #pragma warning(push, 1)
34 // sigh, UTF8.h was removed in poppler-0.21.0 and put back in 0.21.1
35 // FIXME: we can't use #if POPPLER_CHECK_VERSION(0, 21, 0) && !POPPLER_CHECK_VERSION(0, 21, 1)
36 // because the internal poppler does not provide poppler-version.h and the macro always returns 0
37 #if POPPLER_CHECK_VERSION(0, 21, 1)
39 #elif POPPLER_CHECK_VERSION(0, 21, 0)
50 # define snprintf _snprintf
53 #pragma GCC diagnostic warning "-Wformat"
54 #pragma GCC diagnostic warning "-Wformat-extra-args"
61 We stream human-readble tokens to stdout, and binary data (fonts,
62 bitmaps) to g_binary_out. Another process reads from those pipes, and
63 there lies the rub: things can deadlock, if the two involved
64 processes access the pipes in different order. At any point in
65 time, both processes must access the same pipe. To ensure this,
66 data must be flushed to the OS before writing to a different pipe,
67 otherwise not-yet-written data will leave the reading process
68 waiting on the wrong pipe.
74 /// cut off very small numbers & clamp value to zero
75 inline double normalize( double val
)
77 return fabs(val
) < 0.0000001 ? 0.0 : val
;
83 /** Escapes line-ending characters (\n and \r) in input string.
85 boost::shared_array
<char> lcl_escapeLineFeeds(const char* const i_pStr
)
87 size_t nLength(strlen(i_pStr
));
88 char* pBuffer
= new char[2*nLength
+1];
90 const char* pRead
= i_pStr
;
91 char* pWrite
= pBuffer
;
99 else if( *pRead
== '\n' )
104 else if( *pRead
== '\\' )
115 return boost::shared_array
<char>(pBuffer
);
120 /// for the temp char buffer the header gets snprintfed in
121 #define WRITE_BUFFER_SIZE 1024
123 /// for the initial std::vector capacity when copying stream from xpdf
124 #define WRITE_BUFFER_INITIAL_CAPACITY (1024*100)
126 void initBuf(OutputBuffer
& io_rBuffer
)
128 io_rBuffer
.reserve(WRITE_BUFFER_INITIAL_CAPACITY
);
131 void writeBinaryBuffer( const OutputBuffer
& rBuffer
)
133 // ---sync point--- see SYNC STREAMS above
136 // put buffer to stderr
137 if( !rBuffer
.empty() )
138 if( fwrite(&rBuffer
[0], sizeof(char),
139 rBuffer
.size(), g_binary_out
) != (size_t)rBuffer
.size() )
142 // ---sync point--- see SYNC STREAMS above
143 fflush(g_binary_out
);
146 bool ExtractJpegData(Stream
* str
, OutputBuffer
& outBuf
)
148 int bytesToMarker
= 0;
150 bool collectBytes
= false;
163 outBuf
.push_back((Output_t
)b1
);
169 if (bytesToMarker
== 0)
171 if (startOfScan
== 1)
183 outBuf
.push_back((Output_t
)0xFF);
184 outBuf
.push_back((Output_t
)0xD8);
195 else if (collectBytes
)
203 bytesToMarker
= b2
* 256 + b1
;
206 if (startOfScan
== 2)
207 if ((b2
== 0xFF) && (b1
== 0xD9))
212 void writeJpeg_( OutputBuffer
& o_rOutputBuf
, Stream
* str
, bool bWithLinefeed
)
214 // dump JPEG file as-is
215 #if POPPLER_CHECK_VERSION(0, 17, 3)
216 str
= str
->getNextStream();
218 str
= ((DCTStream
*)str
)->getRawStream();
222 o_rOutputBuf
.clear();
223 ExtractJpegData(str
, o_rOutputBuf
);
225 printf( " JPEG %d", (int)o_rOutputBuf
.size() );
232 void writePbm_(OutputBuffer
& o_rOutputBuf
, Stream
* str
, int width
, int height
, bool bWithLinefeed
, bool bInvert
)
234 // write as PBM (char by char, to avoid stdlib lineend messing)
235 o_rOutputBuf
.clear();
236 o_rOutputBuf
.resize(WRITE_BUFFER_SIZE
);
237 o_rOutputBuf
[0] = 'P';
238 o_rOutputBuf
[1] = '4';
239 o_rOutputBuf
[2] = 0x0A;
240 char *pAsCharPtr
= reinterpret_cast<char *>(&o_rOutputBuf
[3]);
241 int nOutLen
= snprintf(pAsCharPtr
, WRITE_BUFFER_SIZE
-10, "%d %d", width
, height
);
243 nOutLen
= WRITE_BUFFER_SIZE
-10;
244 o_rOutputBuf
[3+nOutLen
] =0x0A;
245 o_rOutputBuf
[3+nOutLen
+1]=0;
247 const int header_size
= 3+nOutLen
+1;
248 const int size
= height
* ((width
+ 7) / 8);
250 printf( " PBM %d", size
+ header_size
);
254 // trim buffer to exact header length
255 o_rOutputBuf
.resize(header_size
);
260 // copy the raw stream
263 for( int i
=0; i
<size
; ++i
)
264 o_rOutputBuf
.push_back(static_cast<char>(str
->getChar() ^ 0xff));
268 for( int i
=0; i
<size
; ++i
)
269 o_rOutputBuf
.push_back(static_cast<char>(str
->getChar()));
275 void writePpm_( OutputBuffer
& o_rOutputBuf
,
279 GfxImageColorMap
* colorMap
,
282 // write as PPM (char by char, to avoid stdlib lineend messing)
283 o_rOutputBuf
.clear();
284 o_rOutputBuf
.resize(WRITE_BUFFER_SIZE
);
285 o_rOutputBuf
[0] = 'P';
286 o_rOutputBuf
[1] = '6';
287 o_rOutputBuf
[2] = '\n';
288 char *pAsCharPtr
= reinterpret_cast<char *>(&o_rOutputBuf
[3]);
289 int nOutLen
= snprintf(pAsCharPtr
, WRITE_BUFFER_SIZE
-10, "%d %d", width
, height
);
291 nOutLen
= WRITE_BUFFER_SIZE
-10;
292 o_rOutputBuf
[3+nOutLen
] ='\n';
293 o_rOutputBuf
[3+nOutLen
+1]='2';
294 o_rOutputBuf
[3+nOutLen
+2]='5';
295 o_rOutputBuf
[3+nOutLen
+3]='5';
296 o_rOutputBuf
[3+nOutLen
+4]='\n';
297 o_rOutputBuf
[3+nOutLen
+5]=0;
299 const int header_size
= 3+nOutLen
+5;
300 const int size
= width
*height
*3 + header_size
;
302 printf( " PPM %d", size
);
306 // trim buffer to exact header size
307 o_rOutputBuf
.resize(header_size
);
312 ImageStream
* imgStr
=
315 colorMap
->getNumPixelComps(),
316 colorMap
->getBits());
319 for( int y
=0; y
<height
; ++y
)
321 p
= imgStr
->getLine();
322 for( int x
=0; x
<width
; ++x
)
324 colorMap
->getRGB(p
, &rgb
);
325 o_rOutputBuf
.push_back(colToByte(rgb
.r
));
326 o_rOutputBuf
.push_back(colToByte(rgb
.g
));
327 o_rOutputBuf
.push_back(colToByte(rgb
.b
));
329 p
+=colorMap
->getNumPixelComps();
337 // call this only for 1 bit image streams !
338 void writePng_( OutputBuffer
& o_rOutputBuf
,
347 o_rOutputBuf
.clear();
350 PngHelper::createPng( o_rOutputBuf
, str
, width
, height
, zeroColor
, oneColor
, bIsMask
);
352 printf( " PNG %d", (int)o_rOutputBuf
.size() );
357 void writePng_( OutputBuffer
& o_rOutputBuf
,
359 int width
, int height
, GfxImageColorMap
* colorMap
,
361 int maskWidth
, int maskHeight
, GfxImageColorMap
* maskColorMap
,
364 o_rOutputBuf
.clear();
367 PngHelper::createPng( o_rOutputBuf
, str
, width
, height
, colorMap
, maskStr
, maskWidth
, maskHeight
, maskColorMap
);
369 printf( " PNG %d", (int)o_rOutputBuf
.size() );
374 void writePng_( OutputBuffer
& o_rOutputBuf
,
376 int width
, int height
, GfxImageColorMap
* colorMap
,
378 int maskWidth
, int maskHeight
, bool maskInvert
,
381 o_rOutputBuf
.clear();
384 PngHelper::createPng( o_rOutputBuf
, str
, width
, height
, colorMap
, maskStr
, maskWidth
, maskHeight
, maskInvert
);
386 printf( " PNG %d", (int)o_rOutputBuf
.size() );
391 // stolen from ImageOutputDev.cc
392 void writeMask_( OutputBuffer
& o_rOutputBuf
, Stream
* str
, int width
, int height
, bool bWithLinefeed
, bool bInvert
)
394 if( str
->getKind() == strDCT
)
395 writeJpeg_(o_rOutputBuf
, str
, bWithLinefeed
);
397 writePbm_(o_rOutputBuf
, str
, width
, height
, bWithLinefeed
, bInvert
);
400 void writeImage_( OutputBuffer
& o_rOutputBuf
,
404 GfxImageColorMap
* colorMap
,
408 if( str
->getKind() == strDCT
&&
409 (colorMap
->getNumPixelComps() == 1 ||
410 colorMap
->getNumPixelComps() == 3) )
412 writeJpeg_(o_rOutputBuf
, str
, bWithLinefeed
);
414 else if (colorMap
->getNumPixelComps() == 1 &&
415 colorMap
->getBits() == 1)
417 // this is a two color bitmap, write a png
418 // provide default colors
419 GfxRGB zeroColor
= { 0, 0, 0 },
420 oneColor
= { byteToCol( 0xff ), byteToCol( 0xff ), byteToCol( 0xff ) };
421 if( colorMap
->getColorSpace()->getMode() == csIndexed
|| colorMap
->getColorSpace()->getMode() == csDeviceGray
)
424 colorMap
->getRGB( &nIndex
, &zeroColor
);
426 colorMap
->getRGB( &nIndex
, &oneColor
);
428 writePng_( o_rOutputBuf
, str
, width
, height
, zeroColor
, oneColor
, false, bWithLinefeed
);
431 writePpm_( o_rOutputBuf
, str
, width
, height
, colorMap
, bWithLinefeed
);
437 inline void writeImageLF( OutputBuffer
& o_rOutputBuf
,
441 GfxImageColorMap
* colorMap
) { writeImage_(o_rOutputBuf
,str
,width
,height
,colorMap
,true); }
442 inline void writeMaskLF( OutputBuffer
& o_rOutputBuf
,
446 bool bInvert
) { writeMask_(o_rOutputBuf
,str
,width
,height
,true,bInvert
); }
451 int PDFOutDev::parseFont( long long nNewId
, GfxFont
* gfxFont
, GfxState
* state
) const
453 FontAttributes aNewFont
;
456 GooString
* pFamily
= gfxFont
->getName();
459 aNewFont
.familyName
.clear();
460 aNewFont
.familyName
.append( gfxFont
->getName() );
464 aNewFont
.familyName
.clear();
465 aNewFont
.familyName
.append( "Arial" );
468 aNewFont
.isBold
= gfxFont
->isBold();
469 aNewFont
.isItalic
= gfxFont
->isItalic();
470 aNewFont
.size
= state
->getTransformedFontSize();
471 aNewFont
.isUnderline
= false;
473 if( gfxFont
->getType() == fontTrueType
|| gfxFont
->getType() == fontType1
)
475 // TODO(P3): Unfortunately, need to read stream twice, since
476 // we must write byte count to stdout before
477 char* pBuf
= gfxFont
->readEmbFontFile( m_pDoc
->getXRef(), &nSize
);
480 aNewFont
.isEmbedded
= true;
485 m_aFontMap
[ nNewId
] = aNewFont
;
489 void PDFOutDev::writeFontFile( GfxFont
* gfxFont
) const
491 if( gfxFont
->getType() != fontTrueType
&& gfxFont
->getType() != fontType1
)
495 char* pBuf
= gfxFont
->readEmbFontFile( m_pDoc
->getXRef(), &nSize
);
499 // ---sync point--- see SYNC STREAMS above
502 if( fwrite(pBuf
, sizeof(char), nSize
, g_binary_out
) != (size_t)nSize
)
507 // ---sync point--- see SYNC STREAMS above
508 fflush(g_binary_out
);
512 void PDFOutDev::printPath( GfxPath
* pPath
)
514 int nSubPaths
= pPath
? pPath
->getNumSubpaths() : 0;
515 for( int i
=0; i
<nSubPaths
; i
++ )
517 GfxSubpath
* pSub
= pPath
->getSubpath( i
);
518 const int nPoints
= pSub
->getNumPoints();
520 printf( " subpath %d", pSub
->isClosed() );
522 for( int n
=0; n
<nPoints
; ++n
)
525 normalize(pSub
->getX(n
)),
526 normalize(pSub
->getY(n
)),
532 PDFOutDev::PDFOutDev( PDFDoc
* pDoc
) :
535 m_pUtf8Map( new UnicodeMap("UTF-8", gTrue
, &mapUTF8
) ),
539 PDFOutDev::~PDFOutDev()
544 void PDFOutDev::startPage(int /*pageNum*/, GfxState
* state
545 #if POPPLER_CHECK_VERSION(0, 23, 0) || POPPLER_CHECK_VERSION(0, 24, 0)
551 printf("startPage %f %f\n",
552 normalize(state
->getPageWidth()),
553 normalize(state
->getPageHeight()));
556 void PDFOutDev::endPage()
561 #if POPPLER_CHECK_VERSION(0, 19, 0)
562 void PDFOutDev::processLink(AnnotLink
*link
)
563 #elif POPPLER_CHECK_VERSION(0, 17, 0)
564 void PDFOutDev::processLink(AnnotLink
*link
, Catalog
*)
566 void PDFOutDev::processLink(Link
* link
, Catalog
*)
572 link
->getRect( &x1
, &y1
, &x2
, &y2
);
574 LinkAction
* pAction
= link
->getAction();
575 if (pAction
&& pAction
->getKind() == actionURI
)
577 const char* pURI
= static_cast<LinkURI
*>(pAction
)->getURI()->getCString();
579 boost::shared_array
<char> pEsc( lcl_escapeLineFeeds(pURI
) );
581 printf( "drawLink %f %f %f %f %s\n",
590 void PDFOutDev::saveState(GfxState
*)
592 printf( "saveState\n" );
595 void PDFOutDev::restoreState(GfxState
*)
597 printf( "restoreState\n" );
600 void PDFOutDev::setDefaultCTM(double *pMat
)
604 OutputDev::setDefaultCTM(pMat
);
606 printf( "updateCtm %f %f %f %f %f %f\n",
612 normalize(pMat
[5]) );
615 void PDFOutDev::updateCTM(GfxState
* state
,
622 const double* const pMat
= state
->getCTM();
625 printf( "updateCtm %f %f %f %f %f %f\n",
631 normalize(pMat
[5]) );
634 void PDFOutDev::updateLineDash(GfxState
*state
)
640 double* dashArray
; int arrayLen
; double startOffset
;
641 state
->getLineDash(&dashArray
, &arrayLen
, &startOffset
);
643 printf( "updateLineDash" );
644 if( arrayLen
&& dashArray
)
646 printf( " %f %d", normalize(startOffset
), arrayLen
);
647 for( int i
=0; i
<arrayLen
; ++i
)
648 printf( " %f", normalize(*dashArray
++) );
653 void PDFOutDev::updateFlatness(GfxState
*state
)
658 printf( "updateFlatness %d\n", state
->getFlatness() );
661 void PDFOutDev::updateLineJoin(GfxState
*state
)
666 printf( "updateLineJoin %d\n", state
->getLineJoin() );
669 void PDFOutDev::updateLineCap(GfxState
*state
)
674 printf( "updateLineCap %d\n", state
->getLineCap() );
677 void PDFOutDev::updateMiterLimit(GfxState
*state
)
682 printf( "updateMiterLimit %f\n", normalize(state
->getMiterLimit()) );
685 void PDFOutDev::updateLineWidth(GfxState
*state
)
690 printf( "updateLineWidth %f\n", normalize(state
->getLineWidth()) );
693 void PDFOutDev::updateFillColor(GfxState
*state
)
700 state
->getFillRGB( &aRGB
);
702 printf( "updateFillColor %f %f %f %f\n",
703 normalize(colToDbl(aRGB
.r
)),
704 normalize(colToDbl(aRGB
.g
)),
705 normalize(colToDbl(aRGB
.b
)),
706 normalize(state
->getFillOpacity()) );
709 void PDFOutDev::updateStrokeColor(GfxState
*state
)
716 state
->getStrokeRGB( &aRGB
);
718 printf( "updateStrokeColor %f %f %f %f\n",
719 normalize(colToDbl(aRGB
.r
)),
720 normalize(colToDbl(aRGB
.g
)),
721 normalize(colToDbl(aRGB
.b
)),
722 normalize(state
->getFillOpacity()) );
725 void PDFOutDev::updateFillOpacity(GfxState
*state
)
729 updateFillColor(state
);
732 void PDFOutDev::updateStrokeOpacity(GfxState
*state
)
736 updateStrokeColor(state
);
739 void PDFOutDev::updateBlendMode(GfxState
*)
743 void PDFOutDev::updateFont(GfxState
*state
)
747 GfxFont
*gfxFont
= state
->getFont();
750 FontAttributes aFont
;
753 Ref
* pID
= gfxFont
->getID();
754 // TODO(Q3): Portability problem
755 long long fontID
= (long long)pID
->gen
<< 32 | (long long)pID
->num
;
756 std::unordered_map
< long long, FontAttributes
>::const_iterator it
=
757 m_aFontMap
.find( fontID
);
758 if( it
== m_aFontMap
.end() )
760 nEmbedSize
= parseFont( fontID
, gfxFont
, state
);
761 it
= m_aFontMap
.find( fontID
);
764 printf( "updateFont" );
765 if( it
!= m_aFontMap
.end() )
767 // conflating this with printf below crashes under Windoze
768 printf( " %lld", fontID
);
772 boost::shared_array
<char> pEsc( lcl_escapeLineFeeds(aFont
.familyName
.getCString()) );
773 printf( " %d %d %d %d %f %d %s",
778 normalize(state
->getTransformedFontSize()),
785 writeFontFile(gfxFont
);
789 void PDFOutDev::updateRender(GfxState
*state
)
793 printf( "setTextRenderMode %d\n", state
->getRender() );
796 void PDFOutDev::stroke(GfxState
*state
)
802 printf( "strokePath" );
803 printPath( state
->getPath() );
807 void PDFOutDev::fill(GfxState
*state
)
813 printf( "fillPath" );
814 printPath( state
->getPath() );
818 void PDFOutDev::eoFill(GfxState
*state
)
824 printf( "eoFillPath" );
825 printPath( state
->getPath() );
829 void PDFOutDev::clip(GfxState
*state
)
835 printf( "clipPath" );
836 printPath( state
->getPath() );
840 void PDFOutDev::eoClip(GfxState
*state
)
846 printf( "eoClipPath" );
847 printPath( state
->getPath() );
855 horizontal skip for character (already scaled with font size) +
856 inter-char space: cursor is shifted by this amount for next char
859 vertical skip for character (zero for horizontal writing mode):
860 cursor is shifted by this amount for next char
863 local offset of character (zero for horizontal writing mode). not
864 taken into account for output pos updates. Used for vertical writing.
867 local offset of character (zero for horizontal writing mode). not
868 taken into account for output pos updates. Used for vertical writing.
870 void PDFOutDev::drawChar(GfxState
*state
, double x
, double y
,
871 double dx
, double dy
,
872 double originX
, double originY
,
873 CharCode
, int /*nBytes*/, Unicode
*u
, int uLen
)
882 if (state
->getFont()->getWMode())
884 csdy
= state
->getCharSpace();
886 csdy
+= state
->getWordSpace();
890 csdx
= state
->getCharSpace();
892 csdx
+= state
->getWordSpace();
893 csdx
*= state
->getHorizScaling();
898 state
->textTransformDelta(csdx
, csdy
, &cstdx
, &cstdy
);
900 const double fontSize
= state
->getFontSize();
902 const double aPositionX(x
-originX
);
903 const double aPositionY(y
-originY
);
905 const double* pTextMat
=state
->getTextMat();
906 printf( "drawChar %f %f %f %f %f %f %f %f %f ",
907 normalize(aPositionX
),
908 normalize(aPositionY
),
909 normalize(aPositionX
+ dx
- cstdx
),
910 normalize(aPositionY
+ dy
- cstdy
),
911 normalize(pTextMat
[0]),
912 normalize(pTextMat
[2]),
913 normalize(pTextMat
[1]),
914 normalize(pTextMat
[3]),
918 // silence spurious warning
922 for( int i
=0; i
<uLen
; ++i
)
924 buf
[ m_pUtf8Map
->mapUnicode(u
[i
], buf
, sizeof(buf
)-1) ] = 0;
925 boost::shared_array
<char> pEsc( lcl_escapeLineFeeds(buf
) );
926 printf( "%s", pEsc
.get() );
932 void PDFOutDev::drawString(GfxState
*, GooString
* /*s*/)
937 void PDFOutDev::endTextObject(GfxState
*)
939 printf( "endTextObject\n" );
942 void PDFOutDev::drawImageMask(GfxState
* pState
, Object
*, Stream
* str
,
943 int width
, int height
, GBool invert
,
944 #if POPPLER_CHECK_VERSION(0, 12, 0)
945 GBool
/*interpolate*/,
947 GBool
/*inlineImg*/ )
951 OutputBuffer aBuf
; initBuf(aBuf
);
953 printf( "drawMask %d %d %d", width
, height
, invert
);
955 int bitsPerComponent
= 1;
956 StreamColorSpaceMode csMode
= streamCSNone
;
957 str
->getImageParams( &bitsPerComponent
, &csMode
);
958 if( bitsPerComponent
== 1 && (csMode
== streamCSNone
|| csMode
== streamCSDeviceGray
) )
960 GfxRGB oneColor
= { dblToCol( 1.0 ), dblToCol( 1.0 ), dblToCol( 1.0 ) };
961 GfxRGB zeroColor
= { dblToCol( 0.0 ), dblToCol( 0.0 ), dblToCol( 0.0 ) };
962 pState
->getFillColorSpace()->getRGB( pState
->getFillColor(), &zeroColor
);
964 writePng_( aBuf
, str
, width
, height
, oneColor
, zeroColor
, true, true );
966 writePng_( aBuf
, str
, width
, height
, zeroColor
, oneColor
, true, true );
969 writeMaskLF(aBuf
, str
, width
, height
, invert
);
970 writeBinaryBuffer(aBuf
);
973 void PDFOutDev::drawImage(GfxState
*, Object
*, Stream
* str
,
974 int width
, int height
, GfxImageColorMap
* colorMap
,
975 #if POPPLER_CHECK_VERSION(0, 12, 0)
976 GBool
/*interpolate*/,
978 int* maskColors
, GBool
/*inlineImg*/ )
982 OutputBuffer aBuf
; initBuf(aBuf
);
983 OutputBuffer aMaskBuf
;
985 printf( "drawImage %d %d", width
, height
);
989 // write mask colors. nBytes must be even - first half is
990 // lower bound values, second half upper bound values
991 if( colorMap
->getColorSpace()->getMode() == csIndexed
)
993 aMaskBuf
.push_back( (char)maskColors
[0] );
994 aMaskBuf
.push_back( (char)maskColors
[gfxColorMaxComps
] );
999 colorMap
->getColorSpace()->getRGB(
1000 reinterpret_cast<GfxColor
*>(maskColors
),
1004 colorMap
->getColorSpace()->getRGB(
1005 reinterpret_cast<GfxColor
*>(maskColors
)+gfxColorMaxComps
,
1008 aMaskBuf
.push_back( colToByte(aMinRGB
.r
) );
1009 aMaskBuf
.push_back( colToByte(aMinRGB
.g
) );
1010 aMaskBuf
.push_back( colToByte(aMinRGB
.b
) );
1011 aMaskBuf
.push_back( colToByte(aMaxRGB
.r
) );
1012 aMaskBuf
.push_back( colToByte(aMaxRGB
.g
) );
1013 aMaskBuf
.push_back( colToByte(aMaxRGB
.b
) );
1017 printf( " %d", (int)aMaskBuf
.size() );
1018 writeImageLF( aBuf
, str
, width
, height
, colorMap
);
1019 writeBinaryBuffer(aBuf
);
1020 writeBinaryBuffer(aMaskBuf
);
1023 void PDFOutDev::drawMaskedImage(GfxState
*, Object
*, Stream
* str
,
1024 int width
, int height
,
1025 GfxImageColorMap
* colorMap
,
1026 #if POPPLER_CHECK_VERSION(0, 12, 0)
1027 GBool
/*interpolate*/,
1030 int maskWidth
, int maskHeight
,
1032 #if POPPLER_CHECK_VERSION(0, 12, 0)
1033 , GBool
/*maskInterpolate*/
1039 OutputBuffer aBuf
; initBuf(aBuf
);
1040 printf( "drawImage %d %d 0", width
, height
);
1041 writePng_( aBuf
, str
, width
, height
, colorMap
, maskStr
, maskWidth
, maskHeight
, maskInvert
, true );
1042 writeBinaryBuffer( aBuf
);
1045 void PDFOutDev::drawSoftMaskedImage(GfxState
*, Object
*, Stream
* str
,
1046 int width
, int height
,
1047 GfxImageColorMap
* colorMap
,
1048 #if POPPLER_CHECK_VERSION(0, 12, 0)
1049 GBool
/*interpolate*/,
1052 int maskWidth
, int maskHeight
,
1053 GfxImageColorMap
* maskColorMap
1054 #if POPPLER_CHECK_VERSION(0, 12, 0)
1055 , GBool
/*maskInterpolate*/
1061 OutputBuffer aBuf
; initBuf(aBuf
);
1062 printf( "drawImage %d %d 0", width
, height
);
1063 writePng_( aBuf
, str
, width
, height
, colorMap
, maskStr
, maskWidth
, maskHeight
, maskColorMap
, true );
1064 writeBinaryBuffer( aBuf
);
1067 void PDFOutDev::setPageNum( int nNumPages
)
1069 // TODO(F3): printf might format int locale-dependent!
1070 printf("setPageNum %d\n", nNumPages
);
1073 void PDFOutDev::setSkipImages( bool bSkipImages
)
1075 m_bSkipImages
= bSkipImages
;
1080 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */