Android photo uploading (Slow and demented)

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Android photo uploading (Slow and demented)

Post by William Jamieson » Tue Nov 25, 2014 6:42 pm

Hello

I am trying to get a photo's image data to to be placed into a variable and it does not seem to work.

Here is my script:

I resize the image to about 600x600 then I take a rect of dimensions 600x600 exactly and "export" the image into a variable.
This process takes about 100 milliseconds on my computer but 7-20 seconds on mobile and sometimes freezes.

Code: Select all


on UploadProfilePhoto
   lock screen
   log "UploadProfilePhoto:" && the millisecs
   ##Copies the Resize Image into the variable at the desired size file
   set the JPEGQuality to kJPEGQuality
   
   ##Get the image to resize to a reasonable dimension size
   get ResizeImage()
   if it is "false" then
      exit UploadProfilePhoto
   end if
   log "UploadProfilePhoto:" && the millisecs
   
   ##Get the modified rect
   put getResizeRect() into tResizeImageRect
   
   ##Maintains aspect ratio
   --export snapshot from grp "Snapshot Rect" of me to sPhoto as JPEG
   log "Start Snapshot UploadProfilePhoto:" && the millisecs
   
   export snapshot from rect tResizeImageRect of img "Resize Image" of me to sPhoto as JPEG
   --   export snapshot from rect tResizeImageRect of img "Resize Image" of me at size sPhotoDBThumbnailSize to sThumbnail128 as JPEG
   log "Start Snapshot UploadProfilePhoto:" && the millisecs

   ##MARK can create an activity here acknowleging the upload of the new photo
   
   ##Put the image into the image box on the left
   put sPhoto into img "photo" of me
   set the vis of img "Default" of me to false
   
   
   ResetImageDimensions
   
   unlock screen
end UploadProfilePhoto

The result is that it is taking about 7 to 20 seconds to use the export command. Also, when the screen returns from taking the photo using the phone's architecture, a black area is placed around the card that I cannot control (as noted in the included photos)

Code: Select all

answer "" with "New Picture" and "Gallery"
      ##Lets them choose between taking a pic and using their gallery
      if it is "New Picture" then
         ##iPhones can resize the image automatically
         if the platform is "iphone" then
            mobilePickPhoto "Camera", 600,600
         else
            mobilePickPhoto "camera"
         end if
      else if it is "Gallery" then
         if the platform is "iphone" then
            mobilePickPhoto "Album", 600,600
         else
            mobilePickPhoto "library"
         end if
      else
         exit ChooseProfilePhoto
      end if
      lock screen
      export the last image to binFile as JPEG
      put binFile into img "Resize Image" of me
      put binFile into img "Photo" of me
      ##Clear images made by the mobile device
      if the short name of the last image is not "Profile Image" and \
            the short name of the last image is not "Background Image" and \
            the short name of the last image is not "Resize Image" then
         delete the last image
      end if
      unlock screen
      
      PositionPhoto
Does anyone have any experience using the export command on mobile?

Does anyone have any experience taking photos and saving them?

I am using LC 6.6.2, 6.7.1, 7.0, 7.0.1 RC 2 with samsung galaxy phone and tablet and Android Kitkat (4.2)

-Will
Attachments
Screenshot_2014-11-24-16-45-53.png
Screenshot when returning to the card after taking a photo using the native camera app
Screenshot_2014-11-25-09-18-05.png
Screenshot when returning to the card after taking a photo using the native camera app

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: Android photo uploading (Slow and demented)

Post by William Jamieson » Tue Nov 25, 2014 10:09 pm

Ok 1 problem solved. I got the weird black objects to go away by making the processing right after the MobilePickPhoto lighter

In the choose Photo handler I made the processing lighter

Code: Select all

answer "" with "New Picture" and "Gallery"
      ##Lets them choose between taking a pic and using their gallery
      if it is "New Picture" then
         ##iPhones can resize the image automatically
         if the platform is "iphone" then
            mobilePickPhoto "Camera", 600,600
         else
            mobilePickPhoto "camera"
         end if
      else if it is "Gallery" then
         if the platform is "iphone" then
            mobilePickPhoto "Album", 600,600
         else
            mobilePickPhoto "library"
         end if
      else
         exit ChooseProfilePhoto
      end if
      lock screen
      put the id of the last image of me into tImgID
      set the layer of image id tImgID of me to bottom
      unlock screen
      wait 20 milliseconds with messages
      put img id tImgID of me into img "Resize Image" of me
      put img id tImgID of me into img "Photo" of me
      
      ##Clear images made by the mobile device
      delete img id tImgID of me
      --      if the short name of the last image is not "Profile Image" and \
            --            the short name of the last image is not "Background Image" and \
            --            the short name of the last image is not "Resize Image" and \
            --            the short name of the last image is not "Default" then
      --         delete the last image
      --      end if
      
      PositionPhoto
Which seemed to work well and fast. Now it is just the export command, and it only acts up when using large photos (3+ MB)

Post Reply