As part of my program I have to convert an array of data into an image. The code works fine but because of the large number of points in the array, the process takes a very long time. One medium sized test file is 43200 points (360 x 120) and on my device it takes 233 seconds (nearly 4 min) to go through the data! This is not really acceptable and I wondered if anyone has any bright ideas for reducing the time. The only thing I can think of that might help is transfering the code to a small DLL. I am prepared to give that a go, but only if it really will help (I have never written DLLs before).
The code I am using is:
By the way, I have tried using the FastSetPixel method but that turned out to be slower than drawing a rectangle.
David.
The code I am using is:
B4X:
'palette is an imagelist of 1 x 200 pixel images for the colorschemes
drawer.New2(Img.Image,B4PObject(5))
brush1.New1(cBlack)
bX = 0 'the position of a block to draw on the image
bY = 0
bw = 1 'the size of the block drawn (each datapoint needs to be drawn as 1 pixel wide & 4 high)
bh = 4
Cols = arraylen(dataarray(),1) 'the array of source values
Rows = arraylen(dataarray(),2)
For y = 0 To Rows-1
label1.Text = " Drawing row " & y & " of " & Rows
form1.Refresh 'slows it down but when you are waiting 4 mins you need some feedback!
For x = 0 To Cols-1
brush1.Color = palette.Pixel(ColorScheme,0,dataarray(x,y))
drawer.FillRectangle2(brush1.Value,bx,by,bw,bh)
bX = bX + bw
Next
bY = bY + bh
bX = 0
Next
By the way, I have tried using the FastSetPixel method but that turned out to be slower than drawing a rectangle.
David.