views:

468

answers:

1

I found some blurring code at http://incubator.quasimondo.com/processing/stackblur.pde. Any ideas how to feed it, and get back, a UIImage or CGImageRef or something usable on the iPhone?

I'm not sure what format their BImage file is (Bitmap?) and what corresponds to it in Cocoa Touch.

Thanks.

+1  A: 

That code is in JVM-based Processing language. There are some attempts to port Processing on iPhone, but, I guess, at this stage, you'll either have to port that code by hands, digging in the entrails of the Processing implementation, or have to find yourself some another reference.

Update: On the second glance, they seem to be working with the plain low-level RGB data. So the code should be straightforward to port. Processing is close enough to Java, Java is close enough to C++, and you may compile C++ code as Objective C (just use .mm extension). Just copy-paste the code, fix syntax errors, and run it on your RGB data. Chances are good that you'll be able to get away with just that.

Dig into CGImage docs for information on how to get raw RGB data.

Update 2: The code you've linked to appears to be the stack blur. Author's page says there is a MIT-licensed C++ port of it in the Fog library (search here for Fog::Raster_C - StackBlur).

Alexander Gladysh
Got it. I had to change some things like new int[] to malloc() and delete to free()... It was then C not C++ anymore.
mahboudz
It appears that I would have to use this blur myself: http://stackoverflow.com/questions/1355144/iphone-clip-user-supplied-uiimage-by-a-given-cgpath. Perhaps you'd care to opensource your port somewhere on GitHub under some permissive license?If not, then I'll go for it myself :-)
Alexander Gladysh
BTW, I've found MIT-licensed C++ implementation of the Stack Blur: http://incubator.quasimondo.com/processing/fast_blur_deluxe.phpI've updated my answer.
Alexander Gladysh
If anyone has done a port that is specifically catered for the iPhone and wants to share it I'll happily add a link to it from the Stack blur page.
Quasimondo