InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SnapshotUtilsEx.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Dave Stephens
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 // SnapshotUtilsEx 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.
30 //
31 // The constructors allow the caller to control the scale of the snapshot, the amount
32 // of bleed, whether a grayscale, RGB, CMYK or Lab bitmap is
33 // made and whether an alpha channel for pixel transparency should be generated.
34 //
35 // After construction of a SnapshotUtilsEx, it is necessary to call Draw() with
36 // the desired draw options, including draw quality, anti-aliasing, transparency quality,
37 // text greeking and draw flags.
38 //
39 // If Draw() is successful the caller can access the snapshot by exporting it to a stream
40 // via the Export methods or accessing it directly via CreateAGMImageAccessor.
41 // If exporting to a stream, 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 // Downsampling will be applied if the area to be drawn could not be rendered at the requested
50 // scale within the limits of the frame buffer.
51 //
52 // GetStatus() will return kFailure if memory could not be allocated for any reason or if
53 // the area to be drawn still could not be rendered within the limited size of frame buffer
54 // after downsampling.
55 //
56 // Sample:
57 //
58 // void ItemSnapshot(const UIDRef& itemUIDRef, IPMStream* stream)
59 //
60 // SnapshotUtils snapshot(itemUIDRef);
61 // if (snapshot.Draw()
62 // snapshot.ExportImageToJPEG(stream);
63 //
64 //========================================================================================
65 
66 #ifndef __SnapshotUtilsEx_h__
67 #define __SnapshotUtilsEx_h__
68 
69 class IPMStream;
70 class IDataBase;
71 
72 #include "IShape.h"
73 #include "AGMGraphicsContext.h"
74 #include "AGMImageAccessor.h"
75 #include "SnapshotUtils.h"
76 #include <map>
77 
78 class SnapshotUtilsExImpl;
79 class IdleTimer;
80 
81 //VPAttrMap is a map of view port attribute class IDs and values corresponding to them
82 typedef std::map<ClassID, PMReal> VPAttrMap;
83 
89 {
90 public:
93  typedef enum {
94  kCsGray,
95  kCsRGB,
96  kCsCMYK,
97  kCsLab
99 
122  (
123  const UIDRef& itemUIDRef,
124  const PMReal& xScaleFactor = 1.0,
125  const PMReal& yScaleFactor = 1.0,
126  const PMReal& desiredRes = 72.0,
127  const PMReal& minRes = 72.0,
128  const PMReal& bleedAmount = 0.0,
129  SSColorSpaceFamily colorSpace = kCsRGB,
130  bool8 addTransparencyAlpha = kFalse,
131  bool8 simulateOverprint = kFalse
132  );
133 
156  (
157  const PMRect& clippingBounds,
158  const PMMatrix& boundsToSpreadMatrix,
159  const UIDRef& itemUIDRef,
160  const PMReal& xScaleFactor = 1.0,
161  const PMReal& yScaleFactor = 1.0,
162  const PMReal& desiredRes = 72.0,
163  const PMReal& minRes = 72.0,
164  const PMReal& bleedAmount = 0.0,
165  SSColorSpaceFamily colorSpace = kCsRGB,
166  bool8 addTransparencyAlpha = kFalse,
167  bool8 simulateOverprint = kFalse
168  );
169 
170 
194  (
195  const PMRect& clippingBounds,
196  const PMMatrix& boundsToSpreadMatrix,
197  IDataBase* database,
198  const PMReal& xScaleFactor = 1.0,
199  const PMReal& yScaleFactor = 1.0,
200  const PMReal& desiredRes = 72.0,
201  const PMReal& minRes = 72.0,
202  const PMReal& bleedAmount = 0.0,
203  SSColorSpaceFamily colorSpace = kCsRGB,
204  bool8 addTransparencyAlpha = kFalse,
205  bool8 simulateOverprint = kFalse
206  );
207 
212  virtual ~SnapshotUtilsEx();
213 
214 
244  ErrorCode Draw(int32 flags = IShape::kPreviewMode,
245  bool32 fullResolutionGraphics = kFalse,
246  const PMReal& greekBelowPtSize = 7.0,
247  bool32 enableAntiAliasing = kTrue,
248  SnapshotUtils::Transparencies transparencyQuality = SnapshotUtils::kXPHigh,
249  IdleTimer *abortCheck = nil,
250  VPAttrMap* pVPAttrMap = nil,
251  bool32 bDrawNonPrintingObjects = kTrue
252  );
253 
282  ErrorCode Draw(UID pageItem,
283  int32 flags,
284  bool32 fullResolutionGraphics,
285  const PMReal& greekBelowPtSize,
286  bool32 enableAntiAliasing,
287  SnapshotUtils::Transparencies transparencyQuality,
288  IdleTimer *abortCheck = nil,
289  VPAttrMap* pVPAttrMap = nil,
290  bool32 bDrawNonPrintingObjects = kTrue
291  );
292 
303  ErrorCode ExportImage
304  (
305  ClassID formatClass,
306  IPMStream* writeStream,
307  bool8 colorMapped
308  );
309 
319  ErrorCode ExportImageToJPEG
320  (
321  IPMStream* writeStream,
322  SnapshotUtils::SSJPEGEncoding encoding = SnapshotUtils::kSSJPEGBaseline,
323  SnapshotUtils::SSJPEGQuality quality = SnapshotUtils::kSSJPEGExcellentQuality,
324  bool embedColorProfile = false
325  );
326 
333  ErrorCode ExportImageToTIFF
334  (
335  IPMStream* writeStream,
336  SnapshotUtils::PaletteType paletteType = SnapshotUtils::kNoPalette,
337  bool embedColorProfile = false
338  );
339 
348  ErrorCode ExportImageToGIF
349  (
350  IPMStream* writeStream,
351  SnapshotUtils::PaletteType paletteType = SnapshotUtils::kTryExactThenAdaptivePalette,
352  bool8 interlaced = kFalse
353  );
354 
361  ErrorCode ExportImageToPNG
362  (
363  IPMStream* writeStream,
364  uint32 compression = 5
365  );
366 
374 
382 
392 
393 protected:
394  SnapshotUtilsExImpl *fImpl;
395 };
396 
397 #endif
398 
399 // End, SnapshotUtilsEx.h