user460854
user460854

Reputation: 1

Blackberry Scrolling in Canvas

Hi friends I searched so many threads but I didnt get any solution for scrolling vertically when the bitmaps are drawn using graphics with paint method.

Please help me.

Upvotes: 0

Views: 220

Answers (1)

Nahuel Bergamo
Nahuel Bergamo

Reputation: 293

If you are trying to (as Jonathan said) scroll trough an image that is larger than the screen.

To do it without any fancy function´s help and you are manually painting inside your graphics paint method, i would think of using 2 bitmaps, one as a buffer for your image and another one for the actual frame:

  1. Have your large_image in a "buffer" bitmap, and then create another bitmap to use as a canvas and paint this canvas to the screen (the same size of the screen).
  2. Clip your large_image to the size of the screen on the region of your bitmap that you want to paint on the next frame. Save that clipped bitmap to your canvas.
  3. Draw that canvas bitmap.
  4. Scroll the clipping of your large_image again (move x and y values) into your "canvas" bitmap
  5. repeat 3 and 4 until scrolling ends.

Hope it is clear, think of it as having your canvas as a camera to take smaller snapshots of your large_image and moving the large_image so that each snapshot in sequence creates the scrolling effect.

Cheers and hope it helps!.

Upvotes: 3

Related Questions