Implement EmbedStream::reset() to fix pdftops -level1sep -optimizecolorspace for in-line images.

parent 91d95545
......@@ -1069,6 +1069,7 @@ EmbedStream::EmbedStream(Stream *strA, Object &&dictA, bool limitedA, Goffset le
reusable = reusableA;
record = false;
replay = false;
start = str->getPos();
if (reusable) {
bufData = (unsigned char *)gmalloc(16384);
bufMax = 16384;
......@@ -1083,13 +1084,27 @@ EmbedStream::~EmbedStream()
gfree(bufData);
}
void EmbedStream::reset()
{
if (str->getPos() != start) {
str->reset();
// Might be a FilterStream that does not support str->setPos(start)
while (str->getPos() < start) {
str->getChar();
}
}
record = false;
replay = false;
bufPos = 0;
}
BaseStream *EmbedStream::copy()
{
error(errInternal, -1, "Called copy() on EmbedStream");
return nullptr;
}
Stream *EmbedStream::makeSubStream(Goffset start, bool limitedA, Goffset lengthA, Object &&dictA)
Stream *EmbedStream::makeSubStream(Goffset startA, bool limitedA, Goffset lengthA, Object &&dictA)
{
error(errInternal, -1, "Called makeSubStream() on EmbedStream");
return nullptr;
......
......@@ -747,7 +747,7 @@ public:
BaseStream *copy() override;
Stream *makeSubStream(Goffset start, bool limitedA, Goffset lengthA, Object &&dictA) override;
StreamKind getKind() const override { return str->getKind(); }
void reset() override { }
void reset() override;
int getChar() override;
int lookChar() override;
Goffset getPos() override;
......@@ -774,6 +774,7 @@ private:
long bufMax;
long bufLen;
long bufPos;
Goffset start;
};
//------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment