aboutsummaryrefslogtreecommitdiffstats
path: root/examples/pdf-invert-images.cc
diff options
context:
space:
mode:
Diffstat (limited to 'examples/pdf-invert-images.cc')
-rw-r--r--examples/pdf-invert-images.cc19
1 files changed, 5 insertions, 14 deletions
diff --git a/examples/pdf-invert-images.cc b/examples/pdf-invert-images.cc
index 72a15f2c..bb8541e3 100644
--- a/examples/pdf-invert-images.cc
+++ b/examples/pdf-invert-images.cc
@@ -25,15 +25,13 @@ void usage()
// allocate memory up front for the objects. We want to replace the
// stream data with a function of the original stream data. In order
// to do this without actually holding all the images in memory, we
-// create another QPDF object and copy the streams. Copying the
-// streams doesn't actually copy the data. Internally, the qpdf
-// library is holding onto the location of the stream data in the
-// original file, which makes it possible for the StreamDataProvider
-// to access it when it needs it.
+// create copies of the streams. Copying the streams doesn't actually
+// copy the data. Internally, the qpdf library is holding onto the
+// location of the original stream data, which makes it possible for
+// the StreamDataProvider to access it when it needs it.
class ImageInverter: public QPDFObjectHandle::StreamDataProvider
{
public:
- ImageInverter();
virtual ~ImageInverter()
{
}
@@ -45,16 +43,9 @@ class ImageInverter: public QPDFObjectHandle::StreamDataProvider
PointerHolder<QPDFObjectHandle::StreamDataProvider> self);
private:
- QPDF other;
- // Map og in original to copied image
std::map<QPDFObjGen, QPDFObjectHandle> copied_images;
};
-ImageInverter::ImageInverter()
-{
- this->other.emptyPDF();
-}
-
void
ImageInverter::registerImage(
QPDFObjectHandle image,
@@ -77,7 +68,7 @@ ImageInverter::registerImage(
{
return;
}
- this->copied_images[og] = this->other.copyForeignObject(image);
+ this->copied_images[og] = image.copyStream();
// Register our stream data provider for this stream. Future calls
// to getStreamData or pipeStreamData will use the new