• 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
NSImage is a pain
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSImage is a pain


  • Subject: NSImage is a pain
  • From: "Theodore H. Smith" <email@hidden>
  • Date: Thu, 23 Jun 2005 17:59:58 +0100


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.

So I find out from google that I must use NSImageRep, via turning the image into a tiff and back! Why can't NSImage just have a feature to turn one of it's representations into a proper bitmapped image?

So, I turn it into a tiff and back again into an NSBitmapImageRep.

I see very awkward methods like getPixelAt, or even worse getColorAt! How can you create a method that will instantiate a whole new object (ColorAt, and then dump it into an auto-release mechanism, just to get one pixel is beyond me. These things used to be done in a few instructions or even one if you were lucky. What if I allocate so many NSColor*'s simply because the image is so big? Argh, it doesn't bear thinking about.

I alter the data's internals, using bitmapData instead, wisely.

Then I find that there is no simple way to get an NSImage from an NSImageRep. There is no "-(NSImage*)ownWithNewImage;" method is there?

So I have to do more reading of docs on this wholly awkward design, to find out that there is no simple way to do the obvious.

So I look for [NSImaage initWithRep:]... Nope! There is no [NSImage initWithRep:] is there?

I see [NSImage initWithData:]... right, well I inited my NSImageRep FROM the data, so I should be able to get an NSData FROM the imageRep, right? That would make sense.

But no, you can't get data from the NSImageRep!

So I try "addRepresentation:". That should be pretty straightforward, right? After all, all the information that the NSImage needs, such as the size, the samplesize, etc, are *already* set into the NSImageRep.

Well no, after running something that seems like it should work simply, it turns out it doesn't work.

So I read up the docs, again, and find unless I do some special things, like resetting the size "and so on" (in Apple's words), it won't work. "After invoking this method, you may need to explicitly set features of the new representation, such as size, number of colors, and so on."

But exactly what does this "and so on" consist of?? Unless I'm able to guess exactly what this "and so on" consists of, the image won't draw. And how am I meant to know what it consists of?

Can you feel my frustration here?

Sometimes I wonder if there are people who pride themselves on conquering something complicated and hard, so much, that they don't mind that what they have learnt to use is needlessly hard and needlessly complicated.

Me, I'd rather conquer something complex that is only complex because that is the simplest possible way it could be after everything has been tried to make it simpler (without defeating the purpose) and it is still complex.

--
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


  • Follow-Ups:
    • Re: NSImage is a pain
      • From: john <email@hidden>
    • Re: NSImage is a pain
      • From: j o a r <email@hidden>
  • Prev by Date: Re: NEWBIE: Core Data Orientation questions
  • Next by Date: Re: NSImage is a pain
  • Previous by thread: Video Problems With QTMovieView
  • Next by thread: Re: NSImage is a pain
  • Index(es):
    • Date
    • Thread