Create bitmap from array

Discuss any general programming issues here
Post Reply
zylesea
Posts: 201
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

Create bitmap from array

Post by zylesea » Tue Jan 18, 2011 7:01 pm

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?

User avatar
airsoftsoftwair
Posts: 3110
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Create bitmap from array

Post by airsoftsoftwair » Sat Jan 22, 2011 12:41 am

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().

Post Reply