B4A Library Zoomage - A simple pinch-to-zoom Library

Discussion in 'Additional libraries, classes and official updates' started by DonManfred, Oct 21, 2018.

Similar threads

B4A Library ChatMessageView
B4A Tutorial [java] Custom View with Designer Support (Java library)
B4A Library PanoramaImageView
B4A Library SnakeView
B4A Library msEmoji V1.0.0
  1. DonManfred

    DonManfred Expert Licensed User

    This is a shortwrap for this Github-Project.

    Notes:
    - The Apps needs to be AppCompat compatible as the Zoomage extends an AppCompat Imageview
    - The Image should be place in a path readable by the app. It seems not to work with Assets. I did not tried it much; if i copy it first to a save path it works for me.

    zoomage

    Author:
    Version: 0.1
    • ZoomageView
      • Fields:
        • ba As BA
      • Functions:
        • BringToFront
        • DesignerCreateView (base As Panel, lw As Label, props As Map)
        • Initialize (EventName As String)
        • Invalidate
        • Invalidate2 (arg0 As android.graphics.Rect)
        • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
        • IsInitialized As Boolean
        • RemoveView
        • RequestFocus As Boolean
        • reset
          Reset image back to its original size. Will snap back to original size
          if animation on reset is disabled via {@link #setAnimateOnReset(boolean)}.
        • reset2 (animate As Boolean)
          Reset image back to its starting size. If {@code animate} is false, image
          will snap back to its original size.
          animate: animate the image back to its starting size
        • SendToBack
        • SetBackgroundImage (arg0 As android.graphics.Bitmap) As BitmapDrawable
        • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
        • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
        • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
        • setScaleRange (minScale As Float, maxScale As Float)
          Set the minimum and maximum allowed scale for zooming. {@code minScale} cannot
          be greater than {@code maxScale} and neither can be 0 or less. This will result
          in an {@link IllegalStateException}.
          minScale: minimum allowed scale
          maxScale: maximum allowed scale
        • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
      • Properties:
        • AnimateOnReset As Boolean
          Returns status of animateOnReset. This causes the image to smoothly animate back
          to its start position when reset. Default value is true.
        • AutoCenter As Boolean
          Whether or not the image should automatically center itself when it's dragged partially or
          fully out of view.
        • AutoResetMode As Int
          Get the current {@link AutoResetMode} mode of the image. Default value is {@link AutoResetMode#UNDER}.
        • Background As android.graphics.drawable.Drawable
        • Color As Int [write only]
        • CurrentScaleFactor As Float [read only]
          Get the current scale factor of the image, in relation to its starting size.
        • DoubleTapToZoom As Boolean
          Gets double tap to zoom state.
        • DoubleTapToZoomScaleFactor As Float
          Gets the double tap to zoom scale factor.
        • Enabled As Boolean
        • Height As Int
        • ImageBitmap As android.graphics.Bitmap [write only]
        • ImageDrawable As android.graphics.drawable.Drawable [write only]
        • ImageURI As String [write only]
          {@inheritDoc}
        • Left As Int
        • Padding As Int()
        • Parent As Object [read only]
        • RestrictBounds As Boolean
          If restricted bounds are enabled, the image will not be allowed to translate
          farther inward than the edges of the view's bounds, unless the corresponding
          dimension (width or height) is smaller than those of the view's frame.
        • Tag As Object
        • Top As Int
        • Translatable As Boolean
          Returns whether the image is translatable.
        • Visible As Boolean
        • Width As Int
        • Zoomable As Boolean
          Returns the zoomable state of the image.

    An Example can be downloaded HERE due to it´s size.
     

    Attached Files:

    Don Oso, Mahares, f0raster0 and 13 others like this.
  2. Peter Simpson

    Peter Simpson Expert Licensed User

    He's back, nice one Manfred ;)
     
    Last edited: Dec 5, 2018
  3. MarcoRome

    MarcoRome Expert Licensed User

  4. Almora

    Almora Active Member Licensed User

    does it support online image?
     
  5. Almora

    Almora Active Member Licensed User

    image can download and zoom.
     
  6. Johan Hormaza

    Johan Hormaza Active Member Licensed User

    Great job!!
     
  7. Almora

    Almora Active Member Licensed User

  8. DonManfred

    DonManfred Expert Licensed User

    You should ALWAYS(!!!) start a NEW Thread for any Issue you have.

    Note that the issue is not related to this lib.
     
    Almora likes this.
  9. peacemaker

    peacemaker Well-Known Member Licensed User

    Is this lib only for B4A ?
     
  10. DonManfred

    DonManfred Expert Licensed User

    As it is extending AppCompat Imageview (which is a Google Object from the Supportlibrary) i expect it to work on B4A only. There is no AppCompat for B4J as far as i know.
     
    peacemaker likes this.
  11. Mahares

    Mahares Well Known Member Licensed User

    You did a really good job with this lib. You documented everything well. I was able to use the Assets folder as shown in my below code without having to save the file from assets to defaultExternal. It works well. I can zoom in and out. If, what I did does not make sense, please correct accordingly:
    Code:
    Sub Activity_Create(FirstTime As Boolean)
        
    Activity.LoadLayout("Layout1")  
        
    Dim bd As BitmapDrawable
        bd.Initialize(
    LoadBitmap(File.DirAssets, "empire.jpg"))
        bd.Gravity = 
    Gravity.FILL
        ZoomageView1.ImageDrawable=bd
        ZoomageView1.setScaleRange(
    1,4)
    End Sub
     
  12. Mahares

    Mahares Well Known Member Licensed User

    Here is another way of achieving the same result as above without having to save the bitmap file to DefaultExternal, even shorter than the one in post #11:
    Code:
    Sub Activity_Create(FirstTime As Boolean)
        
    Activity.LoadLayout("Layout1")   
        ZoomageView1.ImageBitmap=
    LoadBitmap(File.DirAssets, "empire.jpg")   
        ZoomageView1.setScaleRange(
    1,4)
    End Sub
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice