OLD | NEW |
| (Empty) |
1 | |
2 /* | |
3 * Copyright 2010 The Android Open Source Project | |
4 * | |
5 * Use of this source code is governed by a BSD-style license that can be | |
6 * found in the LICENSE file. | |
7 */ | |
8 | |
9 | |
10 #ifndef SkPDFImage_DEFINED | |
11 #define SkPDFImage_DEFINED | |
12 | |
13 #include "SkPicture.h" | |
14 #include "SkPDFDevice.h" | |
15 #include "SkPDFStream.h" | |
16 #include "SkPDFTypes.h" | |
17 #include "SkRefCnt.h" | |
18 | |
19 class SkBitmap; | |
20 class SkData; | |
21 class SkPDFCatalog; | |
22 struct SkIRect; | |
23 | |
24 /** | |
25 * Return the mose efficient availible encoding of the given bitmap. | |
26 */ | |
27 SkPDFObject* SkPDFCreateImageObject(SkPDFCanon* canon, | |
28 const SkBitmap&, | |
29 const SkIRect& subset); | |
30 | |
31 /** \class SkPDFImage | |
32 | |
33 An image XObject. | |
34 */ | |
35 | |
36 // We could play the same trick here as is done in SkPDFGraphicState, storing | |
37 // a copy of the Bitmap object (not the pixels), the pixel generation number, | |
38 // and settings used from the paint to canonicalize image objects. | |
39 class SkPDFImage : public SkPDFStream { | |
40 public: | |
41 /** Create a new Image XObject to represent the passed bitmap. | |
42 * @param bitmap The image to encode. | |
43 * @param srcRect The rectangle to cut out of bitmap. | |
44 * @param paint Used to calculate alpha, masks, etc. | |
45 * @return The image XObject or NUll if there is nothing to draw for | |
46 * the given parameters. | |
47 */ | |
48 static SkPDFImage* CreateImage(const SkBitmap& bitmap, | |
49 const SkIRect& srcRect); | |
50 | |
51 virtual ~SkPDFImage(); | |
52 | |
53 bool isEmpty() { | |
54 return fSrcRect.isEmpty(); | |
55 } | |
56 | |
57 private: | |
58 SkBitmap fBitmap; | |
59 bool fIsAlpha; | |
60 SkIRect fSrcRect; | |
61 bool fStreamValid; | |
62 | |
63 /** Create a PDF image XObject. Entries for the image properties are | |
64 * automatically added to the stream dictionary. | |
65 * @param stream The image stream. May be NULL. Otherwise, this | |
66 * (instead of the input bitmap) will be used as the | |
67 * PDF's content stream, possibly with lossless encoding. | |
68 * Will be duplicated, and left in indeterminate state. | |
69 * @param bitmap The image. If a stream is not given, its color data | |
70 * will be used as the image. If a stream is given, this | |
71 * is used for configuration only. | |
72 * @param isAlpha Whether or not this is the alpha of an image. | |
73 * @param srcRect The clipping applied to bitmap before generating | |
74 * imageData. | |
75 */ | |
76 SkPDFImage(SkStream* stream, const SkBitmap& bitmap, bool isAlpha, | |
77 const SkIRect& srcRect); | |
78 | |
79 /** Copy constructor, used to generate substitutes. | |
80 * @param image The SkPDFImage to copy. | |
81 */ | |
82 SkPDFImage(SkPDFImage& pdfImage); | |
83 | |
84 // Populate the stream dictionary. This method returns false if | |
85 // fSubstitute should be used. | |
86 virtual bool populate(SkPDFCatalog* catalog); | |
87 | |
88 typedef SkPDFStream INHERITED; | |
89 }; | |
90 | |
91 #endif | |
OLD | NEW |