Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Converting an NSImage to black and white (1bit)

Converting an NSImage to black and white (1bit)
Thread Tools
Senior User
Join Date: Jun 1999
Location: San Jose, CA
Status: Offline
Reply With Quote
Jul 7, 2002, 01:36 PM
 
I have a pdf file loaded into an NSImage. I then took this pdf and converted it to tiff using:

</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">data = [myImageToSave TIFFRepresentationUsingCompression:NSTIFFCompressi onNone factor:nil];</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Now I am sitting with a NSData object filled with tiff info.

I have looked through the NSImage, and NSBitmapImageRep for anything about converting images, but cant seem to find the info I need.

Anyone with some insight that would be great!

Thanks,
Ben
     
Junior Member
Join Date: Mar 2001
Status: Offline
Reply With Quote
Jul 8, 2002, 04:11 PM
 
Do you mean black and white, or grayscale? If grayscale is ok, I wrote a function that will do that for you. Let me know if you're interested. Any function that converts to black and white is going to have to use some sort of sophisticated algorithm to get good results and is therefore going to be hard to write; that said, you could do it using Carbon and GWorlds too.

-Peter
     
Senior User
Join Date: Jun 1999
Location: San Jose, CA
Status: Offline
Reply With Quote
Jul 8, 2002, 04:55 PM
 
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">Originally posted by Wixar:
<strong>Do you mean black and white, or grayscale? If grayscale is ok, I wrote a function that will do that for you. Let me know if you're interested. Any function that converts to black and white is going to have to use some sort of sophisticated algorithm to get good results and is therefore going to be hard to write; that said, you could do it using Carbon and GWorlds too.

-Peter</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Greyscale might work. I need a 1-bit image for this reason, I was told by some people on the Cocoa-Dev list that it is required in order for the function TIFFRepresentationUsingCompression.

They said it is not very well documented, but if you want to use the NSTIFFCompressionCCITTFAX3 compressor, it expects a 1-bit image with no alpha mask.

Pain in the ass if you ask me, but I need it.

Thanks,
Ben
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 10:00 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2