Re: CGImageRef printing issue

2009-11-13 Thread David Duncan
On Nov 13, 2009, at 1:27 AM, Mirko Viviani wrote:

> To be honest I didn't remember the resolution indipendent thing, but I was 
> supposing something similar
> since drawing my image in tiles on this context resulted with gaps !
> But I was not able to obtain the scale factor of the printing context so I 
> didn't understand.

Technically you are not drawing to the printer, but rather a specialized PDF 
context. Getting the current DPI of the printer isn't always possible, and it 
is easy for the user to invalidate that information (printing to PDF or moving 
a print job between printers) so it isn't recommended.

> CGContextConvertSizeToDeviceSpace() does not seem to correctly convert my 
> paperSize
> (from NSPrintInfo) to device space. (see below)
> I need this information because I want to scale an image (ie 500 Mpx) to a 
> reasonable size instead of
> crashing my app! :)
> 
> I haven't checked the context transform matrix yet, but which route should I 
> follow to obtain this information?


It is doing exactly what it should do given the reality as explained above. I 
would choose a reasonable scaling factor for your image and use that to resize 
it before drawing it to the print context.
--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CGImageRef printing issue

2009-11-13 Thread Mirko Viviani
On 12/nov/2009, at 23.46, David Duncan wrote:

> Just like with all CGContexts you can apply a transform matrix to change the 
> coordinate system. However in general this isn't necessary. If you want an 
> image to display in a 1" x 1" area on screen, draw it into a 72x72 box. The 
> pixel size of the image will determine DPI. If you wanted to draw a 1" image 
> at 300 DPI then you would just need a 300x300 image drawn into a 72x72 box. 
> If you wanted to draw a 1" image at 600 DPI then you would need a 600x600 
> image drawn into the same 72x72 box.

To be honest I didn't remember the resolution indipendent thing, but I was 
supposing something similar
since drawing my image in tiles on this context resulted with gaps !
But I was not able to obtain the scale factor of the printing context so I 
didn't understand.

CGContextConvertSizeToDeviceSpace() does not seem to correctly convert my 
paperSize
(from NSPrintInfo) to device space. (see below)
I need this information because I want to scale an image (ie 500 Mpx) to a 
reasonable size instead of
crashing my app! :)

I haven't checked the context transform matrix yet, but which route should I 
follow to obtain this information?


Preview printing view:

paperSize={595.00 842.00} devicePaperSize={212.70 -301.00}

PDF:

paperSize={595.00 842.00} devicePaperSize={595.00 842.00}

Canon printer:

paperSize={595.00 842.00} devicePaperSize={595.00 842.00}


Thank you!

-- 
Ciao,
Mirko

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CGImageRef printing issue

2009-11-12 Thread Shawn Erickson
On Thu, Nov 12, 2009 at 2:26 PM, Mirko Viviani  wrote:

> Do you mean that there is no way to print an image using a grid of 300 PPI 
> with Cocoa/Quartz?
> If not, why? Alternatives?




etc.

-Shawn
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CGImageRef printing issue

2009-11-12 Thread Kyle Sluder
On Thu, Nov 12, 2009 at 2:26 PM, Mirko Viviani  wrote:
> Do you mean that there is no way to print an image using a grid of 300 PPI 
> with Cocoa/Quartz?
> If not, why? Alternatives?

Resolution independence.  Your physical screen may have 96 pixels per
inch, but the system exposes it as 72 points per inch.  In the case of
printing, it actually gets this right and maps these virtual points to
physical, real-world 1/72 of an inch.  In the case of onscreen
graphics, the system currently does not do the points -> pixels
mapping such that 1 point = 1/72 inch.  You can turn that on with
Quartz Debug, though, and then everything behaves as if you were
printing.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CGImageRef printing issue

2009-11-12 Thread David Duncan
On Nov 12, 2009, at 2:26 PM, Mirko Viviani wrote:

> On 12/ago/2009, at 21.30, David Duncan wrote:
> 
>>> From my experience on Windows, DPIHeight and DPIWidth are properties of the
>>> display device the image is drawn on, and not properties of the image
>>> itself.
>> 
>> They are properties of both. In the case of printing, you are using a fixed 
>> grid at 72 PPI. Your source image of course has its own DPI that determines 
>> the actual size of the image in real world units. You combine the two to 
>> print or display an image at its natural size.
> 
> Do you mean that there is no way to print an image using a grid of 300 PPI 
> with Cocoa/Quartz?
> If not, why? Alternatives?


Just like with all CGContexts you can apply a transform matrix to change the 
coordinate system. However in general this isn't necessary. If you want an 
image to display in a 1" x 1" area on screen, draw it into a 72x72 box. The 
pixel size of the image will determine DPI. If you wanted to draw a 1" image at 
300 DPI then you would just need a 300x300 image drawn into a 72x72 box. If you 
wanted to draw a 1" image at 600 DPI then you would need a 600x600 image drawn 
into the same 72x72 box.
--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CGImageRef printing issue

2009-11-12 Thread Mirko Viviani
On 12/ago/2009, at 21.30, David Duncan wrote:

>> From my experience on Windows, DPIHeight and DPIWidth are properties of the
>> display device the image is drawn on, and not properties of the image
>> itself.
> 
> They are properties of both. In the case of printing, you are using a fixed 
> grid at 72 PPI. Your source image of course has its own DPI that determines 
> the actual size of the image in real world units. You combine the two to 
> print or display an image at its natural size.

Do you mean that there is no way to print an image using a grid of 300 PPI with 
Cocoa/Quartz?
If not, why? Alternatives?

-- 
Ciao,
Mirko

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CGImageRef printing issue

2009-08-12 Thread David Duncan

On Aug 11, 2009, at 11:39 PM, Renzil D'Souza wrote:


Once I get the CGImageSourceRef, I make a call to
CGImageSourceCopyProperties() passing it the imageSource . But this  
always
returns a NULL. If I output this CGImageRef to a file, and then read  
it back
as a CGImageSource, and then call CGImageSourceCopyProperties(), it  
works
fine and gives me the required properties. But I need it to work  
without

having to output an image file.


DPI is a function of specific images in an image file, not of the  
entire file itself (which is what your getting when you call  
CGImageSourceCopyProperties). You want to call  
CGImageSourceCopyPropertiesAtIndex instead for the particular image  
you want to get properties for.


From my experience on Windows, DPIHeight and DPIWidth are properties  
of the

display device the image is drawn on, and not properties of the image
itself.


They are properties of both. In the case of printing, you are using a  
fixed grid at 72 PPI. Your source image of course has its own DPI that  
determines the actual size of the image in real world units. You  
combine the two to print or display an image at its natural size.



And what is kCGImagePropertyOrientation?


Images don't necessarily have to be oriented with with pixels  
neighboring columns adjacent on a row of pixels and the orientation  
reflects this. The 8 defined orientations basically take into account  
that you can rotate and mirror an image relative to how its pixels are  
actually ordered.


This is a general property of images, although not supported (or used)  
in all formats.


Is it that the orientation of a saved image file can be one of a  
number of enumerations, but the orientation of a CGImageRef is  
always the default orientation?



Effectively, CGImage has no support for orientations so if an image is  
meant to be displayed in a different orientation, then it will be  
drawn incorrectly by Quartz without applying the required transform  
first.


Now that said, NSImage may be a much simpler method of doing this, so  
you may want to investigate that alternative instead.

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


CGImageRef printing issue

2009-08-12 Thread Renzil D'Souza
Hi,

I'm trying to print, given a CGImageRef (cgImage). In order to do this
correctly, I need to get a couple of 'CGImageProperty' from my image, like
kCGImagePropertyDPIHeight, kCGImagePropertyDPIWidth and
kCGImagePropertyOrientation. I try to do this from a CGImageSourceRef, which
I create in the following way:


CGImageSourceRef imageSource =
CGImageSourceCreateWithDataProvider(CGImageGetDataProvider(cgImage), NULL);


Once I get the CGImageSourceRef, I make a call to
CGImageSourceCopyProperties() passing it the imageSource . But this always
returns a NULL. If I output this CGImageRef to a file, and then read it back
as a CGImageSource, and then call CGImageSourceCopyProperties(), it works
fine and gives me the required properties. But I need it to work without
having to output an image file.

>From my experience on Windows, DPIHeight and DPIWidth are properties of the
display device the image is drawn on, and not properties of the image
itself. And what is kCGImagePropertyOrientation? The print routine on Mac
that I'm linking to needs it, but I have no idea what it is, and I don't
think it has a Windows equivalent. Is it that the orientation of a saved
image file can be one of a number of enumerations, but the orientation of a
CGImageRef is always the default orientation?

Thanks for your time.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com