Bert's question clarified: How to put a pixel into a view??

Bert
Unregistered
 
Post: #1
That's really it! All I need to know is how to put a pixel directly into a view, the fastest way possible. I know this must be a "dumb" question to most of you, but please bear with me!!

Thanks to everyone who responded to my last (first) post. I hope this makes the question clearer.

-- Bert
Quote this message in a reply
Apprentice
Posts: 19
Joined: 2004.10
Post: #2
The easiest way is to just use:

Code:
[NSBezierPath fillRect:NSMakeRect(x, y, w, h)];
This will draw a rect of size w(idth) and h(eight). To draw exactly a single pixel at point (10,20):

Code:
[NSBezierPath fillRect:NSMakeRect(10.5, 20.5, 1, 1)];
The 0.5's are there because of the way the coordinate system works in a default view.


There are moer optimal ways, but this is easiest.
Quote this message in a reply
Member
Posts: 198
Joined: 2005.01
Post: #3
It'd be super slow for more than a couple of pixels too, I'd think.

Bert, you'll have to tell us what you want to do at a little higher level, I think, before we can give you any intelligent advice. For example if you want to display a static image, you could load it up and blit it using those same NS* primitives (and do some 2D things like rotations, etc). If you want to do things more complicated than that, especially if it will involved a *lot* of pixel pushing or complex scenes, the answer is likely "GL".

Cryptic Allusion Games / Cryptic Allusion, LLC
http://www.cagames.com/
Quote this message in a reply
Apprentice
Posts: 19
Joined: 2004.10
Post: #4
Yes, Dan, OpenGL would be faster, although it's quite a bit more complicated. Smile

Incidentally, I forgot to mention NSRectFillList() (not specifically Cocoa, but still callable in Obj-C), that will fill a list, and is quite fast.

Does anyone know if these APIs are sped up to use the video card in Tiger (ie, fast without the openGL)?
Quote this message in a reply
Member
Posts: 198
Joined: 2005.01
Post: #5
That was rumored to happen in 10.4.1 for cards with the necessary shader support (aka Quartz 2D Extreme) but I'm not sure if it really did (don't have one myself...)

Cryptic Allusion Games / Cryptic Allusion, LLC
http://www.cagames.com/
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #6
No, Q2DE is not enabled in 10.4.1.
Yes it will be enabled in the future.
So, no, Quartz still renders in software.
But, yes, Quartz software rendering in Tiger is about 5x faster than in Panther.

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Post Reply