• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to set dpi of an image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to set dpi of an image


  • Subject: Re: How to set dpi of an image
  • From: Mahaboob <email@hidden>
  • Date: Fri, 22 May 2009 10:18:31 +0530
  • Thread-topic: How to set dpi of an image

I gone through that links and I can't figure it out how to set the dpi.
By googling I found a function to set dpi in windows :

public RenderTargetBitmap(
    int pixelWidth,
    int pixelHeight,
    double dpiX,
    double dpiY,
    PixelFormat pixelFormat
)

Is there any equivalent method?
Is it my size calculation is right?


On 5/21/09 2:09 PM, "email@hidden" <email@hidden>
wrote:

>
> On 21 May 2009, at 08:29, Mahaboob wrote:
>
>> I need to save the image with respect to the given dpi.
>> I calculated the image size proportional to the dpi and saved it.
>> But when I'm viewing the dpi from preview it shows only 72 dpi.
>>
>> I used the code like:
>>
>> float compressionFactor = [compressionSlider floatValue];
>>
>> NSDictionary *jpegProperties = [NSDictionary dictionaryWithObject:
>> [NSNumber
>> numberWithFloat: compressionFactor] forKey: NSImageCompressionFactor];
>>
>>    NSSize size = [image size];
>>
>>    unsigned int     resfac =  (unsigned int)[bitmapResolution
>> intValue];
>>
>>
>>
>>    [image setScalesWhenResized:YES];
>>
>>
>>
>>    [image setSize:NSMakeSize(size.width * resfac/72, size.height *
>> resfac/72)];
>>
> setSize: doesn't change the underlying image reps
> see the docs
> http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Im
> ages/Images.html#/
> /apple_ref/doc/uid/TP40003290-CH208-SW2
>
> or this http://weblog.scifihifi.com/2005/06/25/how-to-resize-an-nsimage/
>
> Apple has some decent sample code with CoreImage additions here
> http://developer.apple.com/SampleCode/Reducer/listing16.html
>
>>
>>    NSBitmapImageRep *theBmapRep = [NSBitmapImageRep imageRepWithData:
>> [image
>> TIFFRepresentation]];
>>
>> NSData *exportedData;
>>
>> exportedData = [ theBmapRep representationUsingType:NSJPEGFileType
>> properties:jpegProperties];
>>
>> Is it I'm missing something?
>> How can I set the exact dpi?
>>
>> Thanks in advance
>> Mahaboob
>>
>>
>>
>>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> 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:
>>
>> This email sent to email@hidden
>
> Jonathan Mitchell
>
> Central Conscious Unit
> http://www.mugginsoft.com
>
>
>
>


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How to set dpi of an image
      • From: Graham Cox <email@hidden>
References: 
 >Re: How to set dpi of an image (From: "email@hidden" <email@hidden>)

  • Prev by Date: Re: Affine transform not being applied to subviews
  • Next by Date: Re: How to set dpi of an image
  • Previous by thread: Re: How to set dpi of an image
  • Next by thread: Re: How to set dpi of an image
  • Index(es):
    • Date
    • Thread