On Jan 5, 2009, at 11:09 PM, Robert Monaghan wrote:

I am trying to figure out what the best method is, to playback "generated" graphics. I am downloading image data over ethernet, and then processing the imagery.

Currently I am creating a NSBitmapImageRep, and populating the buffer with my pixel data.
I then draw this inside an NSView.

If I create a for loop, the imagery isn't been updated in the view, even if I do a "setNeedsDisplay".

Is there a better way to do this?

-setNeedsDisplay: only _marks_ a view as needing display. The actual display doesn't happen until you return control to the AppKit so it has a chance to update any windows needing display (or containing views needing display).

What you should be doing is receiving the image data asynchronously. You get a message each time a chunk of data is received. You collect them as they come but you return to the main event loop after handling each one. When an image is complete, you process it into a bitmap object and call -setNeedsDisplay: on your view. Again, you return to the event loop after doing this. The event loop will notice that your view needs display and will call your drawRect: method to redraw it.

You can read more:

Cocoa Drawing Guide: Views and Drawing
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide/DrawingEnviron/chapter_2_section_6.html

Cocoa Drawing Guide: Using NSTimer for Animated Content
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide/AdvancedDrawing/chapter_9_section_5.html

Cocoa Drawing Guide: Using Cocoa Animation Objects
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide/AdvancedDrawing/chapter_9_section_6.html

View Programming Guide for Cocoa
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/

Cheers,
Ken

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to