InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SnapshotUtils.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Seoras Ashby
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //
23 // SnapshotUtils draws items into a memory based graphics context creating a bitmap,
24 // or "snapshot", that can be exported to a stream in a variety of formats. Drawing
25 // is performed internally by SnapshotUtils via the draw manager IDrawMgr.
26 //
27 // Overloaded constructors assist in the creation of snapshots of:
28 // complete spreads, pages and page items or;
29 // selected areas of these items or;
30 // items drawn later by the caller via the Draw() method.
31 //
32 // The constructors allow the caller to control the scale of the snapshot, the amount
33 // of bleed, the drawing flags passed to IDrawMgr, whether graphics and images
34 // are rendered in full resolution or by proxy, whether a grayscale or RGB bitmap is
35 // made and whether an alpha channel for pixel transparency should be generated.
36 //
37 // After constructing a SnapshotUtils() object the caller must call GetStatus() to
38 // check the snapshot was created successfully.
39 //
40 // If successful the caller can access the snapshot by exporting it to a stream
41 // via the ExportImage() method. The snapshot bitmap is filtered by the image write format
42 // service specified by the caller and written to the stream. A variety of filters are
43 // available (e.g. JPEG, TIFF, GIF).
44 //
45 // Notes:
46 //
47 // The default resolution of the snapshot bitmap is 72 dpi.
48 //
49 // The maximum size of bitmap frame buffer allocated by SnapshotUtils is 2MB.
50 //
51 // Downsampling will be applied if the area to be drawn could not be rendered at the requested
52 // scale within the limits of the frame buffer.
53 //
54 // GetStatus() will return kFailure if memory could not be allocated for any reason or if
55 // the area to be drawn still could not be rendered within the limited size of frame buffer
56 // after downsampling.
57 //
58 // Sample:
59 //
60 // void ItemSnapshot(const UIDRef& itemUIDRef, IPMStream* stream)
61 //
62 // SnapshotUtils snapshot(itemUIDRef);
63 // if (snapshot.GetStatus() == kSuccess)
64 // snapshot.ExportImage(kJPEGImageWriteFormatBoss, stream);
65 //
66 //========================================================================================
67 
68 #ifndef __SnapshotUtils_h__
69 #define __SnapshotUtils_h__
70 
71 class IPMStream;
72 class IDataBase;
73 
74 #include "IShape.h"
75 #include "AGMGraphicsContext.h"
76 #include "AGMImageAccessor.h"
77 
78 class SnapshotUtilsImpl;
79 
89 #ifdef ID_DEPRECATED
90 
91 class SnapshotUtils
92 {
93 public:
94 
99  typedef enum
100  {
101  kSSJPEGBaseline,
102  kSSJPEGProgressive
103  } SSJPEGEncoding;
104 
108  typedef enum
109  {
110  kSSJPEGLowQuality,
111  kSSJPEGGoodQuality,
112  kSSJPEGExcellentQuality,
113  kSSJPEGGreatQuality
114  } SSJPEGQuality;
115 
118  typedef enum
119  {
120  kNoPalette, // Indicates that the image should not be indexed
121  kTryExactThenAdaptivePalette, // attempts to create an Exact Color Table. If it can't then an Adaptive Palette will be created.
122  kMacPalette, // Use the Macintosh 256 entry system palette from Photoshop
123  kWebPalette, // Use a 216 entry web safe color palette
124  kWinPalette // Use the Windows 256 entry system palette from Photoshop
125  } PaletteType;
126 
129  typedef enum
130  {
131  kXPOff = 0,
132  kXPLow, // Crude approximations of transparency effects, blends honored
133  kXPMedium, // Low quality transparency effects, no page isolation set
134  kXPHigh, // Normal
135  kXPMaximum // Resolution independent transparency effects (may not be implemented)
136  } Transparencies;
137 
165  SnapshotUtils
166  (
167  const UIDRef& itemUIDRef,
168  const PMReal& xScaleFactor = 1.0,
169  const PMReal& yScaleFactor = 1.0,
170  const PMReal& desiredRes = 72.0,
171  const PMReal& minRes = 72.0,
172  const PMReal& bleedAmount = 0.0,
173  int32 flags = IShape::kPreviewMode,
174  bool8 fullResolutionGraphics = kFalse,
175  bool8 drawGray = kFalse,
176  bool8 addTransparencyAlpha = kFalse,
177  Transparencies transparencyQuality = kXPHigh,
178  const PMReal& greekBelowPtSize = 7.0,
179  bool8 antiAliasing = kTrue,
180  bool8 overprintPreview = kFalse
181  );
182 
183 
211  SnapshotUtils
212  (
213  const PMRect& clippingBounds,
214  const PMMatrix& boundsToSpreadMatrix,
215  const UIDRef& itemUIDRef,
216  const PMReal& xScaleFactor = 1.0,
217  const PMReal& yScaleFactor = 1.0,
218  const PMReal& desiredRes = 72.0,
219  const PMReal& minRes = 72.0,
220  const PMReal& bleedAmount = 0.0,
221  int32 flags = IShape::kPreviewMode,
222  bool8 fullResolutionGraphics = kFalse,
223  bool8 drawGray = kFalse,
224  bool8 addTransparencyAlpha = kFalse,
225  Transparencies transparencyQuality = kXPHigh,
226  const PMReal& greekBelowPtSize = 7.0,
227  bool8 antiAliasing = kTrue,
228  bool8 overprintPreview = kFalse
229  );
230 
231 
260  SnapshotUtils
261  (
262  const PMRect& clippingBounds,
263  const PMMatrix& boundsToSpreadMatrix,
264  IDataBase* database,
265  const PMReal& xScaleFactor = 1.0,
266  const PMReal& yScaleFactor = 1.0,
267  const PMReal& desiredRes = 72.0,
268  const PMReal& minRes = 72.0,
269  const PMReal& bleedAmount = 0.0,
270  int32 flags = IShape::kPreviewMode,
271  bool8 fullResolutionGraphics = kFalse,
272  bool8 drawGray = kFalse,
273  bool8 addTransparencyAlpha = kFalse,
274  Transparencies transparencyQuality = kXPHigh,
275  const PMReal& greekBelowPtSize = 7.0,
276  bool8 antiAliasing = kTrue,
277  bool8 overprintPreview = kFalse
278  );
279 
284  virtual ~SnapshotUtils();
285 
292  ErrorCode GetStatus() const;
293 
297  void Draw(const UID& itemUID);
298 
308  ErrorCode ExportImage
309  (
310  ClassID formatClass,
311  IPMStream* writeStream,
312  bool8 colorMapped = kFalse
313  );
314 
323  ErrorCode ExportImageToJPEG
324  (
325  IPMStream* writeStream,
326  SSJPEGEncoding encoding = kSSJPEGBaseline,
327  SSJPEGQuality quality = kSSJPEGExcellentQuality
328  );
329 
335  ErrorCode ExportImageToTIFF
336  (
337  IPMStream* writeStream,
338  PaletteType paletteType = kNoPalette
339  );
340 
349  ErrorCode ExportImageToGIF
350  (
351  IPMStream* writeStream,
352  PaletteType paletteType = kTryExactThenAdaptivePalette,
353  bool8 interlaced = kFalse
354  );
355 
359  AGMGraphicsContext * GetGraphicsContext(void) const;
360 
365  AGMImageAccessor * CreateAGMImageAccessor(void) const;
366 
373  AGMImageAccessor * CreateAlphaAGMImageAccessor(void) const;
374 
375 private:
376  SnapshotUtilsImpl *fImpl;
377 };
378 #endif
379 
380 #endif
381 
382 // End, SnapshotUtils.h