objective c - How to implement -draw for custom NSImageRep subclass -


i'm interested in creating nsimagerep subclass can hold double precision values. standard nsbitmapimagerep can hold single precision floats, chokes on doubles. nsbitmapimagerep exposes data buffer manipulation, , i'd retain ability manipulate data in place rather manipulate separate buffer i'll need convert image display.

i think subclassing straight forward except i'm not sure how handle basic part: drawing image. documentation lists -draw method need implement, makes sense, best way draw bitmap?

i saw 1 hesitant suggestion draw lots of little rectangles, 1 per pixel presumably: how implement custom image representation nsimage

is there more efficient approach? i've looked , can't find worked example of custom nsimagerep bitmap data-- examples use vector data.

also, find interesting method implement -draw, , not form of bounded draw. there way determine current clipping region within nsimagerep or avoid drawing parts of image aren't necessary?

i’m sure you’ve found solution post point, here’s findings if you’re still interested.

what i’ve found in implementing own nsimagerep there many inefficient ways of doing it, , don’t have implement starkly simple -(bool)draw method. if provide implementation of -(bool)drawinrect:, used instead in cases. in fact, in nsimagerep subclass, have yet see -(bool)draw being called when -(bool)drawinrect: present.

for actual drawing, i’ve been using core graphics, allows create images raw data , draw great deal of control , precision, while being extremely fast. representation still rather crude, yet it’s fast when dealing large images.

the whole subject direly lacks documentation, due there being little need additional representations outside of old standards (tiff, png, jpeg, etc). it’s rather frustrating research on if time i’ll see writing blog post detailing i’ve run across.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -