B4J Library [B4X] B4J & B4A: Blur Image Effect

Hello everyone,
Nothing new hear, and yes this can be achieved using Bitmap Creator. I wrapped this last year whilst learning Java for a personal project. I've just cleaned it up a bit for the B4X community.

B4X library tab:
1770637879940.png


B4J Images:
1.jpg
2.jpg


B4A Images:
Screenshot_20260209-113232.jpg
Screenshot_20260209-113240.jpg


B4X Blur Image:
Private Sub Button1_Click
    Dim Img As B4XBitmap = ImageView1.GetBitmap ' CAN ALSO USE ImageView1.Snapshot
    If Img.IsInitialized = False Then Return

    'Loop for slow transition blur effect
    For i = 0 To 99
        BI.BlurAsync(Img, i)
        Sleep(20) '20 milliseconds per transition for slow blur
    Next
End Sub

Sub BI_BlurDone(Blurred As Object)
    Dim Bmp As B4XBitmap = Blurred
    If Bmp.IsInitialized = False Then Return
    ImageView1.SetBitmap(Bmp)
End Sub

SS_BlurImage

Author: Peter Simpson
Version: 1.0

    • Functions:
      • Cancel
        Cancel any pending blur task.
        This attempts to cancel the running future if present.
      • Release
        Release engine resources and shutdown the dispatcher.
        After calling release the engine cannot be reused.

    • Functions:
      • BlurPixels (pix As Int(), w As Int, h As Int, radius As Int) As Int()
  • BlurImage
    • Events:
      • BlurDone
    • Functions:
      • BlurAsync (Source As Object, Radius As Int)
        Start an asynchronous blur operation.
        Source is the platform image object or wrapper. Pass a Bitmap, Image, B4XBitmap.
        Radius is the blur radius.
      • Cancel
        Cancel any pending asynchronous blur operation.
        Cancellation is cooperative; if the blur is already running it will attempt to stop.
      • Initialize (EventName As String)
        Initialize the BlurImage engine.
      • IsInitialized As Boolean
      • Release
        Release resources used by the engine.
        This will cancel pending tasks and shut down the internal dispatcher.


Enjoy...
 

Attachments

  • BlurImage.zip
    155.5 KB · Views: 4
  • BlurImage Lib.zip
    6.8 KB · Views: 5
Top