B4A Library [B4X] [XUI] AS Draw (FabricView and CanvasView)

yzhy-mail

Member
@Alexander Stolte
I find your lib is very useful for drawing something.
When I use it .I found the formt of the exportdrawing is PNG. PNG is ok.
When i changed the format to jpeg,I just got a all black image.
I want to konw if I can get picture of JPEG format.
Thank you !
 
Last edited:

Alexander Stolte

Expert
Licensed User
Longtime User
The view only returns the bitmap, how you save it is up to you.
According to the forum search, this is a deliberate behavior, because the background is transparent and in jpg it is just black.
 

yzhy-mail

Member
Thank you !
I don't know the principle .
But I like the ASdraw lib ,so I changed to use PNG. Thougth it's bigger than JPEG.
 

rnlev

New Member
Hello. When I run the example I only see a button that does nothing when clicked. What do I need to run it? I already copied the lib fiile to the libs folder. Any other thing that I should do? Thanks.
 

Alexander Stolte

Expert
Licensed User
Longtime User
Hello. When I run the example I only see a button that does nothing when clicked. What do I need to run it? I already copied the lib fiile to the libs folder. Any other thing that I should do? Thanks.
This is because the focus was on B4A and B4I. B4J should work, I just didn't have the motivation to do an example project for B4J.
 

rnlev

New Member
Ok, thanks.
(I thought it was supposed to run on all platforms -_-
I just can't figure out this B4x thing)
 

jvetterli

Member
Licensed User
Longtime User
@Alexander Stolte

Hi Alex, thanks a lot for this great library! I'm trying to use the export and import drawing feature, but with no success:

I have a global tmpList As List which gets filled by tmpList = ASDraw1.ExportDrawing when saving the current drawing.
After ASDraw1.clear, I use ASDraw1.ImportDrawing(tmpList,False), but nothing happens, what am I doing wrong?

Additionally, I'm wondering if there would be a possibility to use the MotionEvent data as well, since I'd like to optimize the usage for devices which are having a stylus by filtering for TOOL_TYPE_STYLUS?
 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 1.09
    • BugFix - ExportDrawing
    • Intern Function iif2 replaced with the core iif function
A full B4X sample project has been added to the first post.

Thanks for reporting, it should work now.

I'm wondering if there would be a possibility to use the MotionEvent data as well
This view have a "Touch" event is that what you mean?
 

jvetterli

Member
Licensed User
Longtime User
Thanks for the quick fix, works like a charm now!

I'm looking for a method to additionally catch the MotionEvent data on touch, like it's available with the Gesture Detector library. But never mind, since it's not part of your nice solution.
 

Alexander Stolte

Expert
Licensed User
Longtime User
catch the MotionEvent data on touch, like it's available with the Gesture Detector library.
??
B4X:
Sub ASDraw1_Touch (Action As Int, XY As Map)
    'Log("Action: " & Action)
    'Log("X: " & XY.Get("X"))
    'Log("Y: " & XY.Get("Y"))
End Sub
 

irda

Member
Licensed User
Longtime User
Hi, great work.

As it is based on CanvasView and Fabricview, is it possible to extend the library to add shapes (circles, squares...), text and images (not only as background)?

Thanks and best regards.
 

jvetterli

Member
Licensed User
Longtime User
Good morning,

Unfortunately I've found another bug, trying to save the complete image throws an error sometimes:
asdraw_getimagecomplete (java line: 341)
java.lang.RuntimeException: Object should first be initialized (B4XBitmap)

Unfortunately I can't properly reproduce when this is happening, very strange. Anybody else happened the same thing?
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…