Page 1 of 3
Manipulate Bitmap in DSP Code
Posted: Sun May 22, 2016 6:26 am
by aronb
Hi,
I need to manipulate a small Bitmap (128 x 128 pixels max) fast, and was wondering if a Bitmap (image array) can be "loaded" into the DSP Code Module and accessed that way.
For example to extract color information from a particular pixel location... think of it like "GetPix" (Get Pixel) but way faster than green modules ?
I want to use a Bitmap Image for audio waveform manipulation, and vise versa
Thanks,
Aron
Re: Manipulate Bitmap in DSP Code
Posted: Sun May 22, 2016 3:02 pm
by martinvicanek
You could load the Bitmap into mem and then manipulate it using wave read, code and analyzer. However, to display the result you'd have to convert back to bitmap, which is slow.
Re: Manipulate Bitmap in DSP Code
Posted: Mon May 23, 2016 5:10 am
by aronb
Martin,
Can you explain a bit more please, step by step
Would I still use the GetPix primitive and write it to an array then to mem then to DSP ?
Thank you very much for the help,
Aron
Re: Manipulate Bitmap in DSP Code
Posted: Mon May 23, 2016 7:33 am
by martinvicanek
Here is a demo. It is fairly complicated, dunno if there is an easier way.
Edit: fixed initialization issue (thanks tulamide for pointing it out!)
Re: Manipulate Bitmap in DSP Code
Posted: Mon May 23, 2016 10:37 pm
by tulamide
martinvicanek wrote:Here is a demo. It is fairly complicated, dunno if there is an easier way.
Is it supposed to change something when turning the brightness knob? Or does it need additional modules/prims to work? I added and activated an asio out, but nothing happened.
My two cents:
The main idea is good. Convert the bitmap to an array once, store changes to the array and only convert the array back to a bitmap when a redraw is needed. Might be doable with Ruby as well, but the main downside is that we can't make use of the graphics card's power, especially the 2d shaders.
Re: Manipulate Bitmap in DSP Code
Posted: Tue May 24, 2016 6:43 am
by martinvicanek
For the brightness knob to work you might have to press some of the triggers inside the module in some order.
Yes, I suppose you could do most of the first part, the bitmap to mem conversion, in Ruby. I might upload a more interesting demo later on.
Re: Manipulate Bitmap in DSP Code
Posted: Tue May 24, 2016 7:06 pm
by martinvicanek
The above demo features a very simple brightness adjustment. It has clipping artifacts which result in hue distortion. Do not use for serious image processing!
Perhaps a more useful application is attached below. It demoes a control for hue rotation, which might be handy if you want to dynamically sweep the color of a LED from green to red, say, with all nuances of yellow and orange (Spogg, are you reading this?

) in between.
@aronb, what kind of image manipulation did you have in mind?
Re: Manipulate Bitmap in DSP Code
Posted: Wed May 25, 2016 9:14 am
by Spogg
martinvicanek wrote:... orange (Spogg, are you reading this?

).
If the poster is you Martin, I always read it! Especially if orange is involved.
I love this demo but I had a strange issue. I put the whole thing into a module with graphics enabled (so I could put it into my toolbox whole) and it stopped working. I added an ASIO prim. Still not. So I took it out of the module and it still failed to work. Restarted FS and reloaded the module and it worked. Then repeated the above with the same result. I did try the trigger switch but I couldn't revive the function. Never seen this behaviour before.
What am I doing wrong? I bet I'm going to feel foolish quite soon...
Cheers
Spogg
Re: Manipulate Bitmap in DSP Code
Posted: Wed May 25, 2016 4:20 pm
by kortezzzz
@spogg
+1
Seems like the order of the triggers that being sent to the bitmap prim's should be carefully determined, or you loose the functionality for some reason.
@martin, thanks for this. very interesting schematic.
Re: Manipulate Bitmap in DSP Code
Posted: Wed May 25, 2016 8:14 pm
by martinvicanek
The problem was that the output bitmap memory allocation was not retriggered after duplicate. Fixed now.