Lansa Mobile saving images

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Lansa Mobile saving images

Post 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
Art Tostaine
caseywhite
Posts: 192
Joined: Thu May 26, 2016 1:17 am

Re: Lansa Mobile saving images

Post 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.
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Lansa Mobile saving images

Post 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
Art Tostaine
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Lansa Mobile saving images

Post 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
Art Tostaine
caseywhite
Posts: 192
Joined: Thu May 26, 2016 1:17 am

Re: Lansa Mobile saving images

Post 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.
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Lansa Mobile saving images

Post by atostaine »

I removed this part and it's working. Thanks again

#LastImage := "data:image/png;base64," + #base64
Art Tostaine
caseywhite
Posts: 192
Joined: Thu May 26, 2016 1:17 am

Re: Lansa Mobile saving images

Post by caseywhite »

Excellent. Glad to hear.
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Lansa Mobile saving images

Post 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.
Art Tostaine
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Lansa Mobile saving images

Post 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.
Art Tostaine
User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Lansa Mobile saving images

Post 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
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Lansa Mobile saving images

Post 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
Art Tostaine
User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Lansa Mobile saving images

Post by Stewart Marshall »

FilePicker will return the image as a blob

Have a look at xDemoWebImageCapture
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: Lansa Mobile saving images

Post 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).
User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Lansa Mobile saving images

Post 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
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: Lansa Mobile saving images

Post by soa »

Great
Thanks
Post Reply