Page 1 of 1
Lansa Mobile saving images
Posted: Wed Sep 27, 2017 9:44 am
by atostaine
I'm working on a POC where a user will scan 1 or 2 barcodes, then take a bunch of pictures. I want to show the pictures in a list as each one is taken.
Once the user clicks save, I want to save them to a BLOB or CLOB so that they can be sent from the server to an imaging server.
I've seen Casey's posts
viewtopic.php?f=3&t=1386&p=2861&hilit=image#p2908 about saving the images, but I'm not up to that point yet. I started with the camera example that does images and scanning.
After the user clicks "Use photo", I want to show the thumbnailsl in a list. I created a tree view and a tree item RP. How do I get the base64 to the tree item? Casey explains the base64 could be more than a megabyte, do I have to send multiple strings each with a length of 65535?
It's entirely possible I'm going at this all wrong, so any good ideas are welcome. I think my customer will want to use the camera app, not a file picker so I'm going with LANSA mobile for now.
thanks, Art
Re: Lansa Mobile saving images
Posted: Thu Sep 28, 2017 1:46 am
by caseywhite
Art,
I assume you have dropped an image control on your tree view reusable part. I haven't done what you are trying to do but what you did something like this.
Create an image control that is dynamically created and scope *APPLICATION.
Define_Com Class(#PRIM_ALPH) Name(#LastImage2) Scope(*APPLICATION) Reference(*DYNAMIC)
Then create a reference to it and set you image. You would only SET_REF once.
Set_Ref Com(#LastImage2) To(*CREATE_AS #PRIM_ALPH)
#LastImage2 := "data:image/png;base64," + #CameraUse.ImageAsBase64Data
Now in your treeview RP event that adds the image it would have the same DEFINE_COM as above and could simple read the value in LastImage2 and set to the Filename property of the image in your treeview.
A better option would be a keyed collection of PRIM_ALPH values keyed by some index. That index would be a field in your treeview RP so that you knew which collection item to use when setting the filename. That added benefit is that when you click Save you simply iterate through your collection to get what you need to pass to your server module to save the data.
Re: Lansa Mobile saving images
Posted: Thu Sep 28, 2017 2:01 am
by atostaine
caseywhite wrote: Thu Sep 28, 2017 1:46 am
Art,
I assume you have dropped an image control on your tree view reusable part. I haven't done what you are trying to do but what you did something like this.
Yes, I'll give this a try. Thanks!
Art
Re: Lansa Mobile saving images
Posted: Thu Sep 28, 2017 2:57 am
by atostaine
Still something wrong. Here is my code....
Web page has #tree1 on it.... code was copied from camera example. I am able to show the image in the main web page, it's just not showing in the list.
I can see the list entry is added, but no image. Maybe the data's not coming across.
Code: Select all
Evtroutine Handling(#CameraControl.Completed) Base64data(#base64)
#ImageFromDevice.FileName := #base64
#LastImage := "data:image/png;base64," + #base64
add_entry #tree1
Endroutine
Tree item part... Image1 is displayed in the middle of the component
Code: Select all
Mthroutine Name(OnAdd) Options(*Redefine)
if_ref (#lastImage) is(*null)
Set_Ref Com(#LastImage) To(*CREATE_AS #PRIM_ALPH)
endIf
#image1.filename := #lastImage
Endroutine
Re: Lansa Mobile saving images
Posted: Thu Sep 28, 2017 3:00 am
by caseywhite
You should be doing the SET_REF in the web page and not the tree view RP. Make sure the DEFINE_COM SCOPE(*APPLICATION) is in both the web page and the RP. Then in your tree view RP just set the Filename to #LastImage.
Re: Lansa Mobile saving images
Posted: Thu Sep 28, 2017 3:02 am
by atostaine
I removed this part and it's working. Thanks again
#LastImage := "data:image/png;base64," + #base64
Re: Lansa Mobile saving images
Posted: Thu Sep 28, 2017 3:31 am
by caseywhite
Excellent. Glad to hear.
Re: Lansa Mobile saving images
Posted: Thu Sep 28, 2017 6:28 am
by atostaine
So the way to save to a server module is to break it up into 65K chunks in a list and pass the list? What a pain.
Re: Lansa Mobile saving images
Posted: Thu Sep 28, 2017 6:29 am
by atostaine
So the way to save to a server module is to break it up into 65K chunks in a list and pass the list? What a pain.
Re: Lansa Mobile saving images
Posted: Thu Sep 28, 2017 7:30 am
by Stewart Marshall
Sorry about that Art
Happily, we recognised that this was unnecessarily complicated, so we've added features to allow you to create BLOBs and CLOBs from Base64 data strings. These can be passed on a Field_Map
Code: Select all
#myBlob := #sys_web.CreateBlob( "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA...etc" "image/png" )
This will arrive with SP2 which is coming soon
Regards
Re: Lansa Mobile saving images
Posted: Thu Sep 28, 2017 8:17 am
by atostaine
That's good news. Thanks Stewart.
I saw some other posts by Casey that said the filepicker lets you take a picture. I may just switch to that.
I will still need Lansa Mobile for the barcode scanner though
Re: Lansa Mobile saving images
Posted: Thu Sep 28, 2017 8:25 am
by Stewart Marshall
FilePicker will return the image as a blob
Have a look at xDemoWebImageCapture
Re: Lansa Mobile saving images
Posted: Thu Sep 28, 2017 10:10 am
by soa
Stewart
#myBlob := #sys_web.CreateBlob
Will the reverse function be available ie
#myString := #myBlob.asbase64string.
This would solve a problem I have to address next year.
(I thought I's posted this question already but it seems to have disappeared).
Re: Lansa Mobile saving images
Posted: Thu Sep 28, 2017 2:05 pm
by Stewart Marshall
Hi Jim
Yes, but in a slightly different form.
Code: Select all
Define_Com Class(#Prim_web.BlobReader) Name(#BlobReader)
Mthroutine Name(GetBlobData)
#BlobReader.Read( #MyBlob )
Endroutine
Evtroutine Handling(#BlobReader.Completed) Data(#Data)
* Etc
Endroutine
Regards
Re: Lansa Mobile saving images
Posted: Thu Sep 28, 2017 2:37 pm
by soa
Great
Thanks