I would like to losslessly convert a PDF to a raster image in Objective-C. To do this, there must be no drawing of the PDF into a context. Also, I need to be able to scale the PDF. Any ideas?
By converting a PDF into a raster representation, you are implicitly drawing it into a bitmapped graphics context. There's no way around that. Why do you think you need to avoid doing that? What's your ultimate goal here?
Related
Are there any plugins for ImageFlow.NET that enables me to auto crop images to focus on objects, not faces, in them? Or any other non-plugin way to do it with ImageFlow.NET?
Not yet, but it is something we're planning to add. In the meantime, you could try using https://github.com/softawaregmbh/smartcrop.net to get the crop coordinates then feeding them to Imageflow. It looks like a slow library, and the built-in encoding and resizing is very poor, but if you only use it to get coordinates you should be fine.
Can anyone tell why the image in this pdf does not display as 100% Cyan?
clrtestc - NOPREBLEND32.PDF
Warning: I probably know just enough about pdf and colour to be dangerous!
I'm pretty sure each colour plane of the image is in a separate image. Here's a blended version if that helps.
I know the ColorSpace is DeviceCMYK
I'm pretty sure there is only 100% Cyan in the image, at least there was when it went into the PDF converter.
What went in:
CMYK: 100,0,0,0
RGB: 0,255,255
What I measure coming out:
CMYK: 100,27,0,6
RGB: 0,173,238
I'm foxed! Is there some filter affecting the rendering of the PDF?
There's also Magenta, Yellow and Black versions if they help.
Any help much appreciated.
The PDF file is extraordinarily complicated, it has numerous Forms, some of them nested, most of which are empty. However there only appears to be one image, which is defined in an Indexed CMYK space. So as far as I can see, this is indeed a 100% cyan image.
The extended graphics state does use the Multiply Blend mode, and there is no group and no page group specified, so the colour space used for the blending will depend on the colour model of the output device. If that's a monitor, then it's entirely possible that the resulting output will be RGB.
That's because your CMYK image needs to be converted to RGB in order to be blended using that colour space.
Incidentally, the image is in an Indexed colour space. In your image all the image samples have the same value, that value is then consulted in a lookup table, and that table returns the CMYK components. So no, there is not one image per colour plane, or at least, not in this file.
To be honest, you're going to have to explain better how you are evaluating the content of the PDF file. As far as I can see the image is 100% cyan, and when rendered to a CMYK device, it will remain 100% cyan. If you render to an RGB device, it will be converted to RGB. A poor quality PDF consumer might decide to convert to RGB in the absence of a defined colour space for the blending operation.
Since the blending mode doesn't actually do anything (there's no defined alpha, SMask or any other transparency in the file) you could remove that and see if it sorts out your problem.
Edit
Your screen will be an RGB device, so no matter what the CMYK values in the PDF file are, there won't be any CMYK in the screenshot. The PDF rendering engine will have to convert the CMYK to RGB.
So the PDF rendering engine performs an opaque CMYK->RGB conversion. Then you take a picture of that RGB screen. You load that into an image editing application, and ask it what the RGB values are and presumably what it thinks are the CMYK equivalents.
If the CMYK->RGB calculation that the PDF viewer performs is not the inverse of the calculation that the RGB->CMYK image application performs, then you won't be getting the right values!
There's no way to predict what the RGB intermediate values 'should' be, because there is no 'right' answer here. Fundamentally this isn't a reliable technique for evaluating the colour.
It's hard to make any kind of recommendation without knowing what you are trying to achieve (and possibly why), and what tools you are prepared to use. I believe Acrobat Pro would allow you to look at the colour values directly for example. Or you could use something like Ghostscript to create a CMYK TIFF file, then open that in an image application which supports CMYK (like Photoshop) and look at the values there.
But rendering to the screen, taking a screenshot and trying to figure out what the CMYK values might or might not have been is not really going to work.
Im rendering a pdf using pdf js library. There I can specify zoom (scale) property. Which is fine. I can define pretty high zoom , let's say 8x and still get decent quality of the rendered pdf. However if I were to try to same pdf but converted to graphic image format like jpeg. And then try to render it with high zoom the quality is very bad. Why is that so?
You are describing the difference between vector graphics and raster graphics. A vector graphic format contains contains commands telling how to draw an image. A raster format is an array that tells what the color is at each position in the image.
PDF is largely a raster format (Yes, you can embed a raster image in a PDF). A PDF that has in instruction to draw a line or draw a character can be zoomed to any degree and the drawing will be correct.
In a raster format, if you zoom, eventually you see the individual pixels in the array and they cannot be zoomed any more without distortion. Text in a JPEG or PNG file becomes jagged as you zoom.
On the other hand, try to create a photographic quality image just with drawing commands and you would get huge files.
I'm trying to create an objective C classe for my iPad application which can convert a powerpoint file to a jpeg file.
Accordingly i've to read into the pptx format to see how the file is structured and create an image, from scratch, in which i can say this element goes there, this one here, this text there.
But actually i've no idea how to do this, if the best way is to use a already existing framework in iOS or an additional library?
Thanks to everyone ;)
Bye
The fastest way to visualize elements is, to me, OpenGL ES. You can use mobile GPU to visualize then there is CIImage for managing image.
Take a look at Quartz 2D, the drawing engine used as the main workhorse for 2D graphics on iOS. It gives you all the primitives for drawing shapes, fills, text and other objects you need to render the presentation.
I have a one spritesheet image with all sprites, I downloaded this image from Interent. My question: Is there a tool that help me to get the coordinates of each sprite? would I have to search coordinates manually ?
I've been reading several tutorials like:http://www.raywenderlich.com/1271/how-to-use-animations-and-sprite-sheets-in-cocos2d and http://indiedevstories.com/2011/04/10/using-sprite-sheets-in-cocos2d-and-tiled-part-1/, but all them use multiple images to create one spritesheet and generate automatically the .plist, but this is not my case.
In my case I have only one .png and no .plist
Help me please!!!
Apologies for the self-promotion but I have created a tool for working with single spritesheet images and outputting the coordinates. It even has automatic sprite selection :)
http://www.darkfunction.com/editor
You can crop the images using some editor (photoshop for example) and then use the exiting tool to generate the texture and the plist. I think it will be the fastest and the easiest way because in case you would want to generate only plist you will do the same operation - selecting the rectangle.
Use preview to crop out all the images separately. Then use zwoptex or texture packer to combine them all and generate the spritesheet with .png and .plist
Other than that it is difficult to figure out what is the rect of each image. If you are a good programmer you can write a tool to analyze the png and extract out the information which can be used to identify the rectangles, but my advice is to do it manually.
Divide your image using an image editor. Then add it to a spritesheet generator (like Sprite Master). Then you are free to make your output as you want by just changing the parameters.
Sprite Master will have a feature like parsing prepared spritesheet to individual images in following versions.