525
525
Set PDF render geometry.
527
(void) FormatMagickString(geometry,MaxTextExtent,"%gx%g%+g%+g",
528
bounds.x2-bounds.x1,bounds.y2-bounds.y1,bounds.x1,bounds.y1);
527
(void) FormatMagickString(geometry,MaxTextExtent,
528
"%gx%g%+.15g%+.15g",bounds.x2-bounds.x1,bounds.y2-bounds.y1,
529
bounds.x1,bounds.y1);
529
530
(void) SetImageProperty(image,"pdf:HiResBoundingBox",geometry);
530
page.width=(unsigned long) (bounds.x2-bounds.x1+0.5);
531
page.height=(unsigned long) (bounds.y2-bounds.y1+0.5);
531
page.width=(size_t) floor(bounds.x2-bounds.x1+0.5);
532
page.height=(size_t) floor(bounds.y2-bounds.y1+0.5);
532
533
hires_bounds=bounds;
535
536
(void) CloseBlob(image);
536
537
if ((fabs(angle) == 90.0) || (fabs(angle) == 270.0))
578
579
return((Image *) NULL);
581
(void) FormatMagickString(density,MaxTextExtent,"%gx%g",image->x_resolution,
582
image->y_resolution);
582
if (image_info->density != (char *) NULL)
584
flags=ParseGeometry(image_info->density,&geometry_info);
585
image->x_resolution=geometry_info.rho;
586
image->y_resolution=geometry_info.sigma;
587
if ((flags & SigmaValue) == 0)
588
image->y_resolution=image->x_resolution;
590
(void) FormatMagickString(density,MaxTextExtent,"%gx%g",
591
image->x_resolution,image->y_resolution);
583
592
if (image_info->page != (char *) NULL)
585
594
(void) ParseAbsoluteGeometry(image_info->page,&page);
586
page.width=(unsigned long) (page.width*image->x_resolution/delta.x+0.5);
587
page.height=(unsigned long) (page.height*image->y_resolution/delta.y+0.5);
588
(void) FormatMagickString(options,MaxTextExtent,"-g%lux%lu ",page.width,
595
page.width=(size_t) floor(page.width*image->x_resolution/delta.x+
597
page.height=(size_t) floor(page.height*image->y_resolution/delta.y+
599
(void) FormatMagickString(options,MaxTextExtent,"-g%.20gx%.20g ",
600
(double) page.width,(double) page.height);
591
602
if (cmyk != MagickFalse)
592
603
(void) ConcatenateMagickString(options,"-dUseCIEColor ",MaxTextExtent);
602
613
pages[MaxTextExtent];
604
(void) FormatMagickString(pages,MaxTextExtent,"-dFirstPage=%lu "
605
"-dLastPage=%lu",read_info->scene+1,read_info->scene+
606
read_info->number_scenes);
615
(void) FormatMagickString(pages,MaxTextExtent,"-dFirstPage=%.20g "
616
"-dLastPage=%.20g",(double) read_info->scene+1,(double)
617
(read_info->scene+read_info->number_scenes));
607
618
(void) ConcatenateMagickString(options,pages,MaxTextExtent);
608
619
read_info->number_scenes=0;
609
620
if (read_info->scenes != (char *) NULL)
1040
1051
if (image_info->compression == JPEG2000Compression)
1041
version=(unsigned long) MagickMax(version,5);
1052
version=(size_t) MagickMax(version,5);
1042
1053
for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))
1043
1054
if (next->matte != MagickFalse)
1044
version=(unsigned long) MagickMax(version,4);
1055
version=(size_t) MagickMax(version,4);
1045
1056
if (LocaleCompare(image_info->magick,"PDFA") == 0)
1046
version=(unsigned long) MagickMax(version,6);
1047
(void) FormatMagickString(buffer,MaxTextExtent,"%%PDF-1.%lu \n",version);
1057
version=(size_t) MagickMax(version,6);
1058
(void) FormatMagickString(buffer,MaxTextExtent,"%%PDF-1.%.20g \n",
1048
1060
(void) WriteBlobString(image,buffer);
1049
1061
if (LocaleCompare(image_info->magick,"PDFA") == 0)
1050
1062
(void) WriteBlobString(image,"%����\n");
1054
1066
xref[object++]=TellBlob(image);
1055
1067
root_id=object;
1056
(void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
1068
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
1057
1070
(void) WriteBlobString(image,buffer);
1058
1071
(void) WriteBlobString(image,"<<\n");
1059
1072
if (LocaleCompare(image_info->magick,"PDFA") != 0)
1060
(void) FormatMagickString(buffer,MaxTextExtent,"/Pages %lu 0 R\n",
1073
(void) FormatMagickString(buffer,MaxTextExtent,"/Pages %.20g 0 R\n",
1064
(void) FormatMagickString(buffer,MaxTextExtent,"/Metadata %lu 0 R\n",
1077
(void) FormatMagickString(buffer,MaxTextExtent,"/Metadata %.20g 0 R\n",
1066
1079
(void) WriteBlobString(image,buffer);
1067
(void) FormatMagickString(buffer,MaxTextExtent,"/Pages %lu 0 R\n",
1080
(void) FormatMagickString(buffer,MaxTextExtent,"/Pages %.20g 0 R\n",
1070
1083
(void) WriteBlobString(image,buffer);
1071
1084
(void) WriteBlobString(image,"/Type /Catalog\n");
1079
1092
timestamp[MaxTextExtent],
1080
1093
xmp_profile[MaxTextExtent];
1086
1099
Write XMP object.
1088
1101
xref[object++]=TellBlob(image);
1089
(void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
1102
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",
1090
1104
(void) WriteBlobString(image,buffer);
1091
1105
(void) WriteBlobString(image,"<<\n");
1092
1106
(void) WriteBlobString(image,"/Subtype /XML\n");
1102
1116
i=FormatMagickString(xmp_profile,MaxTextExtent,XMPProfile,
1103
1117
XMPProfileMagick,modify_date,create_date,timestamp,
1104
1118
GetMagickVersion(&version),GetMagickVersion(&version));
1105
(void) FormatMagickString(buffer,MaxTextExtent,"/Length %lu\n",1UL*i);
1119
(void) FormatMagickString(buffer,MaxTextExtent,"/Length %.20g\n",
1106
1121
(void) WriteBlobString(image,buffer);
1107
1122
(void) WriteBlobString(image,"/Type /Metadata\n");
1108
1123
(void) WriteBlobString(image,">>\nstream\n");
1116
1131
xref[object++]=TellBlob(image);
1117
1132
pages_id=object;
1118
(void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
1133
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
1119
1135
(void) WriteBlobString(image,buffer);
1120
1136
(void) WriteBlobString(image,"<<\n");
1121
1137
(void) WriteBlobString(image,"/Type /Pages\n");
1122
(void) FormatMagickString(buffer,MaxTextExtent,"/Kids [ %lu 0 R ",object+1);
1138
(void) FormatMagickString(buffer,MaxTextExtent,"/Kids [ %.20g 0 R ",
1123
1140
(void) WriteBlobString(image,buffer);
1124
count=(long) (pages_id+ObjectsPerImage+1);
1141
count=(ssize_t) (pages_id+ObjectsPerImage+1);
1125
1142
if (image_info->adjoin != MagickFalse)
1143
1161
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
1145
1163
(void) WriteBlobString(image,"]\n");
1146
(void) FormatMagickString(buffer,MaxTextExtent,"/Count %lu\n",
1147
(count-pages_id)/ObjectsPerImage);
1164
(void) FormatMagickString(buffer,MaxTextExtent,"/Count %.20g\n",
1165
(double) ((count-pages_id)/ObjectsPerImage));
1148
1166
(void) WriteBlobString(image,buffer);
1149
1167
(void) WriteBlobString(image,">>\n");
1150
1168
(void) WriteBlobString(image,"endobj\n");
1240
1258
if (image->units == PixelsPerCentimeterResolution)
1260
resolution.x=(size_t) (100.0*2.54*resolution.x+0.5)/100.0;
1261
resolution.y=(size_t) (100.0*2.54*resolution.y+0.5)/100.0;
1245
1263
SetGeometry(image,&geometry);
1246
(void) FormatMagickString(page_geometry,MaxTextExtent,"%lux%lu",
1247
image->columns,image->rows);
1264
(void) FormatMagickString(page_geometry,MaxTextExtent,"%.20gx%.20g",
1265
(double) image->columns,(double) image->rows);
1248
1266
if (image_info->page != (char *) NULL)
1249
1267
(void) CopyMagickString(page_geometry,image_info->page,MaxTextExtent);
1251
1269
if ((image->page.width != 0) && (image->page.height != 0))
1252
(void) FormatMagickString(page_geometry,MaxTextExtent,"%lux%lu%+ld%+ld",
1253
image->page.width,image->page.height,image->page.x,image->page.y);
1270
(void) FormatMagickString(page_geometry,MaxTextExtent,
1271
"%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
1272
(double) image->page.height,(double) image->page.x,(double)
1255
1275
if ((image->gravity != UndefinedGravity) &&
1256
1276
(LocaleCompare(image_info->magick,"PDF") == 0))
1259
1279
(void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
1260
1280
&geometry.width,&geometry.height);
1261
1281
scale.x=(double) (geometry.width*delta.x)/resolution.x;
1262
geometry.width=(unsigned long) (scale.x+0.5);
1282
geometry.width=(size_t) floor(scale.x+0.5);
1263
1283
scale.y=(double) (geometry.height*delta.y)/resolution.y;
1264
geometry.height=(unsigned long) (scale.y+0.5);
1284
geometry.height=(size_t) floor(scale.y+0.5);
1265
1285
(void) ParseAbsoluteGeometry(page_geometry,&media_info);
1266
1286
(void) ParseGravityGeometry(image,page_geometry,&page_info,
1267
1287
&image->exception);
1268
1288
if (image->gravity != UndefinedGravity)
1270
1290
geometry.x=(-page_info.x);
1271
geometry.y=(long) (media_info.height+page_info.y-image->rows);
1291
geometry.y=(ssize_t) (media_info.height+page_info.y-image->rows);
1273
1293
pointsize=12.0;
1274
1294
if (image_info->pointsize != 0.0)
1277
1297
value=GetImageProperty(image,"Label");
1278
1298
if (value != (const char *) NULL)
1279
text_size=(unsigned long) (MultilineCensus(value)*pointsize+12);
1299
text_size=(size_t) (MultilineCensus(value)*pointsize+12);
1281
1301
Write Page object.
1283
1303
xref[object++]=TellBlob(image);
1284
(void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
1304
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
1285
1306
(void) WriteBlobString(image,buffer);
1286
1307
(void) WriteBlobString(image,"<<\n");
1287
1308
(void) WriteBlobString(image,"/Type /Page\n");
1288
(void) FormatMagickString(buffer,MaxTextExtent,"/Parent %lu 0 R\n",
1309
(void) FormatMagickString(buffer,MaxTextExtent,"/Parent %.20g 0 R\n",
1290
1311
(void) WriteBlobString(image,buffer);
1291
1312
(void) WriteBlobString(image,"/Resources <<\n");
1292
1313
labels=(char **) NULL;
1296
1317
if (labels != (char **) NULL)
1298
1319
(void) FormatMagickString(buffer,MaxTextExtent,
1299
"/Font << /F%lu %lu 0 R >>\n",image->scene,object+4);
1320
"/Font << /F%.20g %.20g 0 R >>\n",(double) image->scene,(double)
1300
1322
(void) WriteBlobString(image,buffer);
1302
1324
(void) FormatMagickString(buffer,MaxTextExtent,
1303
"/XObject << /Im%lu %lu 0 R >>\n",image->scene,object+5);
1304
(void) WriteBlobString(image,buffer);
1305
(void) FormatMagickString(buffer,MaxTextExtent,"/ProcSet %lu 0 R >>\n",
1307
(void) WriteBlobString(image,buffer);
1308
(void) FormatMagickString(buffer,MaxTextExtent,"/MediaBox [0 0 %g %g]\n",
1309
72.0*media_info.width/resolution.x,72.0*media_info.height/resolution.y);
1310
(void) WriteBlobString(image,buffer);
1311
(void) FormatMagickString(buffer,MaxTextExtent,"/CropBox [0 0 %g %g]\n",
1312
72.0*media_info.width/resolution.x,72.0*media_info.height/resolution.y);
1313
(void) WriteBlobString(image,buffer);
1314
(void) FormatMagickString(buffer,MaxTextExtent,"/Contents %lu 0 R\n",
1316
(void) WriteBlobString(image,buffer);
1317
(void) FormatMagickString(buffer,MaxTextExtent,"/Thumb %lu 0 R\n",
1325
"/XObject << /Im%.20g %.20g 0 R >>\n",(double) image->scene,(double)
1327
(void) WriteBlobString(image,buffer);
1328
(void) FormatMagickString(buffer,MaxTextExtent,"/ProcSet %.20g 0 R >>\n",
1330
(void) WriteBlobString(image,buffer);
1331
(void) FormatMagickString(buffer,MaxTextExtent,
1332
"/MediaBox [0 0 %g %g]\n",72.0*media_info.width/resolution.x,
1333
72.0*media_info.height/resolution.y);
1334
(void) WriteBlobString(image,buffer);
1335
(void) FormatMagickString(buffer,MaxTextExtent,
1336
"/CropBox [0 0 %g %g]\n",72.0*media_info.width/resolution.x,
1337
72.0*media_info.height/resolution.y);
1338
(void) WriteBlobString(image,buffer);
1339
(void) FormatMagickString(buffer,MaxTextExtent,"/Contents %.20g 0 R\n",
1341
(void) WriteBlobString(image,buffer);
1342
(void) FormatMagickString(buffer,MaxTextExtent,"/Thumb %.20g 0 R\n",
1319
1344
(void) WriteBlobString(image,buffer);
1320
1345
(void) WriteBlobString(image,">>\n");
1321
1346
(void) WriteBlobString(image,"endobj\n");
1323
1348
Write Contents object.
1325
1350
xref[object++]=TellBlob(image);
1326
(void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
1351
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
1327
1353
(void) WriteBlobString(image,buffer);
1328
1354
(void) WriteBlobString(image,"<<\n");
1329
(void) FormatMagickString(buffer,MaxTextExtent,"/Length %lu 0 R\n",
1355
(void) FormatMagickString(buffer,MaxTextExtent,"/Length %.20g 0 R\n",
1331
1357
(void) WriteBlobString(image,buffer);
1332
1358
(void) WriteBlobString(image,">>\n");
1333
1359
(void) WriteBlobString(image,"stream\n");
1337
1363
for (i=0; labels[i] != (char *) NULL; i++)
1339
1365
(void) WriteBlobString(image,"BT\n");
1340
(void) FormatMagickString(buffer,MaxTextExtent,"/F%lu %g Tf\n",
1341
image->scene,pointsize);
1366
(void) FormatMagickString(buffer,MaxTextExtent,"/F%.20g %g Tf\n",
1367
(double) image->scene,pointsize);
1342
1368
(void) WriteBlobString(image,buffer);
1343
(void) FormatMagickString(buffer,MaxTextExtent,"%ld %ld Td\n",
1344
geometry.x,(long) (geometry.y+geometry.height+i*pointsize+12));
1369
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g %.20g Td\n",
1370
(double) geometry.x,(double) (geometry.y+geometry.height+i*pointsize+
1345
1372
(void) WriteBlobString(image,buffer);
1346
1373
(void) FormatMagickString(buffer,MaxTextExtent,"(%s) Tj\n",labels[i]);
1347
1374
(void) WriteBlobString(image,buffer);
1348
1375
(void) WriteBlobString(image,"ET\n");
1349
1376
labels[i]=DestroyString(labels[i]);
1351
(void) FormatMagickString(buffer,MaxTextExtent,"%g 0 0 %g %ld %ld cm\n",
1352
scale.x,scale.y,geometry.x,geometry.y);
1378
(void) FormatMagickString(buffer,MaxTextExtent,"%g 0 0 %g %.20g %.20g cm\n",
1379
scale.x,scale.y,(double) geometry.x,(double) geometry.y);
1353
1380
(void) WriteBlobString(image,buffer);
1354
(void) FormatMagickString(buffer,MaxTextExtent,"/Im%lu Do\n",image->scene);
1381
(void) FormatMagickString(buffer,MaxTextExtent,"/Im%.20g Do\n",
1382
(double) image->scene);
1355
1383
(void) WriteBlobString(image,buffer);
1356
1384
(void) WriteBlobString(image,"Q\n");
1357
1385
offset=TellBlob(image)-offset;
1361
1389
Write Length object.
1363
1391
xref[object++]=TellBlob(image);
1364
(void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
1392
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
1365
1394
(void) WriteBlobString(image,buffer);
1366
(void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",
1367
(unsigned long) offset);
1395
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g\n",(double) offset);
1368
1396
(void) WriteBlobString(image,buffer);
1369
1397
(void) WriteBlobString(image,"endobj\n");
1371
1399
Write Procset object.
1373
1401
xref[object++]=TellBlob(image);
1374
(void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
1402
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",
1375
1404
(void) WriteBlobString(image,buffer);
1376
1405
if ((image->storage_class == DirectClass) || (image->colors > 256))
1377
1406
(void) CopyMagickString(buffer,"[ /PDF /Text /ImageC",MaxTextExtent);
1387
1416
Write Font object.
1389
1418
xref[object++]=TellBlob(image);
1390
(void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
1419
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",
1391
1421
(void) WriteBlobString(image,buffer);
1392
1422
(void) WriteBlobString(image,"<<\n");
1393
1423
if (labels != (char **) NULL)
1395
1425
(void) WriteBlobString(image,"/Type /Font\n");
1396
1426
(void) WriteBlobString(image,"/Subtype /Type1\n");
1397
(void) FormatMagickString(buffer,MaxTextExtent,"/Name /F%lu\n",
1427
(void) FormatMagickString(buffer,MaxTextExtent,"/Name /F%.20g\n",
1428
(double) image->scene);
1399
1429
(void) WriteBlobString(image,buffer);
1400
1430
(void) WriteBlobString(image,"/BaseFont /Helvetica\n");
1401
1431
(void) WriteBlobString(image,"/Encoding /MacRomanEncoding\n");
1407
1437
Write XObject object.
1409
1439
xref[object++]=TellBlob(image);
1410
(void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
1440
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
1411
1442
(void) WriteBlobString(image,buffer);
1412
1443
(void) WriteBlobString(image,"<<\n");
1413
1444
(void) WriteBlobString(image,"/Type /XObject\n");
1414
1445
(void) WriteBlobString(image,"/Subtype /Image\n");
1415
(void) FormatMagickString(buffer,MaxTextExtent,"/Name /Im%lu\n",
1446
(void) FormatMagickString(buffer,MaxTextExtent,"/Name /Im%.20g\n",
1447
(double) image->scene);
1417
1448
(void) WriteBlobString(image,buffer);
1418
1449
switch (compression)
1459
1490
MaxTextExtent);
1460
1491
(void) WriteBlobString(image,buffer);
1461
1492
(void) FormatMagickString(buffer,MaxTextExtent,"/DecodeParms [ << "
1462
"/K %s /BlackIs1 false /Columns %ld /Rows %ld >> ]\n",CCITTParam,
1463
image->columns,image->rows);
1493
"/K %s /BlackIs1 false /Columns %.20g /Rows %.20g >> ]\n",CCITTParam,
1494
(double) image->columns,(double) image->rows);
1473
1504
(void) WriteBlobString(image,buffer);
1474
(void) FormatMagickString(buffer,MaxTextExtent,"/Width %lu\n",
1505
(void) FormatMagickString(buffer,MaxTextExtent,"/Width %.20g\n",(double)
1475
1506
image->columns);
1476
1507
(void) WriteBlobString(image,buffer);
1477
(void) FormatMagickString(buffer,MaxTextExtent,"/Height %lu\n",image->rows);
1508
(void) FormatMagickString(buffer,MaxTextExtent,"/Height %.20g\n",(double)
1478
1510
(void) WriteBlobString(image,buffer);
1479
(void) FormatMagickString(buffer,MaxTextExtent,"/ColorSpace %lu 0 R\n",
1511
(void) FormatMagickString(buffer,MaxTextExtent,"/ColorSpace %.20g 0 R\n",
1481
1513
(void) WriteBlobString(image,buffer);
1482
1514
(void) FormatMagickString(buffer,MaxTextExtent,"/BitsPerComponent %d\n",
1483
1515
(compression == FaxCompression) || (compression == Group4Compression) ?
1485
1517
(void) WriteBlobString(image,buffer);
1486
1518
if (image->matte != MagickFalse)
1488
(void) FormatMagickString(buffer,MaxTextExtent,"/SMask %lu 0 R\n",
1520
(void) FormatMagickString(buffer,MaxTextExtent,"/SMask %.20g 0 R\n",
1490
1522
(void) WriteBlobString(image,buffer);
1492
(void) FormatMagickString(buffer,MaxTextExtent,"/Length %lu 0 R\n",
1524
(void) FormatMagickString(buffer,MaxTextExtent,"/Length %.20g 0 R\n",
1494
1526
(void) WriteBlobString(image,buffer);
1495
1527
(void) WriteBlobString(image,">>\n");
1496
1528
(void) WriteBlobString(image,"stream\n");
1546
1578
Dump Runlength encoded pixels.
1549
for (y=0; y < (long) image->rows; y++)
1581
for (y=0; y < (ssize_t) image->rows; y++)
1551
1583
p=GetVirtualPixels(image,0,y,image->columns,1,
1552
1584
&image->exception);
1553
1585
if (p == (const PixelPacket *) NULL)
1555
for (x=0; x < (long) image->columns; x++)
1587
for (x=0; x < (ssize_t) image->columns; x++)
1557
1589
*q++=ScaleQuantumToChar(PixelIntensityToQuantum(p));
1560
1592
if (image->previous == (Image *) NULL)
1562
status=SetImageProgress(image,SaveImageTag,y,image->rows);
1594
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
1563
1596
if (status == MagickFalse)
1587
1620
Dump uncompressed PseudoColor packets.
1589
1622
Ascii85Initialize(image);
1590
for (y=0; y < (long) image->rows; y++)
1623
for (y=0; y < (ssize_t) image->rows; y++)
1592
1625
p=GetVirtualPixels(image,0,y,image->columns,1,
1593
1626
&image->exception);
1594
1627
if (p == (const PixelPacket *) NULL)
1596
for (x=0; x < (long) image->columns; x++)
1629
for (x=0; x < (ssize_t) image->columns; x++)
1598
1631
Ascii85Encode(image,
1599
1632
ScaleQuantumToChar(PixelIntensityToQuantum(p)));
1649
1683
Dump runoffset encoded pixels.
1652
for (y=0; y < (long) image->rows; y++)
1686
for (y=0; y < (ssize_t) image->rows; y++)
1654
1688
p=GetVirtualPixels(image,0,y,image->columns,1,
1655
1689
&image->exception);
1656
1690
if (p == (const PixelPacket *) NULL)
1658
1692
indexes=GetVirtualIndexQueue(image);
1659
for (x=0; x < (long) image->columns; x++)
1693
for (x=0; x < (ssize_t) image->columns; x++)
1661
*q++=ScaleQuantumToChar(p->red);
1662
*q++=ScaleQuantumToChar(p->green);
1663
*q++=ScaleQuantumToChar(p->blue);
1695
*q++=ScaleQuantumToChar(GetRedPixelComponent(p));
1696
*q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
1697
*q++=ScaleQuantumToChar(GetBluePixelComponent(p));
1664
1698
if (image->colorspace == CMYKColorspace)
1665
1699
*q++=ScaleQuantumToChar(indexes[x]);
1668
1702
if (image->previous == (Image *) NULL)
1670
status=SetImageProgress(image,SaveImageTag,y,image->rows);
1704
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
1671
1706
if (status == MagickFalse)
1695
1730
Dump uncompressed DirectColor packets.
1697
1732
Ascii85Initialize(image);
1698
for (y=0; y < (long) image->rows; y++)
1733
for (y=0; y < (ssize_t) image->rows; y++)
1700
1735
p=GetVirtualPixels(image,0,y,image->columns,1,
1701
1736
&image->exception);
1702
1737
if (p == (const PixelPacket *) NULL)
1704
1739
indexes=GetVirtualIndexQueue(image);
1705
for (x=0; x < (long) image->columns; x++)
1740
for (x=0; x < (ssize_t) image->columns; x++)
1707
Ascii85Encode(image,ScaleQuantumToChar(p->red));
1708
Ascii85Encode(image,ScaleQuantumToChar(p->green));
1709
Ascii85Encode(image,ScaleQuantumToChar(p->blue));
1742
Ascii85Encode(image,ScaleQuantumToChar(GetRedPixelComponent(p)));
1743
Ascii85Encode(image,ScaleQuantumToChar(GetGreenPixelComponent(p)));
1744
Ascii85Encode(image,ScaleQuantumToChar(GetBluePixelComponent(p)));
1710
1745
if (image->colorspace == CMYKColorspace)
1711
1746
Ascii85Encode(image,ScaleQuantumToChar(indexes[x]));
1714
1749
if (image->previous == (Image *) NULL)
1716
status=SetImageProgress(image,SaveImageTag,y,image->rows);
1751
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
1717
1753
if (status == MagickFalse)
1745
1781
Dump Runlength encoded pixels.
1748
for (y=0; y < (long) image->rows; y++)
1784
for (y=0; y < (ssize_t) image->rows; y++)
1750
1786
p=GetVirtualPixels(image,0,y,image->columns,1,
1751
1787
&image->exception);
1752
1788
if (p == (const PixelPacket *) NULL)
1754
1790
indexes=GetVirtualIndexQueue(image);
1755
for (x=0; x < (long) image->columns; x++)
1791
for (x=0; x < (ssize_t) image->columns; x++)
1756
1792
*q++=(unsigned char) indexes[x];
1757
1793
if (image->previous == (Image *) NULL)
1759
status=SetImageProgress(image,SaveImageTag,y,image->rows);
1795
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
1760
1797
if (status == MagickFalse)
1784
1821
Dump uncompressed PseudoColor packets.
1786
1823
Ascii85Initialize(image);
1787
for (y=0; y < (long) image->rows; y++)
1824
for (y=0; y < (ssize_t) image->rows; y++)
1789
1826
p=GetVirtualPixels(image,0,y,image->columns,1,
1790
1827
&image->exception);
1791
1828
if (p == (const PixelPacket *) NULL)
1793
1830
indexes=GetVirtualIndexQueue(image);
1794
for (x=0; x < (long) image->columns; x++)
1831
for (x=0; x < (ssize_t) image->columns; x++)
1795
1832
Ascii85Encode(image,(unsigned char) indexes[x]);
1796
1833
if (image->previous == (Image *) NULL)
1798
status=SetImageProgress(image,SaveImageTag,y,image->rows);
1835
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
1799
1837
if (status == MagickFalse)
1812
1850
Write Length object.
1814
1852
xref[object++]=TellBlob(image);
1815
(void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
1853
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
1816
1855
(void) WriteBlobString(image,buffer);
1817
(void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",
1818
(unsigned long) offset);
1856
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g\n",
1819
1858
(void) WriteBlobString(image,buffer);
1820
1859
(void) WriteBlobString(image,"endobj\n");
1822
1861
Write Colorspace object.
1824
1863
xref[object++]=TellBlob(image);
1825
(void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
1864
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
1826
1866
(void) WriteBlobString(image,buffer);
1827
1867
if (image->colorspace == CMYKColorspace)
1828
1868
(void) CopyMagickString(buffer,"/DeviceCMYK\n",MaxTextExtent);
1839
1879
(void) CopyMagickString(buffer,"/DeviceRGB\n",MaxTextExtent);
1841
1881
(void) FormatMagickString(buffer,MaxTextExtent,
1842
"[ /Indexed /DeviceRGB %lu %lu 0 R ]\n",
1843
image->colors-1,object+3);
1882
"[ /Indexed /DeviceRGB %.20g %.20g 0 R ]\n",(double) image->colors-
1883
1,(double) object+3);
1844
1884
(void) WriteBlobString(image,buffer);
1845
1885
(void) WriteBlobString(image,"endobj\n");
1854
1894
if (tile_image == (Image *) NULL)
1855
1895
ThrowWriterException(ResourceLimitError,image->exception.reason);
1856
1896
xref[object++]=TellBlob(image);
1857
(void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
1897
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
1858
1899
(void) WriteBlobString(image,buffer);
1859
1900
(void) WriteBlobString(image,"<<\n");
1860
1901
switch (compression)
1901
1942
MaxTextExtent);
1902
1943
(void) WriteBlobString(image,buffer);
1903
1944
(void) FormatMagickString(buffer,MaxTextExtent,"/DecodeParms [ << "
1904
"/K %s /BlackIs1 false /Columns %lu /Rows %lu >> ]\n",CCITTParam,
1905
tile_image->columns,tile_image->rows);
1945
"/K %s /BlackIs1 false /Columns %.20g /Rows %.20g >> ]\n",CCITTParam,
1946
(double) tile_image->columns,(double) tile_image->rows);
1915
1956
(void) WriteBlobString(image,buffer);
1916
(void) FormatMagickString(buffer,MaxTextExtent,"/Width %lu\n",
1957
(void) FormatMagickString(buffer,MaxTextExtent,"/Width %.20g\n",(double)
1917
1958
tile_image->columns);
1918
1959
(void) WriteBlobString(image,buffer);
1919
(void) FormatMagickString(buffer,MaxTextExtent,"/Height %lu\n",
1960
(void) FormatMagickString(buffer,MaxTextExtent,"/Height %.20g\n",(double)
1920
1961
tile_image->rows);
1921
1962
(void) WriteBlobString(image,buffer);
1922
(void) FormatMagickString(buffer,MaxTextExtent,"/ColorSpace %lu 0 R\n",
1963
(void) FormatMagickString(buffer,MaxTextExtent,"/ColorSpace %.20g 0 R\n",
1924
1965
(void) WriteBlobString(image,buffer);
1925
1966
(void) FormatMagickString(buffer,MaxTextExtent,"/BitsPerComponent %d\n",
1926
1967
(compression == FaxCompression) || (compression == Group4Compression) ?
1928
1969
(void) WriteBlobString(image,buffer);
1929
(void) FormatMagickString(buffer,MaxTextExtent,"/Length %lu 0 R\n",
1970
(void) FormatMagickString(buffer,MaxTextExtent,"/Length %.20g 0 R\n",
1931
1972
(void) WriteBlobString(image,buffer);
1932
1973
(void) WriteBlobString(image,">>\n");
1933
1974
(void) WriteBlobString(image,"stream\n");
1986
2027
Dump Runlength encoded pixels.
1989
for (y=0; y < (long) tile_image->rows; y++)
2030
for (y=0; y < (ssize_t) tile_image->rows; y++)
1991
2032
p=GetVirtualPixels(tile_image,0,y,tile_image->columns,1,
1992
2033
&tile_image->exception);
1993
2034
if (p == (const PixelPacket *) NULL)
1995
for (x=0; x < (long) tile_image->columns; x++)
2036
for (x=0; x < (ssize_t) tile_image->columns; x++)
1997
2038
*q++=ScaleQuantumToChar(PixelIntensityToQuantum(p));
2021
2062
Dump uncompressed PseudoColor packets.
2023
2064
Ascii85Initialize(image);
2024
for (y=0; y < (long) tile_image->rows; y++)
2065
for (y=0; y < (ssize_t) tile_image->rows; y++)
2026
2067
p=GetVirtualPixels(tile_image,0,y,tile_image->columns,1,
2027
2068
&tile_image->exception);
2028
2069
if (p == (const PixelPacket *) NULL)
2030
for (x=0; x < (long) tile_image->columns; x++)
2071
for (x=0; x < (ssize_t) tile_image->columns; x++)
2032
2073
Ascii85Encode(image,
2033
2074
ScaleQuantumToChar(PixelIntensityToQuantum(p)));
2081
2122
Dump runoffset encoded pixels.
2084
for (y=0; y < (long) tile_image->rows; y++)
2125
for (y=0; y < (ssize_t) tile_image->rows; y++)
2086
2127
p=GetVirtualPixels(tile_image,0,y,tile_image->columns,1,
2087
2128
&tile_image->exception);
2088
2129
if (p == (const PixelPacket *) NULL)
2090
2131
indexes=GetVirtualIndexQueue(tile_image);
2091
for (x=0; x < (long) tile_image->columns; x++)
2132
for (x=0; x < (ssize_t) tile_image->columns; x++)
2093
*q++=ScaleQuantumToChar(p->red);
2094
*q++=ScaleQuantumToChar(p->green);
2095
*q++=ScaleQuantumToChar(p->blue);
2134
*q++=ScaleQuantumToChar(GetRedPixelComponent(p));
2135
*q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
2136
*q++=ScaleQuantumToChar(GetBluePixelComponent(p));
2096
2137
if (image->colorspace == CMYKColorspace)
2097
2138
*q++=ScaleQuantumToChar(indexes[x]);
2121
2162
Dump uncompressed DirectColor packets.
2123
2164
Ascii85Initialize(image);
2124
for (y=0; y < (long) tile_image->rows; y++)
2165
for (y=0; y < (ssize_t) tile_image->rows; y++)
2126
2167
p=GetVirtualPixels(tile_image,0,y,tile_image->columns,1,
2127
2168
&tile_image->exception);
2128
2169
if (p == (const PixelPacket *) NULL)
2130
2171
indexes=GetVirtualIndexQueue(tile_image);
2131
for (x=0; x < (long) tile_image->columns; x++)
2172
for (x=0; x < (ssize_t) tile_image->columns; x++)
2133
Ascii85Encode(image,ScaleQuantumToChar(p->red));
2134
Ascii85Encode(image,ScaleQuantumToChar(p->green));
2135
Ascii85Encode(image,ScaleQuantumToChar(p->blue));
2174
Ascii85Encode(image,ScaleQuantumToChar(GetRedPixelComponent(p)));
2175
Ascii85Encode(image,ScaleQuantumToChar(GetGreenPixelComponent(p)));
2176
Ascii85Encode(image,ScaleQuantumToChar(GetBluePixelComponent(p)));
2136
2177
if (image->colorspace == CMYKColorspace)
2137
2178
Ascii85Encode(image,ScaleQuantumToChar(indexes[x]));
2168
2209
Dump Runlength encoded pixels.
2171
for (y=0; y < (long) tile_image->rows; y++)
2212
for (y=0; y < (ssize_t) tile_image->rows; y++)
2173
2214
p=GetVirtualPixels(tile_image,0,y,tile_image->columns,1,
2174
2215
&tile_image->exception);
2175
2216
if (p == (const PixelPacket *) NULL)
2177
2218
indexes=GetVirtualIndexQueue(tile_image);
2178
for (x=0; x < (long) tile_image->columns; x++)
2219
for (x=0; x < (ssize_t) tile_image->columns; x++)
2179
2220
*q++=(unsigned char) indexes[x];
2181
2222
#if defined(MAGICKCORE_ZLIB_DELEGATE)
2201
2242
Dump uncompressed PseudoColor packets.
2203
2244
Ascii85Initialize(image);
2204
for (y=0; y < (long) tile_image->rows; y++)
2245
for (y=0; y < (ssize_t) tile_image->rows; y++)
2206
2247
p=GetVirtualPixels(tile_image,0,y,tile_image->columns,1,
2207
2248
&tile_image->exception);
2208
2249
if (p == (const PixelPacket *) NULL)
2210
2251
indexes=GetVirtualIndexQueue(tile_image);
2211
for (x=0; x < (long) tile_image->columns; x++)
2252
for (x=0; x < (ssize_t) tile_image->columns; x++)
2212
2253
Ascii85Encode(image,(unsigned char) indexes[x]);
2214
2255
Ascii85Flush(image);
2224
2265
Write Length object.
2226
2267
xref[object++]=TellBlob(image);
2227
(void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
2268
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
2228
2270
(void) WriteBlobString(image,buffer);
2229
(void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",
2230
(unsigned long) offset);
2271
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g\n",(double) offset);
2231
2272
(void) WriteBlobString(image,buffer);
2232
2273
(void) WriteBlobString(image,"endobj\n");
2233
2274
xref[object++]=TellBlob(image);
2234
(void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
2275
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
2235
2277
(void) WriteBlobString(image,buffer);
2236
2278
if ((image->storage_class != DirectClass) && (image->colors <= 256) &&
2237
2279
(compression != FaxCompression) && (compression != Group4Compression))
2242
2284
(void) WriteBlobString(image,"<<\n");
2243
2285
if (compression == NoCompression)
2244
2286
(void) WriteBlobString(image,"/Filter [ /ASCII85Decode ]\n");
2245
(void) FormatMagickString(buffer,MaxTextExtent,"/Length %lu 0 R\n",
2287
(void) FormatMagickString(buffer,MaxTextExtent,"/Length %.20g 0 R\n",
2247
2289
(void) WriteBlobString(image,buffer);
2248
2290
(void) WriteBlobString(image,">>\n");
2249
2291
(void) WriteBlobString(image,"stream\n");
2250
2292
offset=TellBlob(image);
2251
2293
if (compression == NoCompression)
2252
2294
Ascii85Initialize(image);
2253
for (i=0; i < (long) image->colors; i++)
2295
for (i=0; i < (ssize_t) image->colors; i++)
2255
2297
if (compression == NoCompression)
2276
2318
Write Length object.
2278
2320
xref[object++]=TellBlob(image);
2279
(void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
2321
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
2280
2323
(void) WriteBlobString(image,buffer);
2281
(void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",
2282
(unsigned long) offset);
2324
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g\n",(double)
2283
2326
(void) WriteBlobString(image,buffer);
2284
2327
(void) WriteBlobString(image,"endobj\n");
2286
2329
Write softmask object.
2288
2331
xref[object++]=TellBlob(image);
2289
(void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
2332
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
2290
2334
(void) WriteBlobString(image,buffer);
2291
2335
(void) WriteBlobString(image,"<<\n");
2292
2336
if (image->matte == MagickFalse)
2327
2371
(void) WriteBlobString(image,buffer);
2328
(void) FormatMagickString(buffer,MaxTextExtent,"/Width %lu\n",
2372
(void) FormatMagickString(buffer,MaxTextExtent,"/Width %.20g\n",
2373
(double) image->columns);
2330
2374
(void) WriteBlobString(image,buffer);
2331
(void) FormatMagickString(buffer,MaxTextExtent,"/Height %lu\n",
2375
(void) FormatMagickString(buffer,MaxTextExtent,"/Height %.20g\n",
2376
(double) image->rows);
2333
2377
(void) WriteBlobString(image,buffer);
2334
2378
(void) WriteBlobString(image,"/ColorSpace /DeviceGray\n");
2335
2379
(void) FormatMagickString(buffer,MaxTextExtent,"/BitsPerComponent %d\n",
2336
2380
(compression == FaxCompression) || (compression == Group4Compression)
2338
2382
(void) WriteBlobString(image,buffer);
2339
(void) FormatMagickString(buffer,MaxTextExtent,"/Length %lu 0 R\n",
2383
(void) FormatMagickString(buffer,MaxTextExtent,"/Length %.20g 0 R\n",
2341
2385
(void) WriteBlobString(image,buffer);
2342
2386
(void) WriteBlobString(image,">>\n");
2343
2387
(void) WriteBlobString(image,"stream\n");
2364
2408
Dump Runlength encoded pixels.
2367
for (y=0; y < (long) image->rows; y++)
2411
for (y=0; y < (ssize_t) image->rows; y++)
2369
2413
p=GetVirtualPixels(image,0,y,image->columns,1,
2370
2414
&image->exception);
2371
2415
if (p == (const PixelPacket *) NULL)
2373
for (x=0; x < (long) image->columns; x++)
2417
for (x=0; x < (ssize_t) image->columns; x++)
2375
*q++=ScaleQuantumToChar((Quantum) (QuantumRange-p->opacity));
2419
*q++=ScaleQuantumToChar((Quantum) (GetAlphaPixelComponent(p)));
2399
2443
Dump uncompressed PseudoColor packets.
2401
2445
Ascii85Initialize(image);
2402
for (y=0; y < (long) image->rows; y++)
2446
for (y=0; y < (ssize_t) image->rows; y++)
2404
2448
p=GetVirtualPixels(image,0,y,image->columns,1,
2405
2449
&image->exception);
2406
2450
if (p == (const PixelPacket *) NULL)
2408
for (x=0; x < (long) image->columns; x++)
2452
for (x=0; x < (ssize_t) image->columns; x++)
2410
2454
Ascii85Encode(image,ScaleQuantumToChar((Quantum) (QuantumRange-
2455
GetOpacityPixelComponent(p))));
2424
2468
Write Length object.
2426
2470
xref[object++]=TellBlob(image);
2427
(void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
2471
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
2428
2473
(void) WriteBlobString(image,buffer);
2429
(void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",(unsigned long)
2474
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g\n",(double) offset);
2431
2475
(void) WriteBlobString(image,buffer);
2432
2476
(void) WriteBlobString(image,"endobj\n");
2433
2477
if (GetNextImageInList(image) == (Image *) NULL)
2444
2488
xref[object++]=TellBlob(image);
2445
2489
info_id=object;
2446
(void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
2490
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g 0 obj\n",(double)
2447
2492
(void) WriteBlobString(image,buffer);
2448
2493
(void) WriteBlobString(image,"<<\n");
2449
2494
(void) FormatMagickString(buffer,MaxTextExtent,"/Title (%s)\n",
2463
2508
(void) FormatMagickString(buffer,MaxTextExtent,"/ModDate (%s)\n",date);
2464
2509
(void) WriteBlobString(image,buffer);
2465
2510
(void) FormatMagickString(buffer,MaxTextExtent,"/Producer (%s)\n",
2466
EscapeParenthesis(GetMagickVersion((unsigned long *) NULL)));
2511
EscapeParenthesis(GetMagickVersion((size_t *) NULL)));
2467
2512
(void) WriteBlobString(image,buffer);
2468
2513
(void) WriteBlobString(image,">>\n");
2469
2514
(void) WriteBlobString(image,"endobj\n");
2473
2518
offset=TellBlob(image)-xref[0]+10;
2474
2519
(void) WriteBlobString(image,"xref\n");
2475
(void) FormatMagickString(buffer,MaxTextExtent,"0 %lu\n",object+1);
2520
(void) FormatMagickString(buffer,MaxTextExtent,"0 %.20g\n",(double)
2476
2522
(void) WriteBlobString(image,buffer);
2477
2523
(void) WriteBlobString(image,"0000000000 65535 f \n");
2478
for (i=0; i < (long) object; i++)
2524
for (i=0; i < (ssize_t) object; i++)
2480
2526
(void) FormatMagickString(buffer,MaxTextExtent,"%010lu 00000 n \n",
2481
2527
(unsigned long) xref[i]);
2484
2530
(void) WriteBlobString(image,"trailer\n");
2485
2531
(void) WriteBlobString(image,"<<\n");
2486
(void) FormatMagickString(buffer,MaxTextExtent,"/Size %lu\n",object+1);
2487
(void) WriteBlobString(image,buffer);
2488
(void) FormatMagickString(buffer,MaxTextExtent,"/Info %lu 0 R\n",info_id);
2489
(void) WriteBlobString(image,buffer);
2490
(void) FormatMagickString(buffer,MaxTextExtent,"/Root %lu 0 R\n",root_id);
2532
(void) FormatMagickString(buffer,MaxTextExtent,"/Size %.20g\n",(double)
2534
(void) WriteBlobString(image,buffer);
2535
(void) FormatMagickString(buffer,MaxTextExtent,"/Info %.20g 0 R\n",(double)
2537
(void) WriteBlobString(image,buffer);
2538
(void) FormatMagickString(buffer,MaxTextExtent,"/Root %.20g 0 R\n",(double)
2491
2540
(void) WriteBlobString(image,buffer);
2492
2541
(void) WriteBlobString(image,">>\n");
2493
2542
(void) WriteBlobString(image,"startxref\n");
2494
(void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",
2495
(unsigned long) offset);
2543
(void) FormatMagickString(buffer,MaxTextExtent,"%.20g\n",(double) offset);
2496
2544
(void) WriteBlobString(image,buffer);
2497
2545
(void) WriteBlobString(image,"%%EOF\n");
2498
2546
xref=(MagickOffsetType *) RelinquishMagickMemory(xref);