B4A Library BetterImageView

Phayao

Active Member
Licensed User
Longtime User
If you replace the BetterImageView by an ImageView, do you have the same problem?
Hello,
meanwhile i realized that the problem is coming from a part that i did not mention in the code:
in the touch-event i open also a dialog window, so that the user can input the name of the waypoint.
If i do this, the program sooner or later just stops without errormessage.
Obviously the touch event and open a dialog is not compatible
 

Informatix

Expert
Licensed User
Longtime User
Put your dialog code in another sub and call this sub with CallSubDelayed.
 

Phayao

Active Member
Licensed User
Longtime User
Put your dialog code in another sub and call this sub with CallSubDelayed.
Thank you - this worked !
Strangely the customdialog is working now and also filedialog (from dialog lib ) BUT the filedialog does only work in debug mode and does not open in Release mode.
But this question goes probably too far beyond the original, so i dont waste your time with it, i'll play around with it.
Thanks so much for your incredible contributions !

Chris
 

Informatix

Expert
Licensed User
Longtime User
You have an alternative for the file dialog here.
 

Phayao

Active Member
Licensed User
Longtime User
You have an alternative for the file dialog here.
That's it - working like a Charm - thanks a lot !
without your advice I had to refer to much more complicated ways.

Hope i can contribute to this forum one day in a similar way.

Chris
 

Paul Edwards

Member
Licensed User
Longtime User

Hi,

I want to be able to click on different parts of an image, that will do different things. Is this possible with this library ?

Thanks,
Paul
 

Paul Edwards

Member
Licensed User
Longtime User
Yes, like any view with a Touch event. You have to filter the X and Y results of the touch action.

Yes I can get it to do what I need.

However, when I replace the log command with msgbox(), it works for a few clicks, then it crashes. It crashes in both the emulator and on a proper android device. Is this a known issue ?

Paul
 

Informatix

Expert
Licensed User
Longtime User
Yes I can get it to do what I need.

However, when I replace the log command with msgbox(), it works for a few clicks, then it crashes. It crashes in both the emulator and on a proper android device. Is this a known issue ?

Paul
Place the call to messagebox in a separate sub and call this sub with CallSubDelayed.
 

b2mvga

Member
Licensed User
Longtime User
Hi, I have one transparent PNG (3.png) and a JPG(3x4.jpg)... I put JPG in PNG using code:

BetterIV.BackgroundBitmap = LoadBitmap(File.DirAssets, "3x4.jpg")
BetterIV.Bitmap = LoadBitmapSample(File.DirAssets, "3.png", BetterIV.Width, BetterIV.Height)

This code works great on screen... The image 3x4.jpg appears on 3.png transparent...

After do this, I try save this merging:

Sub Button5_Click
Dim cvs As Canvas
cvs.Initialize(BetterIV)

Dim Out As OutputStream
Out = File.OpenOutput(File.DirRootExternal, "merging.png", False)
cvs.Bitmap.WriteToStream (Out,100,"PNG")
Out.Close
End Sub

However the file saved have only 3x4.jpg... the PNG Transparent is not saved in same file... how I can solve this?
 

Informatix

Expert
Licensed User
Longtime User
You write only the foreground bitmap to disk so the result is not surprising. To save the composite view, you have to take a screenshot of the view. You can find code for that in this forum, e.g. https://www.b4x.com/android/forum/threads/capture-complete-panel-to-imageview.40657/#content
 

JdV

Active Member
Licensed User
Longtime User
Hi

Thanks for sharing such an excellent library.

I see Demo4 (with its filters) works by setting the view's background bitmap. Should the filters also work if the demo is changed to set the view's foreground bitmap?

If not, is that by design?

Regards

Joe
 

Informatix

Expert
Licensed User
Longtime User
I see Demo4 (with its filters) works by setting the view's background bitmap. Should the filters also work if the demo is changed to set the view's foreground bitmap?

If not, is that by design?
The quickest answer to your question is to try by yourself.
If you look closely at the parameters of the functions, you will see that they take bitmaps as inputs and produce a new bitmap, so they are completely unrelated to the ImageView layer.
 

JdV

Active Member
Licensed User
Longtime User
Thanks for the quick reply.

My reason for asking is that in my own program I'm attempting to use a filter on an ImageView.Bitmap image and I get the following error:
java.lang.IllegalStateException: Immutable bitmap passed to Canvas constructor

The bitmap I'm using isn't saved locally but downloaded from the Internet and the ImageView.Bitmap is set directly.
 

Informatix

Expert
Licensed User
Longtime User
In the Accelerated Surface library, you have a function to convert your immutable bitmap:
B4X:
Dim IU As AS_ImageUtils
MutableBmp = IU.MakeMutable(ImmutableBmp)
You can also do that with the InitializeMutable constructor of the Bitmap class but it's simpler and faster with the above.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…