Make a round photo icon for OSX and Mobile

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
trevix
Posts: 958
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Make a round photo icon for OSX and Mobile

Post by trevix » Wed Jul 28, 2021 9:03 pm

I am trying, as login process of my standalone, to let the user shot or load his photo, making a round PNG image out of it.
A PNG because, at the end of the job, I would like to have a alpha transparent background that show only the circle with the photo on it.

I've got some code and ispiration here:
http://forums.livecode.com/viewtopic.ph ... 80#p135480
viewtopic.php?f=7&t=31825&start=15

As of now, on OSX only, I can load an image, resize it, move it.
My problem is taking a snapshot of the result: somehow the snapshot doesn't work. Not to talk having an image with alpha channel (wich I don't really understand).
ImageResizePhoto.livecode.zip
(29.65 KiB) Downloaded 110 times
Any suggestion or stack improvement is welcomed.
Trevix
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

andresdt
Posts: 146
Joined: Fri Aug 16, 2019 7:51 pm

Re: Make a round photo icon for OSX and Mobile

Post by andresdt » Wed Jul 28, 2021 11:22 pm

Hi trevix
Today I created a thread wondering why the roundRadius property is not present in groups. Now I see that it would also be nice if the images had it.
The problem you are facing I have already faced and here is the solution I found.
The code is on the stack that I attach.
look at the exportSnapshotPNG command
Attachments
CropAvatar.zip
(50.64 KiB) Downloaded 113 times

ClipArtGuy
Posts: 253
Joined: Wed Aug 19, 2015 4:29 pm

Re: Make a round photo icon for OSX and Mobile

Post by ClipArtGuy » Thu Jul 29, 2021 12:18 am

trevix wrote:
Wed Jul 28, 2021 9:03 pm

Any suggestion or stack improvement is welcomed.
Trevix

This script works in your saveImage button.

Code: Select all

on mouseUp pMouseButton
  export snapshot from rect(the rect of graphic "PhotoCircle") of this card to tFileVar as PNG
   put tFileVar into image "FinalImage" of card "cardShow"
   go card "cardshow"
end mouseup

trevix
Posts: 958
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Make a round photo icon for OSX and Mobile

Post by trevix » Fri Jul 30, 2021 10:12 am

Great answers: thanks
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”