B4A Library DrawingView

A wrapper for this project https://github.com/mukeshsolanki/DrawingView-Android

DrawingView is a simple view that lets you draw on screen using your fingers and lets you save the drawings as images.




ScreenShoot.gif


sample:
B4X:
Dim demo As DrawingView
B4X:
        demo.Initialize("")
    Activity.AddView(demo,0,0,100%x,80%y)
 
    demo.DrawBackgroundColor=Colors.White

NOTE:
B4X:
DependsOn(values={"android-support-v4"})

When saving image use format fields like COMPRESS_PNG .

Version 2 adds loadimage(bitmap as bitmap) method so you can load your previous drawing as asked by @Almora

DrawingView
Author:
SMM
Version: 0.01
  • DrawingView
    Fields:
    • COMPRESS_JPEG As CompressFormat
    • COMPRESS_PNG As CompressFormat
    • ba As BA
    Methods:
    • BringToFront
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • 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)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • initializeEraser
    • initializePen
    • saveImage (filePath As String, filename As String, format As CompressFormat, quality As Int)
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • DrawBackgroundColor As Int [write only]
    • Enabled As Boolean
    • EraserSize As Float [write only]
    • Height As Int
    • Left As Int
    • Parent As Object [read only]
    • PenColor As Int [write only]
    • PenSize As Float [write only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int
 

Attachments

  • DrawingView.zip
    7.3 KB · Views: 418
  • DrawingView2.zip
    7.5 KB · Views: 402
Last edited:

Edgardo PuntoCom

Member
Licensed User
Longtime User
I don't think so .
Can you test on your current version and feedback ? :)

When making a new application works well in B4A 5.8.

When attempting to integrate into an application that I have made, compiling never ends. A shame.

Maybe in the future I find how to make it work.

Either way this library is great. Thanks for sharing.
 

Edgardo PuntoCom

Member
Licensed User
Longtime User
How to use saveImage?

B4X:
Dim dv1 As DrawingView
panelMiArte.AddView(dv1,0,50dip,100%x -10dip,100%x -10dip)
dv1.DrawBackgroundColor=Colors.Transparent

dv1.saveImage(File.DirRootExternal, "pictures/temporalSuperMEME002", dv1.COMPRESS_JPEG, 100)
???
 
Last edited:

somed3v3loper

Well-Known Member
Licensed User
Longtime User
How to use saveImage?

B4X:
Dim dv1 As DrawingView
panelMiArte.AddView(dv1,0,50dip,100%x -10dip,100%x -10dip)
dv1.DrawBackgroundColor=Colors.Transparent

dv1.saveImage(File.DirRootExternal, "pictures/temporalSuperMEME002", dv1.COMPRESS_JPEG, 100)
???
So sorry for late reply
B4X:
dv1.saveImage(File.DirRootExternal,"pictures/temporalSuperMEME002", dv1.COMPRESS_PNG, 100)
this should work
 

Almora

Well-Known Member
Licensed User
Longtime User
Hi...
How do I get to the last screen that I draw after the application is opened?
 

Almora

Well-Known Member
Licensed User
Longtime User
I use translation. Do not look in the sack.

I opened the application and made the drawing.

I closed the application.

How can I see the last drawing I draw on the screen when I turn it on again.
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
I use translation. Do not look in the sack.

I opened the application and made the drawing.

I closed the application.

How can I see the last drawing I draw on the screen when I turn it on again.
I uploaded a new version to the first post that adds loadimage method . You can try it now .
 

Almora

Well-Known Member
Licensed User
Longtime User
Hello again .. pencil does not call old drawing call. how can I do it?

because it is an image file cannot be reused.
 

Attachments

  • DrawingView.zip
    7.9 KB · Views: 323
Last edited:
Top