B4A Library Picasso-Transformations - an Image processing library (30 May - update in post #5)

This was requested by @ilan. It is a wrap for this Github project. I have added 14 of the available filters thus far and will add some more as and when time permits. Posting the following:

1. The B4A project demonstrating the 14 filters (comment / uncomment some of the code to see the various filters. I have only fitted 8 on the display of my device)
2. The Java code as it is at present
3. The B4A library - copy them to your additional library folder (it includes picasso-2.5.2.jar)

Eight of the 14 filters:
1.png



Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: PicassoTransform
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private ImageView1, ImageView2, ImageView3, ImageView4, ImageView5, ImageView6, ImageView7, ImageView8 As ImageView
  
    Dim rc As RoundedCornersTransformation
    Dim sf As SketchFilterTransformation
    Dim pft As PixelationFilterTransformation
    Dim tft As ToonFilterTransformation
    Dim cct As CropCircleTransformation
    Dim vft As VignetteFilterTransformation
    Dim swirl As SwirlFilterTransformation
    Dim mt As MaskTransformation
    Dim bdft As BuldgeDistortionFilterTransformation
    Dim chft As CrosshatchFilterTransformation
    Dim gsft As GlassSphereFilterTransformation
    Dim srft As SphereRefractionFilterTransformation
    Dim eft As ExposureFilterTransformation
    Dim emboss As EmbossFilterTransformation
  
    Dim bm As Bitmap
  
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
    rc.Initialize
    sf.Initialize
    pft.Initialize
    tft.Initialize
    cct.Initialize
    vft.Initialize
    swirl.Initialize
    mt.Initialize
    bdft.Initialize
    chft.Initialize
    gsft.Initialize
    srft.Initialize
    eft.Initialize
    emboss.Initialize

  
    bm.Initialize(File.DirAssets,"stitch.jpg")  
    gsft.ImageBitmap = bm
    gsft.CenterX = 0.5
    gsft.CenterY = 0.5
    gsft.RefractiveIndex = 0.65
    gsft.SphereRadius = 0.5
    ImageView1.Bitmap = gsft.applyGlassSphereFilterTransformation  
  
    bm.Initialize(File.DirAssets,"stitch.jpg")  
    eft.ImageBitmap = bm
    eft.Exposure = 0.5
    ImageView2.Bitmap = eft.applyExposureFilterTransformation
  
'    bm.Initialize(File.DirAssets,"stitch.jpg")  
'    srft.ImageBitmap = bm
'    srft.CenterX = 0.5
'    srft.CenterY = 0.5
'    srft.RefractiveIndex = 0.65
'    srft.SphereRadius = 0.5
'    ImageView2.Bitmap = srft.applySphereRefractionFilterTransformation  
  
  
'    bm.Initialize(File.DirAssets,"stitch.jpg")  
'    chft.ImageBitmap = bm
'    chft.CrossHatchSpacing = 0.03
'    chft.LineWidth = 0.003
'    ImageView1.Bitmap = chft.applyCrosshatchFilterTransformation
  
  
'    bm.Initialize(File.DirAssets,"stitch.jpg")  
'    cct.ImageBitmap = bm
'    ImageView1.Bitmap = cct.applyCropCircleTransformation
  

'    bm.Initialize(File.DirAssets,"stitch.jpg")  
'    bdft.ImageBitmap = bm
'    bdft.CenterX = 0.5
'    bdft.CenterY = 0.5
'    bdft.DistortionRadius = 0.5
'    bdft.DistortionScale = 0.75
'    ImageView1.Bitmap = bdft.applyBuldgeDistortionFilterTransformation
  

'    bm.Initialize(File.DirAssets,"stitch.jpg")
'    rc.ImageBitmap = bm
'    rc.CornerRadius = 30
'    rc.CornerType = rc.CornerType_ALL
'    rc.ImageMargin = 5
'    ImageView2.Bitmap = rc.applyRoundedCornersTransformation
  
    bm.Initialize(File.DirAssets,"stitch.jpg")
    vft.ImageBitmap = bm
    vft.CenterX = 0.5
    vft.CenterY = 0.5
    vft.VignetteStart = 0.1
    vft.VignetteEnd = 0.8
    vft.VignetteColor = Array As Float(0.2, 0.0, 0.2)                      'RGB ---> values range from 0 to 1
    ImageView3.Bitmap = vft.applyVignetteFilterTransformation

    bm.Initialize(File.DirAssets,"stitch.jpg")
    sf.ImageBitmap = bm
    ImageView4.Bitmap = sf.applySketchFilterTransformation
  
    bm.Initialize(File.DirAssets,"stitch.jpg")
    tft.ImageBitmap = bm
    tft.Threshold = 0.2
    tft.QuantizationLevels = 10.0
    ImageView5.Bitmap = tft.applyToonFilterTransformation

    bm.Initialize(File.DirAssets,"stitch.jpg")
    pft.ImageBitmap = bm
    pft.PixelSize = 10
    ImageView6.Bitmap = pft.applyPixelationFilterTransformation
  
'    bm.Initialize(File.DirAssets,"stitch.jpg")
'    swirl.ImageBitmap = bm
'    swirl.CenterX = 0.5
'    swirl.CenterY = 0.5
'    swirl.SwirlRadius = 0.5
'    swirl.SwirlAngle = 0.5
'    ImageView7.Bitmap = swirl.applySwirlFilterTransformation

    bm.Initialize(File.DirAssets,"stitch.jpg")
    emboss.ImageBitmap = bm
    emboss.Intensity = 2.0
    ImageView7.Bitmap = emboss.applyEmbossFilterTransformation

                  
    bm.Initialize(File.DirAssets,"stitch.jpg")
    mt.ImageBitmap = bm
    mt.addImageMask("mask_starfish")                         'masks should be in the /Objects/res/drawable folder of the B4A project and set to READ ONLY
    ImageView8.Bitmap = mt.applyMaskTransformation   
  
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Library as it stands at present:
PicassoTransform
Author:
Github: Daichi Furiya, Wrapped by: Johan Schoeman
Version: 1
  • BuldgeDistortionFilterTransformation
    Methods:
    • Initialize
    • applyBuldgeDistortionFilterTransformation As Object
      Performs a buldge distortion effect
    Properties:
    • CenterX As Float [write only]
    • CenterY As Float [write only]
    • DistortionRadius As Float [write only]
    • DistortionScale As Float [write only]
    • ImageBitmap As Bitmap [write only]
  • CropCircleTransformation
    Methods:
    • Initialize
    • applyCropCircleTransformation As Object
    Properties:
    • ImageBitmap As Bitmap [write only]
  • CrosshatchFilterTransformation
    Methods:
    • Initialize
    • applyCrosshatchFilterTransformation As Object
      Performs a cross hatch effect
    Properties:
    • CrossHatchSpacing As Float [write only]
    • ImageBitmap As Bitmap [write only]
    • LineWidth As Float [write only]
  • EmbossFilterTransformation
    Methods:
    • Initialize
    • applyEmbossFilterTransformation As Object
    Properties:
    • ImageBitmap As Bitmap [write only]
    • Intensity As Float [write only]
  • ExposureFilterTransformation
    Methods:
    • Initialize
    • applyExposureFilterTransformation As Object
    Properties:
    • Exposure As Float [write only]
    • ImageBitmap As Bitmap [write only]
  • GlassSphereFilterTransformation
    Methods:
    • Initialize
    • applyGlassSphereFilterTransformation As Object
      Performs a glass sphere effect
    Properties:
    • CenterX As Float [write only]
    • CenterY As Float [write only]
    • ImageBitmap As Bitmap [write only]
    • RefractiveIndex As Float [write only]
    • SphereRadius As Float [write only]
  • MaskTransformation
    Methods:
    • Initialize
    • addImageMask (mask As String)
    • applyMaskTransformation As Object
      Applies a mask to the image/bitmap
    Properties:
    • ImageBitmap As Bitmap [write only]
  • PixelationFilterTransformation
    Methods:
    • Initialize
    • applyPixelationFilterTransformation As Object
    Properties:
    • ImageBitmap As Bitmap [write only]
    • PixelSize As Float [write only]
  • RoundedCornersTransformation
    Fields:
    • CornerType_ALL As Int
    • CornerType_BOTTOM As Int
    • CornerType_BOTTOM_LEFT As Int
    • CornerType_BOTTOM_RIGHT As Int
    • CornerType_DIAGONAL_FROM_TOP_LEFT As Int
    • CornerType_DIAGONAL_FROM_TOP_RIGHT As Int
    • CornerType_LEFT As Int
    • CornerType_OTHER_BOTTOM_LEFT As Int
    • CornerType_OTHER_BOTTOM_RIGHT As Int
    • CornerType_OTHER_TOP_LEFT As Int
    • CornerType_OTHER_TOP_RIGHT As Int
    • CornerType_RIGHT As Int
    • CornerType_TOP As Int
    • CornerType_TOP_LEFT As Int
    • CornerType_TOP_RIGHT As Int
    Methods:
    • Initialize
    • applyRoundedCornersTransformation As Object
    Properties:
    • CornerRadius As Int [write only]
    • CornerType As Int [write only]
    • ImageBitmap As Bitmap [write only]
    • ImageMargin As Int [write only]
  • SketchFilterTransformation
    Methods:
    • Initialize
    • applySketchFilterTransformation As Object
    Properties:
    • ImageBitmap As Bitmap [write only]
  • SphereRefractionFilterTransformation
    Methods:
    • Initialize
    • applySphereRefractionFilterTransformation As Object
      Performs a sphere refraction effect
    Properties:
    • CenterX As Float [write only]
    • CenterY As Float [write only]
    • ImageBitmap As Bitmap [write only]
    • RefractiveIndex As Float [write only]
    • SphereRadius As Float [write only]
  • SwirlFilterTransformation
    Methods:
    • Initialize
    • applySwirlFilterTransformation As Object
      Apply a swirl filter to the image/bitmap
    Properties:
    • CenterX As Float [write only]
    • CenterY As Float [write only]
    • ImageBitmap As Bitmap [write only]
    • SwirlAngle As Float [write only]
    • SwirlRadius As Float [write only]
  • ToonFilterTransformation
    Methods:
    • Initialize
    • applyToonFilterTransformation As Object
    Properties:
    • ImageBitmap As Bitmap [write only]
    • QuantizationLevels As Float [write only]
    • Threshold As Float [write only]
  • VignetteFilterTransformation
    Methods:
    • Initialize
    • applyVignetteFilterTransformation As Object
      Performs a vignetting effect, fading out the image at the edges
    Properties:
    • CenterX As Float [write only]
    • CenterY As Float [write only]
    • ImageBitmap As Bitmap [write only]
    • VignetteColor() As Float [write only]
    • VignetteEnd As Float [write only]
    • VignetteStart As Float [write only]
 

Attachments

  • TheJavaCode.zip
    497.3 KB · Views: 346
  • PicassoTransformLibFiles.zip
    284.3 KB · Views: 479
  • b4aPicassoTransform.zip
    63.2 KB · Views: 389
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
An update. Have added the following 5 additional filters:
B4X:
Dim sobel As SobelEdgeDetectionFilterTransformation
Dim htft As HalftoneFilterTransformation
Dim bbft As BoxBlurFilterTransformation
Dim bft As BrightnessFilterTransformation
Dim cbft As ColorBalanceFilterTransformation

Posting the update B4A project, the Java code (only the src folder - see post one Java code for the libs folder that you need to compile the Java code), new B4A library files.

2.png


Sample Code:

B4X:
#Region  Project Attributes
    #ApplicationLabel: PicassoTransform
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private ImageView1, ImageView2, ImageView3, ImageView4, ImageView5, ImageView6, ImageView7, ImageView8 As ImageView
  
    Dim rc As RoundedCornersTransformation
    Dim sf As SketchFilterTransformation                           'done
    Dim pft As PixelationFilterTransformation                      'done
    Dim tft As ToonFilterTransformation                            'done
    Dim cct As CropCircleTransformation
    Dim vft As VignetteFilterTransformation                        'done
    Dim swirl As SwirlFilterTransformation
    Dim mt As MaskTransformation                                   'done
    Dim bdft As BuldgeDistortionFilterTransformation
    Dim chft As CrosshatchFilterTransformation
    Dim gsft As GlassSphereFilterTransformation                    'done
    Dim srft As SphereRefractionFilterTransformation
    Dim eft As ExposureFilterTransformation                        'done
    Dim emboss As EmbossFilterTransformation                       'done
    Dim sobel As SobelEdgeDetectionFilterTransformation
    Dim htft As HalftoneFilterTransformation
    Dim bbft As BoxBlurFilterTransformation
    Dim bft As BrightnessFilterTransformation
    Dim cbft As ColorBalanceFilterTransformation
  

  
    Dim bm As Bitmap
  
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
    rc.Initialize
    sf.Initialize
    pft.Initialize
    tft.Initialize
    cct.Initialize
    vft.Initialize
    swirl.Initialize
    mt.Initialize
    bdft.Initialize
    chft.Initialize
    gsft.Initialize
    srft.Initialize
    eft.Initialize
    emboss.Initialize
    sobel.Initialize
    htft.Initialize
    bbft.Initialize
    bft.Initialize
    cbft.Initialize

  
'    bm.Initialize(File.DirAssets,"stitch.jpg")  
'    gsft.ImageBitmap = bm
'    gsft.CenterX = 0.5
'    gsft.CenterY = 0.5
'    gsft.RefractiveIndex = 0.65
'    gsft.SphereRadius = 0.5
'    ImageView1.Bitmap = gsft.applyGlassSphereFilterTransformation  
  
    bm.Initialize(File.DirAssets,"stitch.jpg")  
    cbft.ImageBitmap = bm
    cbft.Shawdows = Array As Float(0.1, 0.2, 0,3)
    cbft.Highlights = Array As Float(0.2, 0.3, 0.4)
    cbft.Midtones = Array As Float(0.3, 0.5, 0.2)
    ImageView1.Bitmap = cbft.applyColorBalanceFilterTransformation
  
    bm.Initialize(File.DirAssets,"stitch.jpg")  
    bft.ImageBitmap = bm
    bft.Brightness = 0.2
    ImageView2.Bitmap = bft.applyBrightnessFilterTransformation
  
    bm.Initialize(File.DirAssets,"stitch.jpg")  
    bbft.ImageBitmap = bm
    bbft.BlurSize = 2.0
    ImageView3.Bitmap = bbft.applyBoxBlurFilterTransformation

    bm.Initialize(File.DirAssets,"stitch.jpg")  
    htft.ImageBitmap = bm
    htft.FractionalWidthOfAPixel = 0.03
    ImageView4.Bitmap = htft.applyHalftoneFilterTransformation
  
    bm.Initialize(File.DirAssets,"stitch.jpg")  
    sobel.ImageBitmap = bm
    sobel.LineSize = 5.0
    ImageView5.Bitmap = sobel.applySobelEdgeDetectionFilterTransformation
  
  
  
'    bm.Initialize(File.DirAssets,"stitch.jpg")  
'    eft.ImageBitmap = bm
'    eft.Exposure = 0.5
'    ImageView2.Bitmap = eft.applyExposureFilterTransformation
  
'    bm.Initialize(File.DirAssets,"stitch.jpg")  
'    srft.ImageBitmap = bm
'    srft.CenterX = 0.5
'    srft.CenterY = 0.5
'    srft.RefractiveIndex = 0.65
'    srft.SphereRadius = 0.5
'    ImageView2.Bitmap = srft.applySphereRefractionFilterTransformation  
  
  
    bm.Initialize(File.DirAssets,"stitch.jpg")  
    chft.ImageBitmap = bm
    chft.CrossHatchSpacing = 0.03
    chft.LineWidth = 0.003
    ImageView6.Bitmap = chft.applyCrosshatchFilterTransformation
  
  
    bm.Initialize(File.DirAssets,"stitch.jpg")  
    cct.ImageBitmap = bm
    ImageView7.Bitmap = cct.applyCropCircleTransformation
  

    bm.Initialize(File.DirAssets,"stitch.jpg")  
    bdft.ImageBitmap = bm
    bdft.CenterX = 0.5
    bdft.CenterY = 0.5
    bdft.DistortionRadius = 0.5
    bdft.DistortionScale = 0.75
    ImageView8.Bitmap = bdft.applyBuldgeDistortionFilterTransformation
  

'    bm.Initialize(File.DirAssets,"stitch.jpg")
'    rc.ImageBitmap = bm
'    rc.CornerRadius = 30
'    rc.CornerType = rc.CornerType_ALL
'    rc.ImageMargin = 5
'    ImageView2.Bitmap = rc.applyRoundedCornersTransformation
  
'    bm.Initialize(File.DirAssets,"stitch.jpg")
'    vft.ImageBitmap = bm
'    vft.CenterX = 0.5
'    vft.CenterY = 0.5
'    vft.VignetteStart = 0.1
'    vft.VignetteEnd = 0.8
'    vft.VignetteColor = Array As Float(0.2, 0.0, 0.2)                      'RGB ---> values range from 0 to 1
'    ImageView3.Bitmap = vft.applyVignetteFilterTransformation

'    bm.Initialize(File.DirAssets,"stitch.jpg")
'    sf.ImageBitmap = bm
'    ImageView4.Bitmap = sf.applySketchFilterTransformation
  
'    bm.Initialize(File.DirAssets,"stitch.jpg")
'    tft.ImageBitmap = bm
'    tft.Threshold = 0.2
'    tft.QuantizationLevels = 10.0
'    ImageView5.Bitmap = tft.applyToonFilterTransformation

'    bm.Initialize(File.DirAssets,"stitch.jpg")
'    pft.ImageBitmap = bm
'    pft.PixelSize = 10
'    ImageView6.Bitmap = pft.applyPixelationFilterTransformation
  
'    bm.Initialize(File.DirAssets,"stitch.jpg")
'    swirl.ImageBitmap = bm
'    swirl.CenterX = 0.5
'    swirl.CenterY = 0.5
'    swirl.SwirlRadius = 0.5
'    swirl.SwirlAngle = 0.5
'    ImageView7.Bitmap = swirl.applySwirlFilterTransformation

'    bm.Initialize(File.DirAssets,"stitch.jpg")
'    emboss.ImageBitmap = bm
'    emboss.Intensity = 4.0
'    ImageView7.Bitmap = emboss.applyEmbossFilterTransformation

                  
'    bm.Initialize(File.DirAssets,"stitch.jpg")
'    mt.ImageBitmap = bm
'    mt.addImageMask("mask_starfish")                         'masks should be in the /Objects/res/drawable folder of the B4A project and set to READ ONLY
'    ImageView8.Bitmap = mt.applyMaskTransformation   
  
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Library:
PicassoTransform
Author:
Github: Daichi Furiya, Wrapped by: Johan Schoeman
Version: 1
  • BoxBlurFilterTransformation
    Methods:
    • Initialize
    • applyBoxBlurFilterTransformation As Object
    Properties:
    • BlurSize As Float [write only]
    • ImageBitmap As Bitmap [write only]
  • BrightnessFilterTransformation
    Methods:
    • Initialize
    • applyBrightnessFilterTransformation As Object
    Properties:
    • Brightness As Float [write only]
    • ImageBitmap As Bitmap [write only]
  • BuldgeDistortionFilterTransformation
    Methods:
    • Initialize
    • applyBuldgeDistortionFilterTransformation As Object
      Performs a buldge distortion effect
    Properties:
    • CenterX As Float [write only]
    • CenterY As Float [write only]
    • DistortionRadius As Float [write only]
    • DistortionScale As Float [write only]
    • ImageBitmap As Bitmap [write only]
  • ColorBalanceFilterTransformation
    Methods:
    • Initialize
    • applyColorBalanceFilterTransformation As Object
    Properties:
    • Highlights() As Float [write only]
    • ImageBitmap As Bitmap [write only]
    • Midtones() As Float [write only]
    • PreserveLuminosity As Boolean [write only]
    • Shawdows() As Float [write only]
  • CropCircleTransformation
    Methods:
    • Initialize
    • applyCropCircleTransformation As Object
    Properties:
    • ImageBitmap As Bitmap [write only]
  • CrosshatchFilterTransformation
    Methods:
    • Initialize
    • applyCrosshatchFilterTransformation As Object
      Performs a cross hatch effect
    Properties:
    • CrossHatchSpacing As Float [write only]
    • ImageBitmap As Bitmap [write only]
    • LineWidth As Float [write only]
  • EmbossFilterTransformation
    Methods:
    • Initialize
    • applyEmbossFilterTransformation As Object
    Properties:
    • ImageBitmap As Bitmap [write only]
    • Intensity As Float [write only]
  • ExposureFilterTransformation
    Methods:
    • Initialize
    • applyExposureFilterTransformation As Object
    Properties:
    • Exposure As Float [write only]
    • ImageBitmap As Bitmap [write only]
  • GlassSphereFilterTransformation
    Methods:
    • Initialize
    • applyGlassSphereFilterTransformation As Object
      Performs a glass sphere effect
    Properties:
    • CenterX As Float [write only]
    • CenterY As Float [write only]
    • ImageBitmap As Bitmap [write only]
    • RefractiveIndex As Float [write only]
    • SphereRadius As Float [write only]
  • HalftoneFilterTransformation
    Methods:
    • Initialize
    • applyHalftoneFilterTransformation As Object
    Properties:
    • FractionalWidthOfAPixel As Float [write only]
    • ImageBitmap As Bitmap [write only]
  • MaskTransformation
    Methods:
    • Initialize
    • addImageMask (mask As String)
    • applyMaskTransformation As Object
      Applies a mask to the image/bitmap
    Properties:
    • ImageBitmap As Bitmap [write only]
  • PixelationFilterTransformation
    Methods:
    • Initialize
    • applyPixelationFilterTransformation As Object
    Properties:
    • ImageBitmap As Bitmap [write only]
    • PixelSize As Float [write only]
  • RoundedCornersTransformation
    Fields:
    • CornerType_ALL As Int
    • CornerType_BOTTOM As Int
    • CornerType_BOTTOM_LEFT As Int
    • CornerType_BOTTOM_RIGHT As Int
    • CornerType_DIAGONAL_FROM_TOP_LEFT As Int
    • CornerType_DIAGONAL_FROM_TOP_RIGHT As Int
    • CornerType_LEFT As Int
    • CornerType_OTHER_BOTTOM_LEFT As Int
    • CornerType_OTHER_BOTTOM_RIGHT As Int
    • CornerType_OTHER_TOP_LEFT As Int
    • CornerType_OTHER_TOP_RIGHT As Int
    • CornerType_RIGHT As Int
    • CornerType_TOP As Int
    • CornerType_TOP_LEFT As Int
    • CornerType_TOP_RIGHT As Int
    Methods:
    • Initialize
    • applyRoundedCornersTransformation As Object
    Properties:
    • CornerRadius As Int [write only]
    • CornerType As Int [write only]
    • ImageBitmap As Bitmap [write only]
    • ImageMargin As Int [write only]
  • SketchFilterTransformation
    Methods:
    • Initialize
    • applySketchFilterTransformation As Object
    Properties:
    • ImageBitmap As Bitmap [write only]
  • SobelEdgeDetectionFilterTransformation
    Methods:
    • Initialize
    • applySobelEdgeDetectionFilterTransformation As Object
    Properties:
    • ImageBitmap As Bitmap [write only]
    • LineSize As Float [write only]
  • SphereRefractionFilterTransformation
    Methods:
    • Initialize
    • applySphereRefractionFilterTransformation As Object
      Performs a sphere refraction effect
    Properties:
    • CenterX As Float [write only]
    • CenterY As Float [write only]
    • ImageBitmap As Bitmap [write only]
    • RefractiveIndex As Float [write only]
    • SphereRadius As Float [write only]
  • SwirlFilterTransformation
    Methods:
    • Initialize
    • applySwirlFilterTransformation As Object
      Apply a swirl filter to the image/bitmap
    Properties:
    • CenterX As Float [write only]
    • CenterY As Float [write only]
    • ImageBitmap As Bitmap [write only]
    • SwirlAngle As Float [write only]
    • SwirlRadius As Float [write only]
  • ToonFilterTransformation
    Methods:
    • Initialize
    • applyToonFilterTransformation As Object
    Properties:
    • ImageBitmap As Bitmap [write only]
    • QuantizationLevels As Float [write only]
    • Threshold As Float [write only]
  • VignetteFilterTransformation
    Methods:
    • Initialize
    • applyVignetteFilterTransformation As Object
      Performs a vignetting effect, fading out the image at the edges
    Properties:
    • CenterX As Float [write only]
    • CenterY As Float [write only]
    • ImageBitmap As Bitmap [write only]
    • VignetteColor() As Float [write only]
    • VignetteEnd As Float [write only]
    • VignetteStart As Float [write only]
 

Attachments

  • PicassoTransformLibFiles.zip
    184.4 KB · Views: 321
  • b4aPicassoTransform.zip
    63.5 KB · Views: 312
  • TheJavaCode.zip
    178.3 KB · Views: 274

Johan Schoeman

Expert
Licensed User
Longtime User
Great! One question, is possible to use effect on picasso downloaded image?
I have an imageview in wich i load bitmap from url using picasso.
I guess it should be possible. See the filter that I have added to the service in the attached B4A sample project by @Erel. Although not using Picasso to download the image it nevertheless applies the filter to the images that was downloaded with HttpUtils2. I have applied a CropCircleTransformation to the images. Mods to the code was done in the service module.

Original project is here https://www.b4x.com/android/forum/threads/imagedownloader-the-simple-way-to-download-images.30875/

1.png
 

Attachments

  • b4aPicassoTransform.zip
    8.3 KB · Views: 283

gma

Member
Licensed User
Longtime User
Hi,

this library is really great, just what I was looking for. Is it possible to apply two or more filters after each other on the same bitmap? How to avoid debug error like "java.lang.IllegalArgumentException: bitmap is recycled"?

Thanks in advance,
Mark
 

Johan Schoeman

Expert
Licensed User
Longtime User
Hi,

this library is really great, just what I was looking for. Is it possible to apply two or more filters after each other on the same bitmap? How to avoid debug error like "java.lang.IllegalArgumentException: bitmap is recycled"?

Thanks in advance,
Mark
You can Mark. Do for eg something like this:

B4X:
    bm.Initialize(File.DirAssets,"stitch.jpg")  
    sobel.ImageBitmap = bm
    sobel.LineSize = 5.0
    ImageView5.Bitmap = sobel.applySobelEdgeDetectionFilterTransformation
  
    Dim newbm As Bitmap
    newbm.Initialize3(ImageView5.Bitmap)
    dft.ImageBitmap = newbm
    dft.DilationRadius = 4                                         'this shlould be an integer from 1 to 4
    ImageView5.Bitmap = dft.applyDilationFilterTransformation

See the below pics - 3rd from the top on the left. Applied two consecutive filters to it:
1. SobelEdgeDetectionFliter to the original image and displayed it in ImageView5
2. Then used the bitmap in ImageView5 and applied a DilationFilterTransformation to it and displayed it back in ImageView5

1.png


2.png
 
Top