aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFImageStream.h
blob: c518081518b7859cdece2e9897be5d5eb43a3c30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 * Copyright 2013 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkPDFImageStream_DEFINED
#define SkPDFImageStream_DEFINED

#include "SkBitmap.h"
#include "SkPDFDevice.h"
#include "SkPDFStream.h"
#include "SkPDFTypes.h"
#include "SkRect.h"
#include "SkRefCnt.h"
#include "SkStream.h"
#include "SkTemplates.h"

class SkPDFCatalog;

/** \class SkPDFImageStream

    An image stream object in a PDF.  Note, all streams must be indirect objects
    (via SkObjRef).
    This class is similar to SkPDFStream, but it is also able to use image
    specific compression. Currently we support DCT(jpeg) and flate(zip).
*/
class SkPDFImageStream : public SkPDFStream {
public:
    /** Create a PDF stream with the same content and dictionary entries
     *  as the passed one.
     */
    explicit SkPDFImageStream(const SkPDFImageStream& pdfStream);
    virtual ~SkPDFImageStream();

protected:
    SkPDFImageStream(SkStream* stream, const SkBitmap& bitmap,
                     const SkIRect& srcRect, EncodeToDCTStream encoder);

    // Populate the stream dictionary.  This method returns false if
    // fSubstitute should be used.
    virtual bool populate(SkPDFCatalog* catalog);

private:
    const SkBitmap fBitmap;
    const SkIRect fSrcRect;
    EncodeToDCTStream fEncoder;

    typedef SkPDFStream INHERITED;
};

#endif