50 CGContextRef context = job->
context;
52#ifdef __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
53#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 20000
55 size_t context_datalen;
65 context_data = CGBitmapContextGetData(context);
66 context_datalen = CGBitmapContextGetBytesPerRow(context) * CGBitmapContextGetHeight(context);
76 CGPDFContextClose(context);
81 *((CGImageRef *) job->
window) = CGBitmapContextCreateImage(context);
84#if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
85 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1040) || \
86 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
87 __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 40000)
91 CGDataConsumerRef data_consumer =
92 CGDataConsumerCreate(job,
94 CGImageDestinationRef image_destination =
95 CGImageDestinationCreateWithDataConsumer(data_consumer,
99 CGImageRef
image = CGBitmapContextCreateImage(context);
100 CGImageDestinationAddImage(image_destination,
image,
NULL);
101 CGImageDestinationFinalize(image_destination);
104 if (image_destination)
105 CFRelease(image_destination);
106 CGImageRelease(
image);
107 CGDataConsumerRelease(data_consumer);
113 CGContextRelease(context);
115#ifdef __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
116#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 20000
117 if (context_data && context_datalen)
118 munmap(context_data, context_datalen);
125 CGRect bounds = CGRectMake(0.0, 0.0, job->
width, job->
height);
134 CFStringRef auxiliaryKeys[] = {
135 kCGPDFContextCreator,
138 CFStringRef auxiliaryValues[] = {
139 CFStringCreateWithFormat(kCFAllocatorDefault,
NULL,
145 CFStringCreateWithBytesNoCopy(kCFAllocatorDefault,
148 kCFStringEncodingUTF8,
153 CFDictionaryRef auxiliaryInfo =
154 CFDictionaryCreate(kCFAllocatorDefault,
155 (
const void **) &auxiliaryKeys,
156 (
const void **) &auxiliaryValues,
157 sizeof(auxiliaryValues) /
158 sizeof(auxiliaryValues[0]),
159 &kCFTypeDictionaryKeyCallBacks,
160 &kCFTypeDictionaryValueCallBacks);
163 CGDataConsumerRef data_consumer =
164 CGDataConsumerCreate(job,
167 CGPDFContextCreate(data_consumer, &bounds,
171 CGDataConsumerRelease(data_consumer);
172 CFRelease(auxiliaryInfo);
173 for (
size_t i = 0; i <
sizeof(auxiliaryValues) /
sizeof(auxiliaryValues[0]);
175 CFRelease(auxiliaryValues[i]);
181 size_t bytes_per_row =
187#ifdef __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
188#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 20000
192 size_t buffer_size = job->
height * bytes_per_row;
193 mach_msg_type_number_t vm_info_size = HOST_VM_INFO_COUNT;
194 vm_statistics_data_t vm_info;
197 (mach_host_self(), HOST_VM_INFO,
198 (host_info_t) & vm_info,
199 &vm_info_size) != KERN_SUCCESS
201 vm_info.free_count * vm_page_size) {
202 FILE *temp_file = tmpfile();
204 int temp_file_descriptor = fileno(temp_file);
205 if (temp_file_descriptor >= 0
206 && ftruncate(temp_file_descriptor,
208 buffer = mmap(
NULL, buffer_size, PROT_READ | PROT_WRITE,
209 MAP_FILE | MAP_PRIVATE, temp_file_descriptor, 0);
210 if (buffer == MAP_FAILED)
216 if (buffer ==
NULL) {
217 buffer = mmap(
NULL, buffer_size, PROT_READ | PROT_WRITE,
218 MAP_ANON | MAP_PRIVATE, -1, 0);
219 if (buffer == MAP_FAILED) {
227 CGColorSpaceRef color_space =
228 CGColorSpaceCreateDeviceRGB();
229 job->
context = CGBitmapContextCreate(buffer,
235 kCGImageAlphaPremultipliedFirst
240 CGColorSpaceRelease(color_space);
248 CGContextRef context = job->
context;
249 CGContextBeginPage(context, &bounds);
250 CGContextSaveGState(context);
256 CGContextRotateCTM(context, job->
rotation *
M_PI / 180.0);
269 char *target,
char *
id)
276 if (url && url_map) {
278 CGContextRef context = job->
context;
280 CFURLCreateWithBytes(kCFAllocatorDefault, (
const UInt8 *) url,
281 strlen(url), kCFStringEncodingUTF8,
NULL);
282 CGPDFContextSetURLForRect(context, uri,
284 CGRectApplyAffineTransform(CGRectMake
305 CGContextRef context = job->
context;
319 const CGFloat *segments;
320 size_t segment_count;
324 segment_count =
sizeof(
dashed) /
sizeof(CGFloat);
328 segment_count =
sizeof(
dotted) /
sizeof(CGFloat);
335 CGContextSetLineDash(context, 0.0, segments, segment_count);
338 CGContextSetLineWidth(context, job->
obj->
penwidth);
341 CGContextDrawPath(context, filled ? kCGPathFillStroke : kCGPathStroke);
496#if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
497 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1040) || \
498 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
499 __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 20000)
502#if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
503 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1040) || \
504 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
505 __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 40000)
518#ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
519#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1040
double yoffset_centerline
void(* free_layout)(void *layout)