Android Question Rotating a bitmap

Azhar

Active Member
Licensed User
Longtime User
Hello All,

I have created an analogue gauge from a bitmap image. It doesn't have any needle pointer so I created one in GIMP with a transparent background (also a bitmap).

I configured an imageView control to float on top of the panel containing the gauge bitmap and configured the imageView control to load with the needle pointer bitmap.

When the gauge values are neutral (no needle movement required) all is fine. But when the measurement values change, using the RSImageProcessing library to rotate it a few degrees proportional to the change in value, the needle will rotate nicely but the imageView will then have an opaque black background which obliterates the gauge bitmap.

Does anyone know how to overcome this? Also when the needle rotates 45 degrees, the needle 'stretches' to the corner of the imageView control making it longer.

I was considering drawing lines instead but I rather like the needle.

I've attached two screenshots. The last one shows the needle pointing downwards with an opaque background.

Any advice is most appreciated.
 

Attachments

  • Screenshot_20161230-203003.png
    Screenshot_20161230-203003.png
    91.6 KB · Views: 304
  • Screenshot_20161230-203033.png
    Screenshot_20161230-203033.png
    96.9 KB · Views: 261

sorex

Expert
Licensed User
Longtime User
did you try with the normal canvas operations?

there's a .drawbitmapRotated function if I recallright.
 
Upvote 0

Azhar

Active Member
Licensed User
Longtime User
did you try with the normal canvas operations?

there's a .drawbitmapRotated function if I recallright.
Thanks Sorex, I shall take a look at that now.
BTW, I exported the needle with transparent background as a .png file and configured the RSImageProcessing library function with this and it kept the background transparency upon rotation. But unfortunately the needle changes dimensions in the square imageView control. Hopefully on the canvas control it won't.

Azhar
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
instead of drawing you could also put it as imageview above the gauge and rotate the imageview.

this is possible since android 3.0+
 
Upvote 0

Azhar

Active Member
Licensed User
Longtime User
Did you have a look at the B4A Beginner's Guide, chapter 16.2.2 Drawing rotating bitmaps / RotatingNeedle?
Hi Klaus,

I haven't as such but I will and thanks very much for your advice.

I have actually resolved the problem with the needle stretching out when rotated 30 to 60 degrees (and around the corners of the square imageView box.
I created the needle with a circle around it with an opacity set to just 1. This forced the image not to be stretched out when rotated (as the needle was bound to the circle which 'filled up' the image size proportionally).
Also, loading up a .png file into the control as opposed to a .bmp retained it's background transparency.

Kind regards,

Azhar
 
Upvote 0
Top