Author Topic: Using LAMW objects, how to DrawBitmap() using only a PART of a Bitmap?  (Read 282 times)


  • Jr. Member
  • **
  • Posts: 74
  • Pascal dev
When I need to draw on the screen from a bitmap, I use something like this:

    jDrawingView1.DrawBitmap(jBitmap1.GetImage(), TargetRect.Left, TargetRect.Top, TargetRect.Right, TargetRect.Bottom); 

This works well, and it even automatically stretches the image to fit into the destination coordinates, which is very useful.

However, with the above method, I can only draw the entire source bitmap. Now I would like to be able to select only a portion of the source bitmap.

For example, if the source bitmap is 100x100 pixels, I would like to be able to select, say, a 30x30 rectangle at (10,10,40,10), and draw only that portion on the jDrawingView.

I could not find a method that allows to specify only a portion of the source bitmap, and I also am not sure of what should be an efficient way of doing that, and what object should I use.

For example, should I create another temporary jBitmap object at runtime, somehow (how?) copy into it the portion of the source bitmap that I want to use, and then use the temp object to call DrawBitmap()?

Or is there a function that I didn't discover yet that I can use?

Or should I use some other objects instead of jBitmap?

As I have to draw many such partial bitmaps to the screen, I'd like to know what's an efficient solution -- which method and objects would you recommend to use?

And best of all would be a couple of lines of code that show exactly how to do that...

Many thanks in advance to anyone who can help us in this regard.

All the best!

manlio mazzon gmail


  • Hero Member
  • *****
  • Posts: 1486
Re: Using LAMW objects, how to DrawBitmap() using only a PART of a Bitmap?
« Reply #1 on: August 03, 2019, 06:36:45 am »


Added method  "DrawCroppedBitmap" to jDrawingView component!

Thank you!!!
Lamw: Lazarus Android Module Wizard