Render a View to a Bitmap - Some questions
Posted: Thu Jan 21, 2016 12:23 pm
I'm finally get able (more or less) to do what I'm looking for.
Well, I've a Ruby component that draw some graphic: in this case a rectangle with a random color; in my real plugin, it processes an array of 400.000 samples (or more) and draw the waveform (I'm loading a sample and display its waveform; with a Drumloop, the number of samples is big).
Since I've a redrawing 100 times at second, I've lots of operations coming out from that Ruby component, which freeze the whole application.
The only solution (for what I see) is to render the generated waveform display to Bitmap.
So I've made this module that (on event trigger) generate the View; then it triggers a "Bitmap Create" that (trought Sample & Hold) create it and store within the schematic:
Here's the schematic:
The problem I have now are these:
1 - Why when I trigger "Create Bitmap" the first time, it continuously trigger S&H? (watch at the Trigger counter I've inserted inside the module). It should trigger once, not continuously. Fixed; I've link the input trigger directly to S&H trigger and removed the one from Bitmap Create, so it trigger just once now (p.s. I've linked it as "second" order-position, so it first creates the bitmap, then store it).
2 - Why the generated bitmap position has an offset? It starts from grid 3,6. (Fixed; I've set X,Y=0 to the MGUI inside Display module)
3 - Why if I use "redraw 0" inside the event method of my Display module the whole application crash? (in fact I'd like to do the redraw when I click on trigger; not waiting the redraw invoked by the Redraw module and be "lucky").
4 - How can I make sure that "Create Bitmap" is called (and will finish its task to create the bitmap) after the Display module Draw its graphic and before the draw method loop again (which will draw nothing)? Because at the moment, the "double" trigger could generate an empty Bitmap (if I Create Bitmap after the draw method has been recalled). I'm not sure of this, but I think could happens (even if I didn't encounter this yet). Maybe "draws" events are executed following a stack? This will ensure that Create Bitmap will be executed before the Display module draw acts again, but I don't know! Flowstone is single process-thread (which will not introduce concurrency issues here)?
I hope you can help me! I'm improving myself on FlowStone day per day! Love it!!!
Thanks!
Well, I've a Ruby component that draw some graphic: in this case a rectangle with a random color; in my real plugin, it processes an array of 400.000 samples (or more) and draw the waveform (I'm loading a sample and display its waveform; with a Drumloop, the number of samples is big).
Since I've a redrawing 100 times at second, I've lots of operations coming out from that Ruby component, which freeze the whole application.
The only solution (for what I see) is to render the generated waveform display to Bitmap.
So I've made this module that (on event trigger) generate the View; then it triggers a "Bitmap Create" that (trought Sample & Hold) create it and store within the schematic:
Here's the schematic:
The problem I have now are these:
1 - Why when I trigger "Create Bitmap" the first time, it continuously trigger S&H? (watch at the Trigger counter I've inserted inside the module). It should trigger once, not continuously. Fixed; I've link the input trigger directly to S&H trigger and removed the one from Bitmap Create, so it trigger just once now (p.s. I've linked it as "second" order-position, so it first creates the bitmap, then store it).
2 - Why the generated bitmap position has an offset? It starts from grid 3,6. (Fixed; I've set X,Y=0 to the MGUI inside Display module)
3 - Why if I use "redraw 0" inside the event method of my Display module the whole application crash? (in fact I'd like to do the redraw when I click on trigger; not waiting the redraw invoked by the Redraw module and be "lucky").
4 - How can I make sure that "Create Bitmap" is called (and will finish its task to create the bitmap) after the Display module Draw its graphic and before the draw method loop again (which will draw nothing)? Because at the moment, the "double" trigger could generate an empty Bitmap (if I Create Bitmap after the draw method has been recalled). I'm not sure of this, but I think could happens (even if I didn't encounter this yet). Maybe "draws" events are executed following a stack? This will ensure that Create Bitmap will be executed before the Display module draw acts again, but I don't know! Flowstone is single process-thread (which will not introduce concurrency issues here)?
I hope you can help me! I'm improving myself on FlowStone day per day! Love it!!!
Thanks!