51 CGContextRef context = job->
context;
53#ifdef __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
54#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 20000
56 size_t context_datalen;
66 context_data = CGBitmapContextGetData(context);
67 context_datalen = CGBitmapContextGetBytesPerRow(context) * CGBitmapContextGetHeight(context);
77 CGPDFContextClose(context);
82 *((CGImageRef *) job->
window) = CGBitmapContextCreateImage(context);
85#if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
86 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1040) || \
87 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
88 __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 40000)
92 CGDataConsumerRef data_consumer =
93 CGDataConsumerCreate(job,
95 CGImageDestinationRef image_destination =
96 CGImageDestinationCreateWithDataConsumer(data_consumer,
100 CGImageRef
image = CGBitmapContextCreateImage(context);
101 CGImageDestinationAddImage(image_destination,
image,
NULL);
102 CGImageDestinationFinalize(image_destination);
105 if (image_destination)
106 CFRelease(image_destination);
107 CGImageRelease(
image);
108 CGDataConsumerRelease(data_consumer);
114 CGContextRelease(context);
116#ifdef __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
117#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 20000
118 if (context_data && context_datalen)
119 munmap(context_data, context_datalen);
126 CGRect bounds = CGRectMake(0.0, 0.0, job->
width, job->
height);
135 CFStringRef auxiliaryKeys[] = {
136 kCGPDFContextCreator,
139 CFStringRef auxiliaryValues[] = {
140 CFStringCreateWithFormat(kCFAllocatorDefault,
NULL,
146 CFStringCreateWithBytesNoCopy(kCFAllocatorDefault,
149 kCFStringEncodingUTF8,
154 CFDictionaryRef auxiliaryInfo =
155 CFDictionaryCreate(kCFAllocatorDefault,
156 (
const void **) &auxiliaryKeys,
157 (
const void **) &auxiliaryValues,
158 sizeof(auxiliaryValues) /
159 sizeof(auxiliaryValues[0]),
160 &kCFTypeDictionaryKeyCallBacks,
161 &kCFTypeDictionaryValueCallBacks);
164 CGDataConsumerRef data_consumer =
165 CGDataConsumerCreate(job,
168 CGPDFContextCreate(data_consumer, &bounds,
172 CGDataConsumerRelease(data_consumer);
173 CFRelease(auxiliaryInfo);
174 for (
size_t i = 0; i <
sizeof(auxiliaryValues) /
sizeof(auxiliaryValues[0]);
176 CFRelease(auxiliaryValues[i]);
182 size_t bytes_per_row =
188#ifdef __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
189#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 20000
193 size_t buffer_size = job->
height * bytes_per_row;
194 mach_msg_type_number_t vm_info_size = HOST_VM_INFO_COUNT;
195 vm_statistics_data_t vm_info;
198 (mach_host_self(), HOST_VM_INFO,
199 (host_info_t) & vm_info,
200 &vm_info_size) != KERN_SUCCESS
202 vm_info.free_count * vm_page_size) {
203 FILE *temp_file = tmpfile();
205 int temp_file_descriptor = fileno(temp_file);
206 if (temp_file_descriptor >= 0
207 && ftruncate(temp_file_descriptor,
209 buffer = mmap(
NULL, buffer_size, PROT_READ | PROT_WRITE,
210 MAP_FILE | MAP_PRIVATE, temp_file_descriptor, 0);
211 if (buffer == MAP_FAILED)
217 if (buffer ==
NULL) {
218 buffer = mmap(
NULL, buffer_size, PROT_READ | PROT_WRITE,
219 MAP_ANON | MAP_PRIVATE, -1, 0);
220 if (buffer == MAP_FAILED) {
228 CGColorSpaceRef color_space =
229 CGColorSpaceCreateDeviceRGB();
230 job->
context = CGBitmapContextCreate(buffer,
236 kCGImageAlphaPremultipliedFirst
241 CGColorSpaceRelease(color_space);
249 CGContextRef context = job->
context;
250 CGContextBeginPage(context, &bounds);
251 CGContextSaveGState(context);
257 CGContextRotateCTM(context, job->
rotation *
M_PI / 180.0);
270 char *target,
char *
id)
277 if (url && url_map) {
279 CGContextRef context = job->
context;
281 CFURLCreateWithBytes(kCFAllocatorDefault, (
const UInt8 *) url,
282 strlen(url), kCFStringEncodingUTF8,
NULL);
283 CGPDFContextSetURLForRect(context, uri,
285 CGRectApplyAffineTransform(CGRectMake
306 CGContextRef context = job->
context;
320 const CGFloat *segments;
321 size_t segment_count;
325 segment_count =
sizeof(
dashed) /
sizeof(CGFloat);
329 segment_count =
sizeof(
dotted) /
sizeof(CGFloat);
336 CGContextSetLineDash(context, 0.0, segments, segment_count);
339 CGContextSetLineWidth(context, job->
obj->
penwidth);
342 CGContextDrawPath(context, filled ? kCGPathFillStroke : kCGPathStroke);
497#if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
498 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1040) || \
499 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
500 __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 20000)
503#if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
504 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1040) || \
505 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
506 __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 40000)
519#ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
520#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1040
double yoffset_centerline
void(* free_layout)(void *layout)