Performance on Bitmap?

Roadrunner

Member
Licensed User
Hello there,

I've got a bitmap which have a grid (horizontal and vertical lines).
In this grid I'm plotting values from left to right.

If I'm on the right end I will scroll the bitmap one pixel to the left.
To do that I have a loop that counts on bitmap.width.
Within that loop there is another loop (bitmap.height) reading the pixel color of the right neightbor and plots them to the actual position.

On the desktop application it's fast enough to have a "scrolling effect". But on my mobile device it's extremly slow and totally unusable.

The bitmap have a size of 100x80 - so there are 8000 get / setpixel-commands. Too much for my mobile :(

Does anyone have an idea to scroll bitmaps ? :sign0085:
 

Roadrunner

Member
Licensed User
Scrolling means that the whole image will be moved by one pixel to the left. The now missing pixel on the right will be redrawn.
If this will be done every second, you have a scrolling effect (like on jump'n'run games)

There is some example of my code:

B4X:
   For i=0 To bitmap1.Width-2
   For ii=1 To bitmap1.Height-2
   wi.text = i
   wii.text = ii
   col = bitmap1.getpixel1(i+1,ii)
   Select col
   Case cWhite 
      bitmap1.SetPixel(i,ii,cWhite)
   Case cBlack 
      bitmap1.SetPixel(i,ii,cBlack)
   Case cRed 
      bitmap1.SetPixel(i,ii,cRed)
   End Select
   bitmap1.SetPixel(bitmap1.width-1,ii,cWhite)
      Next ii
   Next i
   bitmap1.SetPixel(noscroll-2,wert+120,cRed)
 

Roadrunner

Member
Licensed User
You should use DrawImage instead.
I've attached a small example of a scrolling bitmap (the bitmap size is 1460x40).
Thanks for your reply :)

My main problem is that I don't have a fixed image.
On start I'm drawing my grid bitmap. Then on every timer event I'm adding a pixel (value of a measurement) on that grid. After that I have to scroll the whole bitmap on one pixel and have to redraw the grid on the right side.

I attached my example for a better understanding.
 
Last edited:

RandomCoder

Well-Known Member
Licensed User
Your example didn't do anything???
Why was the yearup image commented out?

Anyway, I've made a couple of changes, hope it's what you had in mind.

Regards,
RandomCoder
 

Attachments

Roadrunner

Member
Licensed User
Think I got it fixed now...

Normally I'm drawing my values in the bitmap directly so I have to work with the whole bitmap.

Now I'm changed it to a really bitmap-file, put my values into an array and now scrolling in the way Erel is doing and then start again at the beginning.

So I only have to redraw my values into the bitmap every 10 times.

Thanks all for your help :sign0060:
 
Top