Page 1 of 1

Create bitmap from array

Posted: Tue Jan 18, 2011 7:01 pm
by zylesea
How do I create a bitmap from an arry and plot that as a brush or sprite?
Given I want to do some kind of oscilloscope I now draw lined from one sample point of my array to the next.

Code: Select all

For k=0 To 498
    last_temp_o=temp_o
    m=k*5
    temp_o=noise[m+2]+noise[m+4]
    temp_o=temp_o/4
    Line (k+12, 180+temp_o,k+12,180+last_temp_o, $00cc80)
    If k<415
    Line (k+511, 180+oszidata[k],k+511,180+oszidata[k+1], $00cc80)
    EndIf
    oszidata[k]=temp_o
  Next                  
But drawing lots of lines (499/125ms) is rather cpu time intensive, hence I want to precalculate a bitmap out of my sample and plot it as one single brush. Unfortunately I don't have a clue how to do this. Any hints?

Re: Create bitmap from array

Posted: Sat Jan 22, 2011 12:41 am
by airsoftsoftwair
You could simply draw the lines to an offscreen bitmap using SelectBrush(). After you have drawn the lines, you can then just display the whole brush. Alternatively, you can use a double buffer setup using BeginDoubleBuffer() and Flip().