On Oct 18, 2010, at 04:37, Amy Heavey wrote:

> The source images are not generated by us, they are from a variety of surces, 
> and are generally 200pixels + on each side, however sometimes they are 72 
> dpi, and sometimes they are 300dpi. Even if an aimage is 450pixels square, 
> when it is set as 300 dpi it's reduced too small when my app reduces it it to 
> fit a 75pixel square area.
> 
> I know this is to do with the bitmapRepresentation, but I can't work out how 
> to change it. If I was doing this in photoshop I'd be keeping the actual 
> pixel count, but changing the resolution from 300 to 72 for these images.
> 
> Can anyone point me in the right direction?  Here's the code I'm using at the 
> moment:
> 
> while ((imgPath = [imageLoop nextObject])) {
>               NSImage *img = [[NSImage alloc]initWithContentsOfFile:imgPath];
>               [targetImage lockFocus];
> 
>               [img drawInRect:NSMakeRect(x,y,75,75) 
> fromRect:NSMakeRect(20,20,0,0) operation:NSCompositeCopy fraction:1];

What does "too small" mean? Are you saying that your original image is being 
drawn somewhere inside your 75-pixel square, failing to fill it completely?

Also, I don't understand the intended significance of your 
'fromRect:NSMakeRect(20,20,0,0)' parameter. This should either be the part of 
the original image you want to transfer to the destination, or NSZeroRect to 
copy the whole thing.

If you're copying the whole image, I can't see that the "resolution" (in the 
sense of "dpi") has any significance to 'drawInRect:...'. It really only comes 
into play when relating the absolute (in points) size of two different images 
or contexts. You can always adjust the (effective) resolution of a NSImage by 
calling 'setSize:' with the absolute size you want. This does not change the 
pixel size of the underlying representation.


_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to