I have a simple drawing issue. I have prepared a 2 dimensional array which has an animated wave motion. The array is updated every 1/10th of a second (this can be changed by the user). After the array is updated I want to display it as a 2 dimensional image with each array value as a pixel with color range from 0 to 255.
Any pointers on how to do this most efficiently…
Appreciate any help on this…
KAS
If it’s just a greyscale then the following (coded as I type, probably worth checking for errors) should work:
That’d be for a one-shot display, assuming you didn’t want to write a custom UIView subclass (which is worth the effort only if performance is a problem, probably).
My understanding from the docs is that the data provider can be created just once for the lifetime of your C buffer. I don’t think that’s true of the image, but if you created a CGBitmapContext to wrap your buffer rather than a provider and an image, that would safely persist and you could use
CGBitmapContextCreateImageto get a CGImageRef to be moving on with. It’s probably worth benchmarking both ways around if it’s an issue.EDIT: so the alternative way around would be:
CoreGraphics copies things about very lazily, so neither of these solutions should be as costly as the multiple steps imply.