• 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: drawing 1 bit images, and image resolution
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: drawing 1 bit images, and image resolution


  • Subject: Re: drawing 1 bit images, and image resolution
  • From: email@hidden
  • Date: Wed, 08 Feb 2012 17:53:43 +0000
  • Importance: Normal
  • Sensitivity: Normal

I know this is somewhat lame, but could you use sips from a shell call to convert your saved image to a tiff and delete the original?

Sent from my Verizon Wireless BlackBerry

-----Original Message-----
From: Chris Paveglio <email@hidden>
Sender: cocoa-dev-bounces+zav=email@hiddente: Wed, 08 Feb 2012 07:26:24
To: Cocoa Dev List<email@hidden>
Reply-to: Chris Paveglio <email@hidden>
Subject: drawing 1 bit images, and image resolution

I need to save an NSImage as a TIFF file, as a 1-bit (black and white) image, and at a specific resolution (dpi). I have my NSImage being created in RGB mode, and I can save it (as RGB).
I've been trying to read the other posts on 1-bit images, but I don't understand things like "you'll have to fill it yourself".
(http://www.cocoabuilder.com/archive/cocoa/204408-1-bit-nsbitmapimagerep.html?q="1+bit+image"#204521)

Does anyone have some code they could share to take an NSImage and then make it 1-bit?

Also, I have tried to use [nsImage setSize:NSMakeSize(fx, fy)] on an NSImage and it appears to work, but when I save the image then it defaults back to 72dpi (the default). So is there something that I need to do to aside from setSize?

Here's what I am using for my saving method:

-(IBAction)saveImage:(id)sender
{
 IKSaveOptions *saveOptions = [[IKSaveOptions alloc]
       initWithImageProperties: NULL
       imageUTType: @"public.tiff"]; 
 
 NSSavePanel *savePanel = [NSSavePanel savePanel];
 
 [savePanel setAllowedFileTypes:[NSArray arrayWithObject:@"tif"]];
 [savePanel setTitle:@"Save QR Image As TIF"];
 [savePanel setMessage:@"TIF will be the file type of the image."];
 
 [savePanel beginWithCompletionHandler:^(NSInteger result)
 {
  if (result == NSFileHandlingPanelOKButton) 
  { 
   NSString *newUTType = [saveOptions imageUTType];
   NSURL *url = [savePanel URL];
      
   CGImageRef image = [qrImage CGImageForProposedRect:NULL context:NULL hints:NULL];
   
   if (image)
   {
    CGImageDestinationRef dest = CGImageDestinationCreateWithURL((CFURLRef)url,
                    (CFStringRef)newUTType, 1, NULL);
    if (dest)
    {
     CGImageDestinationAddImage(dest, image,
              (CFDictionaryRef)[saveOptions imageProperties]);
     CGImageDestinationFinalize(dest);
     CFRelease(dest);
    } //(dest)
   } //(image)
 //CALL ASOC FILE PLACER HERE  
  } //(result == NSFileHandlingPanelOKButton)
 } ]; //savePanel
}

Thanks,
Chris

_______________________________________________

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

_______________________________________________

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: drawing 1 bit images, and image resolution
      • From: Chris Paveglio <email@hidden>
References: 
 >drawing 1 bit images, and image resolution (From: Chris Paveglio <email@hidden>)

  • Prev by Date: drawing 1 bit images, and image resolution
  • Next by Date: Can I somehow encourage the deallocation of a dismissed view controller?
  • Previous by thread: drawing 1 bit images, and image resolution
  • Next by thread: Re: drawing 1 bit images, and image resolution
  • Index(es):
    • Date
    • Thread