DrawKit
Vector and illustration framework for Mac OS X
Instance Methods | List of all members
DKDrawing(Export) Category Reference

This category provides methods for exporting drawings in a variety of formats, such as TIFF, JPEG and PNG. More...

Instance Methods

(CGImageRef- CGImageWithResolution:hasAlpha:
 Creates the initial bitmap image that the various bitmap formats are created from. More...
 
(CGImageRef- CGImageWithResolution:hasAlpha:relativeScale:
 
(NSData *) - JPEGDataWithProperties:
 Returns JPEG data for the drawing. More...
 
(NSData *) - JPEGDataWithResolution:quality:progressive:
 Returns JPEG data for the drawing or nil if there was a problem. More...
 
(NSArray *) - layerBitmapsWithDPI:
 Returns an array of bitmaps (NSBitmapImageReps) one per layer. More...
 
(NSData *) - multipartTIFFDataWithResolution:
 Returns TIFF data. More...
 
(NSData *) - PNGDataWithProperties:
 Returns PNG data for the drawing. More...
 
(NSData *) - PNGDataWithResolution:gamma:interlaced:
 
(NSData *) - thumbnailData
 Returns JPEG data for the drawing at 50% actual size, with 50% quality. More...
 
(NSData *) - TIFFDataWithProperties:
 Returns TIFF data for the drawing. More...
 
(NSData *) - TIFFDataWithResolution:compressionType:
 Returns TIFF data for the drawing or nil if there was a problem. More...
 

Detailed Description

This category provides methods for exporting drawings in a variety of formats, such as TIFF, JPEG and PNG.

Author
Contributions from the community; see CONTRIBUTORS.md
Date
2005-2015

This category provides methods for exporting drawings in a variety of formats, such as TIFF, JPEG and PNG. As these are all bitmap formats, a way to specify the resolution of the exported image is also provided. All methods return NSData that is the formatted image data - this can be written directly as a file of the designated kind.

All image export starts with the pdf representation of the drawing as exported directly by DKDrawing. This is then imaged into a new bitmap image rep before conversion to the final format. The use of the pdf data ensures that results are consistent and require no major knowledge of the drawing's internals.

All images are exported in 24/32 bit full colour.

dpi is specified directly, e.g. 72 for 72 dpi, 150 for 150 dpi, etc. The image size will be the drawing size scaled by the dpi, so a 144dpi image will be twice as wide and twice as high as the drawing. If the dpi passed does not result in a whole multiple of the drawing size, it is rounded up to the nearest whole value that is.

This uses Image I/O to perform the data encoding.

Method Documentation

- (CGImageRef) CGImageWithResolution: (NSInteger dpi
hasAlpha: (BOOL hasAlpha 

Creates the initial bitmap image that the various bitmap formats are created from.

Returned ref is autoreleased. The image always has an alpha channel, but the <hasAlpha> flag will paint the background in the paper colour if hasAlpha is NO.

Parameters
dpithe resolution of the image in dots per inch.
hasAlphaspecifies whether the image is painted in the background paper colour or not.
relScalescaling factor, 1.0 = actual size, 0.5 = half size, etc.
Returns
a CG image that is used to generate the export image formats

Extends class DKDrawing.

- (CGImageRef) CGImageWithResolution: (NSInteger dpi
hasAlpha: (BOOL hasAlpha
relativeScale: (CGFloat relScale 

Extends class DKDrawing.

- (NSData*) JPEGDataWithProperties: (NSDictionary *)  props

Returns JPEG data for the drawing.

Parameters
propsvarious parameters and properties
Returns
JPEG data or nil if there was a problem DrawKit properties that control the data generation. Users may find the convenience methods below easier to use for many typical situations.

Extends class DKDrawing.

- (NSData*) JPEGDataWithResolution: (NSInteger dpi
quality: (CGFloat quality
progressive: (BOOL progressive 

Returns JPEG data for the drawing or nil if there was a problem.

This is a convenience wrapper around the dictionary-based methods above

Parameters
dpithe resolution in dots per inch
qualitya value 0..1 that indicates the amount of compression - 0 = max, 1 = none.
progressiveYES if the data is progressive, NO otherwise
Returns
JPEG data

Extends class DKDrawing.

- (NSArray*) layerBitmapsWithDPI: (NSUInteger dpi

Returns an array of bitmaps (NSBitmapImageReps) one per layer.

The lowest index is the bottom layer. Hidden layers and non-printing layers are excluded.

Parameters
dpithe desired resolution in dots per inch.
Returns
an array of bitmaps

Extends class DKDrawing.

- (NSData*) multipartTIFFDataWithResolution: (NSUInteger dpi

Returns TIFF data.

Each layer is written as a separate image. This is not the same as a layered TIFF however.

Parameters
dpithe desired resolution in dots per inch.
Returns
TIFF data

Extends class DKDrawing.

- (NSData*) PNGDataWithProperties: (NSDictionary *)  props

Returns PNG data for the drawing.

Parameters
propsvarious parameters and properties
Returns
PNG data or nil if there was a problem DrawKit properties that control the data generation. Users may find the convenience methods below easier to use for many typical situations.

Extends class DKDrawing.

- (NSData*) PNGDataWithResolution: (NSInteger dpi
gamma: (CGFloat gamma
interlaced: (BOOL interlaced 

Extends class DKDrawing.

- (NSData*) thumbnailData

Returns JPEG data for the drawing at 50% actual size, with 50% quality.

Useful for e.g. generating QuickLook thumbnails

Returns
JPEG data

Extends class DKDrawing.

- (NSData*) TIFFDataWithProperties: (NSDictionary *)  props

Returns TIFF data for the drawing.

Parameters
propsvarious parameters and properties
Returns
TIFF data or nil if there was a problem DrawKit properties that control the data generation. Users may find the convenience methods below easier to use for many typical situations.

Extends class DKDrawing.

- (NSData*) TIFFDataWithResolution: (NSInteger dpi
compressionType: (NSTIFFCompression)  compType 

Returns TIFF data for the drawing or nil if there was a problem.

This is a convenience wrapper around the dictionary-based methods above

Parameters
dpithe resolution in dots per inch
compTypea valid TIFF compression type (see NSBitMapImageRep.h)
Returns
TIFF data

Extends class DKDrawing.