B4A Library BetterImageView

This is an enhanced ImageView, closer to the standard Java ImageView, with two layers (foreground and background), a touch event, a scaletype setting (similar to gravity, but for the foreground), an alpha setting and a few functions to alter the colors.
I fixed the issue with the gravity of the B4A ImageView (since it is a property of bitmapdrawables, the setting was lost when the background was changed to another type of drawable; now, this setting is kept whatever may be the contents).
It is a custom view that you can add in the designer.

screenshot.jpg
scnsht2.jpg


v1.1:
- The background set in the designer is properly read now;
- Added five functions: AlterColors, ApplyColorFilter, ReduceColors, LoadScaledBitmap and LoadNinePatchDrawable;
- Added a new demo;
- Fixed an issue in the first demo with some screen resolutions.
 

Attachments

  • BetterImageView v1.1.zip
    132.8 KB · Views: 1,534
  • Java - BetterImageView.zip
    7 KB · Views: 376
Last edited:

Informatix

Expert
Licensed User
Longtime User
It looks like a great library. Though I don't see why it will be better to have it as part of the core library...

The core library is packaged in every app created. The core ImageView is simple and properly handles its "simple" task to show an image.
I understand your point and have no problem with this.
My request about custom views would be to improve their integration in the designer. For example, there's no mean to set a background image for this view in the designer. The label used to pass settings to the custom view has no background set.
 

thedesolatesoul

Expert
Licensed User
Longtime User
It looks like a great library. Though I don't see why it will be better to have it as part of the core library...
The core library is packaged in every app created. The core ImageView is simple and properly handles its "simple" task to show an image.
I think what he means is that this library adds simple enough features that he feels should be a part of the core library. (I am not sure whether core or ImageView lib, but something packages into B4A official release)

Anyway, thanks Informatix! (sorry to hijack the thread)
 

Beja

Expert
Licensed User
Longtime User
Thank you informatix for this great library.
 

RonC.

Member
Licensed User
Longtime User
Praise: Informatrix, every time I get to a thread that you've started, your libraries and code really blow me away. Knock me over with a feather. ;)

All the demos worked for me except the last...

Had an issue with BIV demo 4 on Android 4.4.2 (Motorola Moto G), even in release... Got an exception and even when I passed that exception, it didn't seem as the other images hue or saturation changed. Labels didn't show for any of the images after the first.

As always, I'm adding the disclaimer that I don't know if it's me. lol.
 

Attachments

  • Screenshot_2014-05-14-23-22-18.png
    Screenshot_2014-05-14-23-22-18.png
    282.8 KB · Views: 391

Informatix

Expert
Licensed User
Longtime User
Praise: Informatrix, every time I get to a thread that you've started, your libraries and code really blow me away. Knock me over with a feather. ;)

All the demos worked for me except the last...

Had an issue with BIV demo 4 on Android 4.4.2 (Motorola Moto G), even in release... Got an exception and even when I passed that exception, it didn't seem as the other images hue or saturation changed. Labels didn't show for any of the images after the first.

As always, I'm adding the disclaimer that I don't know if it's me. lol.
I have no idea of what's happened because I run the same Android version on my Nexus 7 and all is fine. Maybe you could force the bitmap to be mutable with the MakeMutable function of my Accelerated Surface lib.
 

FernandoMassa

Member
Licensed User
Longtime User
The BetterImageView supports LongClick?
In my program is not working.
Have to do anything special?
 

FernandoMassa

Member
Licensed User
Longtime User
thanks for the super fast response. :)
I found that the panel should appear in LongClick, was below the BetterImageView. (though in the Designer panel is underneath)
Brighttofront solved the problem.
Thank you very much.;)
 

Thraka

Member
Licensed User
Longtime User
All of your samples use background bitmap though, along (sometimes) with the normal bitmap. Mine keep showing a solid white background when I only use the Bitmap property.

...

Ok I figured it out. :) Since the control is added as a custom type, it gets a solid white background because it's a ColorDrawable. Setting this to transparent had no effect. I have to change it to BitmapDrawable and it works as expected. I guess when you set the BackgroundBitmap property to a bitmap, it does this automatically. So the only way to get a bitmap to show without using the backgroundbitmap is to set the Drawable type to BitmapDrawable.

Working now, thanks :)
 

Informatix

Expert
Licensed User
Longtime User
All of your samples use background bitmap though, along (sometimes) with the normal bitmap. Mine keep showing a solid white background when I only use the Bitmap property.
I don't know what you looked at but all my examples use a foreground (the B4A logo) and a background (a photo).

So the only way to get a bitmap to show without using the backgroundbitmap is to set the Drawable type to BitmapDrawable.
I'm not sure that I understand you. You can use a bitmap directly with BackgroundBitmap or any drawable with Background.
 

Thraka

Member
Licensed User
Longtime User
:) I'm saying, don't use background at all. Don't set the property. If you just drop the control on a panel, then in code set the bitmap (not backgroundbitmap) to something, it will just display a solid white area.

To get it to work this way, you must change the Drawable type to BitmapDrawable. Then whatever bitmap (not backgroundbitmap) you put on it will show.
 
Top