• 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: help with NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help with NSImage


  • Subject: Re: help with NSImage
  • From: "Daniel O'Sullivan" <email@hidden>
  • Date: Sun, 13 Feb 2005 14:36:37 +0000

From: Heinrich Giesen <email@hidden>
To: email@hidden
CC: email@hidden
Subject: Re: help with NSImage
Date: Sun, 13 Feb 2005 10:54:20 +0100
MIME-Version: 1.0 (Apple Message framework v619.2)
Received: from mailout04.sul.t-online.com ([194.25.134.18]) by mc1-f31.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); Sun, 13 Feb 2005 01:55:34 -0800
Received: from fwd00.aul.t-online.de by mailout04.sul.t-online.com with smtp id 1D0GSX-000097-00; Sun, 13 Feb 2005 10:54:33 +0100
Received: from [10.0.1.2] (TQXLQrZZgeaohm1zHnL53g36HzZFzaWYBWT55BkuQHQae2lhisJocB@[84.169.65.44]) by fwd00.sul.t-online.comwith esmtp id 1D0GSN-0wnzSi0; Sun, 13 Feb 2005 10:54:23 +0100
X-Message-Info: JGTYoYF78jE9ed7tLsMlVJV3TSNG4rOX/EKLAgfmLvg=
References: <email@hidden>
X-Mailer: Apple Mail (2.619.2)
X-ID: TQXLQrZZgeaohm1zHnL53g36HzZFzaWYBWT55BkuQHQae2lhisJocB
X-TOI-MSGID: 45b05b03-26a7-45f8-95b0-805528feee40
Return-Path: email@hidden
X-OriginalArrivalTime: 13 Feb 2005 09:55:34.0729 (UTC) FILETIME=[2974AB90:01C511B2]



On 12.02.2005, at 16:57, Daniel O'Sullivan wrote:

hi,

I'm a new to cocoa so this will probably sound rather basic, but i'm looking
to display .ppm images using NSImage. Do i use NSQuickDrawView? if anyone
could help me, it would be really appreciated especailly if theres any
example code out there that i could view.



On 12.02.2005, at 14:14:30 +0100, Uli Kusterer answered:
  I don't think Cocoa or QuickTime support loading pbm and ppm images
yet. IIRC, PPM is this text-based file format that uses numeric
strings to encode each pixel, right?

No, this is only true for the seldom used formats P1, P2 and P3.
  In that case, your best bet is to use NSString
-stringWithContentsOfFile: to load the PPM, and then to parse that

No, never, you should always use NSData! The formats P4, P5, P6 and P7 contain raw (binary) data, which are very similar to the data structure of an NSBitmapImageRep. To create an NSImageRep from pbm data is a relatively simple job. Here <http://www.heinrich-giesen.homepage.t-online.de/MacOSX/> in Archive.zip I offer you some files from one of my applications. PBMImageRep is a subclass of NSBitmapImageRep and registers itself at NSImageRep with: [NSImageRep registerImageRepClass:[self class]]; So you can write:

id aRep = [NSImageRep imageRepWithContentsOfFile:pbmFileName];
or test if it works with pbm data:
BOOL rtn = [NSImageRep canInitWithData:[NSData dataWithContentsOfFile: pbmFileName]];


If you then really need an NSImage, create one:
NSImage *img = [[NSImage alloc] initWithSize:NSZeroSize];
[img addRepresentation:aRep];

--
Heinrich Giesen

email: email@hidden




Hi,
Thanks for the help guys. just a couple of questions. do i pass the pbmFileName as a NSString or something different. Basically i know the name of the ppm file to be loaded, for example "dan.ppm" should i save it as a NSString and parse that into the pbmFileName or do i have to pass it as a NSData? the reason i ask is when i try the bool test it always returns 0. if so, how do i pass the ppm file as a NSData?
Thanks again the help!! :-)
Danny


_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today! http://www.msn.co.uk/messenger


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: help with NSImage (From: Heinrich Giesen <email@hidden>)

  • Prev by Date: Re: Pure Quartz vs. Cocoa-Objects ... why is Quartz slower?
  • Next by Date: Re: Objective-C BufferedReader
  • Previous by thread: Re: help with NSImage
  • Next by thread: NSImageView only for images?
  • Index(es):
    • Date
    • Thread