projects
/
xscreensaver
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
From http://www.jwz.org/xscreensaver/xscreensaver-5.26.tar.gz
[xscreensaver]
/
driver
/
pdf2jpeg.m
diff --git
a/driver/pdf2jpeg.m
b/driver/pdf2jpeg.m
index 87e890341c7bcfedee2a8036916a9b9735591738..d681b4a5424b58241679daf961bf1db66e035658 100644
(file)
--- a/
driver/pdf2jpeg.m
+++ b/
driver/pdf2jpeg.m
@@
-1,6
+1,6
@@
/* pdf2jpeg -- converts a PDF file to a JPEG file, using Cocoa
*
/* pdf2jpeg -- converts a PDF file to a JPEG file, using Cocoa
*
- * Copyright (c) 200
1, 2002, 2003
by Jamie Zawinski <jwz@jwz.org>
+ * Copyright (c) 200
3, 2008
by Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@
-23,6
+23,7
@@
main (int argc, char** argv)
const char *progname = argv[0];
const char *infile = 0, *outfile = 0;
double compression = 0.85;
const char *progname = argv[0];
const char *infile = 0, *outfile = 0;
double compression = 0.85;
+ double scale = 1.0;
int verbose = 0;
int i;
int verbose = 0;
int i;
@@
-45,6
+46,18
@@
main (int argc, char** argv)
}
compression = q / 100.0;
}
}
compression = q / 100.0;
}
+ else if (!strcmp (argv[i], "-scale"))
+ {
+ float s;
+ if (1 != sscanf (argv[++i], " %f %c", &s, &c) ||
+ s <= 0 || s > 50)
+ {
+ fprintf (stderr, "%s: scale must be 0.0 - 50.0 (%f)\n",
+ progname, s);
+ goto USAGE;
+ }
+ scale = s;
+ }
else if (!strcmp (argv[i], "-verbose"))
verbose++;
else if (!strcmp (argv[i], "-v") ||
else if (!strcmp (argv[i], "-verbose"))
verbose++;
else if (!strcmp (argv[i], "-v") ||
@@
-64,7
+77,7
@@
main (int argc, char** argv)
{
USAGE:
fprintf (stderr,
{
USAGE:
fprintf (stderr,
- "usage: %s [-verbose] [-quality NN] "
+ "usage: %s [-verbose] [-
scale N] [-
quality NN] "
"infile.pdf outfile.jpg\n",
progname);
exit (1);
"infile.pdf outfile.jpg\n",
progname);
exit (1);
@@
-87,17
+100,23
@@
main (int argc, char** argv)
// Load the PDF file into an NSData object:
NSData *pdf_data = [NSData dataWithContentsOfFile:
// Load the PDF file into an NSData object:
NSData *pdf_data = [NSData dataWithContentsOfFile:
- [NSString stringWithCString:infile]];
+ [NSString stringWithCString:infile
+ encoding:NSUTF8StringEncoding]];
// Create an NSPDFImageRep from the data:
NSPDFImageRep *pdf_rep = [NSPDFImageRep imageRepWithData:pdf_data];
// Create an NSImage instance
// Create an NSPDFImageRep from the data:
NSPDFImageRep *pdf_rep = [NSPDFImageRep imageRepWithData:pdf_data];
// Create an NSImage instance
- NSImage *image = [[NSImage alloc] initWithSize:[pdf_rep size]];
+ NSRect rect;
+ rect.size = [pdf_rep size];
+ rect.size.width *= scale;
+ rect.size.height *= scale;
+ rect.origin.x = rect.origin.y = 0;
+ NSImage *image = [[NSImage alloc] initWithSize:rect.size];
// Draw the PDFImageRep in the NSImage
[image lockFocus];
// Draw the PDFImageRep in the NSImage
[image lockFocus];
- [pdf_rep draw
AtPoint:NSMakePoint(0.0,0.0)
];
+ [pdf_rep draw
InRect:rect
];
[image unlockFocus];
// Load the NSImage's contents into an NSBitmapImageRep:
[image unlockFocus];
// Load the NSImage's contents into an NSBitmapImageRep:
@@
-123,7
+142,8
@@
main (int argc, char** argv)
properties:props];
[jpeg_data writeToFile:
properties:props];
[jpeg_data writeToFile:
- [NSString stringWithCString:outfile]
+ [NSString stringWithCString:outfile
+ encoding:NSUTF8StringEncoding]
atomically:YES];
[image release];
atomically:YES];
[image release];