B4A Library [B4X] BitmapCreator Effects

BitmapCreatorEffects class includes all kinds of very simple to use image effects.
The class is cross platform and compatible with B4J (v6.3+), B4A (v8.3+) and B4i (v5.0+).
Example:
B4X:
'Greyscale an image:
Dim GreyImage As B4XBitmap = effects.GreyScale(ExistingBmp)
'Blur an image:
Dim BlurImage As B4XBitmap = effects.Blur(ExistingBmp)


The attached examples demonstrate the various methods.


Updates

v1.40 - Adds support for B4XImageViews (XUI Views).
- New ScaleDownImages flag. True by default. The updated example demonstrates the usage. Note that if not using B4XImageView then you should set the image when ScaleDown = False, with XUIViewsUtils.SetBitmapAndFill.
v1.31 -New FadeBorders effect. See post #9: https://www.b4x.com/android/forum/threads/b4x-bitmapcreator-effects.93608/#post-672188
v1.21 - New ReplaceColor method.
v1.20 - Added PieceSize to ImplodeAnimated and added FlipVertical and FlipHorizontal methods.
v1.10 - Adds TransitionAnimated method to transition between two bitmaps.
 

Attachments

  • EffectsExample.zip
    376.6 KB · Views: 1,051
  • B4XBitmapEffects.b4xlib
    3.3 KB · Views: 1,053
Last edited:

Pitag

Member
Licensed User
Longtime User
I updated the Library to 1.40 (the online version is still reported as 1.31), but i get an error if i try to use B4XImageView instead of regular ImageView. (The reason i did the update was because i need to use B4XImageView)

If i write the line:
B4X:
effects.ImplodeAnimated(1500, OriginalBmp,B4XImageView1,50)

in the Logs windows i get the warning message: type does not match (warning #22) and if i run the code i get the following error

B4X:
java.lang.ClassCastException: b4a.example.b4ximageview cannot be cast to android.view.View
    at anywheresoftware.b4a.objects.B4XViewWrapper.asViewWrapper(B4XViewWrapper.java:89)
    at anywheresoftware.b4a.objects.B4XViewWrapper.getTag(B4XViewWrapper.java:583)
    at b4a.example.bitmapcreatoreffects._setbitmap(bitmapcreatoreffects.java:1719)
    at b4a.example.bitmapcreatoreffects$ResumableSub_TransitionAnimated.resume(bitmapcreatoreffects.java:710)
    at b4a.example.bitmapcreatoreffects._transitionanimated(bitmapcreatoreffects.java:530)
    at b4a.example.main._button2_click(main.java:459)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:6291)
    at android.view.View$PerformClick.run(View.java:24931)
    at android.os.Handler.handleCallback(Handler.java:808)
    at android.os.Handler.dispatchMessage(Handler.java:101)
    at android.os.Looper.loop(Looper.java:166)
    at android.app.ActivityThread.main(ActivityThread.java:7529)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
It seems that i found a solution, but i m not sure if it is the good one

This code do not works
B4X:
effects.ImplodeAnimated(1500, OriginalBmp,B4XImageView1,50)

the following works
B4X:
effects.ImplodeAnimated(1500, OriginalBmp, B4XImageView1.mbase,50)
 
Top