Re: NSImage is a pain
Re: NSImage is a pain
- Subject: Re: NSImage is a pain
- From: Michael McCracken <email@hidden>
- Date: Thu, 23 Jun 2005 13:32:58 -0700
Hi, honestly I find that I usually find the answer to my questions in
Apple's documentation faster than with Google. As an experiment, since
I'm rather unfamiliar with Cocoa's graphics processing, I tried to
find the answer to your question without leaving XCode.
I think that it does help to be used to the naming conventions,
because the second relevant thing I found was that NSBitmapImageRep
has a method -TIFFRepresentation. That returns an NSData, so you can
probably just create a new NSImage using [[NSImage alloc]
initWithData:[myBitmapImageRep TIFFRepresentation] and be done with
it. caveat: I didn't try that, and remember, I said I don't know so
much about Cocoa graphics.
Note that after "and so on" it says: "See NSImageRep and its
subclasses for the methods you use to complete initialization." That's
the link I followed to get the above.
The first relevant thing I found was from the "Drawing and Images"
topic - "Setting up an Image Representation" [1]. Note the part about
NSBitmapImageRep tells you not to worry about setting image
attributes.
Finally, I'd just follow up on joar's philosophical advice: the
information you need is almost always in the docs, especially for
mature parts of the frameworks. You just might need to read through
the "Conceptual" parts and not just the API parts, then let them stew
a bit. If you have a suggestion for improving the docs, make it
constructive and you will probably be appreciated.
-mike
[1]: http://developer.apple.com/documentation/Cocoa/Conceptual/DrawImages/Concepts/SettingUpImages.html
On 6/23/05, Theodore H. Smith <email@hidden> wrote:
> >> OK, so I wanted to load an image which had a white background, and
> >> treat that white as transparant. Seems reasonable enough, it's a
> >> common technique used in gif and many file formats.
> >>
> >> But no, it's not there.
> >>
> >
> > <newbie rant snipped>
> >
> > Face it, learning new things takes time - especially things that are
> > worth learning. Some things you just can't rush, and grokking a new
> > framework is one of them. You need to allow it some time to sink in.
>
>
> OK. Let me express it in a non-rant manner.
>
> The docs do not explain how to to create an NSImage from an
> NSImageRep. The closest it comes to saying how to do this, says "and
> so on". Which is vague.
>
> "After invoking this method, you may need to explicitly set features
> of the new representation, such as size, number of colors, and so on."
>
> "allow it some time to sink in". This requires material to sink in.
> Mostly there is the material to sink in. And so yep, I'm doing that.
>
> I've just noted how in this particular case, there is a hole in
> Apple's material (the "and so on" hole), and there is nothing to sink
> in.
>
> What do you suggest then? I looked on google. I looked on cocoadev.com
>
> Experiment on setting stuff?
>
> I count 12 "set" methods that could be set in NSImage. How do I find
> out the right combination without doing it in excess? Use some kind
> of binary search technique with combinations of set methods?
>
> What is the problem is not in setting methods in NSImage? I could
> have done all that experimentation and end up with nothing.
>
> Let me make this simple and clear. The docs are lacking on [NSImage
> addRepresentation].
>
>
> One of my other points, is that the Cocoa framework does not appear
> as well designed as I would have made it. For example: [NSImageRep
> colorAtX:(int)x y:(int)y] Do you see any design flaws in such a method?
>
> For someone who really appreciates good design, Cocoa's colorAtX:y:
> method does not make me feel comfortable. I see good design in most
> of the Cocoa classes I've come across. NSImage/NSImageRep are two
> that I do not see good design, they are in the minority by far, of
> course.
>
> To me, an example of good design, is NSString's file path methods.
> They do what you want, do it well, are clearly designed, and take on
> a task that is awkward for most software developers yet most software
> developers do need. GREAT. Exactly correct design.
>
> NSImage/NSImageRep however, I can see many design problems there.
>
> --
> http://elfdata.com/plugin/ Industrial strength string processing,
> made easy.
>
> "All things are logical. Putting free-will in the slot for premises in
> a logical system, makes all of life both understandable, and free."
>
> _______________________________________________
> 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
>
--
Michael McCracken
UCSD CSE PhD Student
San Diego Supercomputer Center
http://www.cse.ucsd.edu/~mmccrack/
_______________________________________________
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