Resizing images - slow performance on device

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Resizing images - slow performance on device

Post by jacque » Thu Jan 07, 2016 1:12 am

I'm enclosing the stack here. It's so old I'm surprised I still have it. Note it will error if you try to run it in the IDE, you'll have to build a mobile app. Also, it hasn't been tested in any recent version of LC, it was built in version 5.x, so take your chances.
Attachments
photoTest.livecode.zip
(3.45 KiB) Downloaded 293 times
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

abhinav7979
Posts: 5
Joined: Mon Jan 04, 2016 1:10 pm

Re: Resizing images - slow performance on device

Post by abhinav7979 » Tue Jan 12, 2016 4:51 pm

jacque wrote:I'm enclosing the stack here. It's so old I'm surprised I still have it. Note it will error if you try to run it in the IDE, you'll have to build a mobile app. Also, it hasn't been tested in any recent version of LC, it was built in version 5.x, so take your chances.

Thank you so much jacque. That helped me solve the issue. It was working fine on 7.1.
But I'm still trying to fix the storage issue. I want to store this image into mySQL db as a MEDIUMBLOB that I hosted remotely on my server. So, the problem is my phone captures images of sizes above 600kb at least. So, is there any way that I could bring the size down. And any alternative way of storing it in to db(it is necessary that I have it on db). This app should be able to upload it from a 3G internet which is pretty slow for a 1.x mb picture as a blob data.

Please suggest something.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Resizing images - slow performance on device

Post by jacque » Tue Jan 12, 2016 8:06 pm

When LiveCode resizes an image, it does not change the actual binary content, it only changes the screen display. No matter what size it is on the card, the file content you send to the DB will always be the same number of bytes as the original-sized image. To reduce the image's actual file size you need to replace the original binary content with the resized display content. You can do it like this:

Code: Select all

set the imageData of img x to the imageData of img x -- "x" being any valid reference to the image
Once you do that, the byte count will be reduced but the original quality and size of the image can't be recovered. It's a permanent change. The image will be smaller and suffer some loss of quality. If you will always display it only in your app at the same reduced size, it will be fine. If the goal is to store a high quality image for use somewhere else, the original has been lost and you'll never see anything better than the resized screen display.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply