Exporting a snapshot more larger than the card containing it

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Exporting a snapshot more larger than the card containing it

Post by Mag » Fri Jan 25, 2013 4:16 pm

Hi all,

I'm trying to save an image containing some controls (in an hiden card) to share it via social networks. With iPhone 4 all goes OK but with iPhone the image is cropped at the size of the screen.

Code: Select all

export snapshot from rect snapRect of cd "sharePreview" to url ("binfile:"&tFolder&"/fotoPerShare.jpg") as JPEG
Somebody knows if there is a way to accomplish this?

:oops:

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Exporting a snapshot more larger than the card containin

Post by Mark » Fri Jan 25, 2013 5:24 pm

Hi,

Make a group of the objects you want to export as a picture and export a snapshot of the group. The group has to large enough to show all controls if the card were that big.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Exporting a snapshot more larger than the card containin

Post by Mag » Fri Jan 25, 2013 7:02 pm

Thank you so much Mark!

PS
It seems that the URL of your signature doesn't work

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Exporting a snapshot more larger than the card containin

Post by Mark » Fri Jan 25, 2013 7:29 pm

Hi,

The Qery URL is broken. I'll fix that shortly.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7240
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Exporting a snapshot more larger than the card containin

Post by jacque » Fri Jan 25, 2013 7:49 pm

Or if you don't want to group everything, you can do it directly this way:

export snapshot from this cd to file "cardsnap.jpg" as jpeg

The "from" syntax will include everything regardless whether it is visible on screen or not and regardless of the size.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Exporting a snapshot more larger than the card containin

Post by Mag » Fri Jan 25, 2013 9:34 pm

Thank you Jacque!

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Exporting a snapshot more larger than the card containin

Post by Mag » Sat Jan 26, 2013 2:24 am

Done some testing, well, if I export from card I get some unwaited blank space. If I export from group I get a weird black 4 pixel frame. BTW I think that I need to test a bit more to setup things in the good way...

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Exporting a snapshot more larger than the card containin

Post by Mag » Sat Jan 26, 2013 1:23 pm

Unfortunately I continue to get mixed results, this could be probably due by the fact that I dinamically resize the content of the card before to take the screen shot.

Code: Select all

on preparePostcard
   lock screen
   go to cd "sharePreview" -- it needs it to refresh photo dimensions, frame dimensions etc, altough thet don't change
   put specialFolderPath("documents") into tFolderPath
   put tFolderPath & "/customPreviewPhoto.JPG" into tFilePath
   set the filename of image "imageBox" of cd "sharePreview" to "" -- to be sure to reset the image, maybe doesn't need it
   set the filename of image "imageBox" of cd "sharePreview" to tFilePath
   
   -- set the frame
   set the height of graphic "postcardFrame" of cd "sharePreview" to (the height of image "imageBox" of cd "sharePreview"  + 40)
   set the width of graphic "postcardFrame" of cd "sharePreview" to (the width of image "imageBox" of cd "sharePreview"  + 40)
   set the loc of graphic "postcardFrame" of cd "sharePreview" to the loc of image "imageBox" of cd "sharePreview"
   
   -- set the logo
   set the loc of image "logo" of cd "sharePreview" to (the loc of image "imageBox" of cd "sharePreview") -- center it
   set the top of image "logo" of cd "sharePreview" to (the top of graphic "postcardFrame" of cd "sharePreview" - 22) -- move to top
   
   set the loc of button "mark" of cd "sharePreview" to (the loc of image "imageBox" of cd "sharePreview") -- center it
   set the bottom of button "mark" of cd "sharePreview" to (the bottom of graphic "postcardFrame" of cd "sharePreview" + 40)  -- move to bottom
   
   -- set the screenShot rect
   set the loc of graphic "snapshotRect" of cd "sharePreview" to (the loc of image "imageBox" of cd "sharePreview")
   set the height of graphic "snapshotRect" of cd "sharePreview" to (the height of image "imageBox" of cd "sharePreview" + 130)
   set the width of graphic "snapshotRect" of cd "sharePreview" to (the width of image "imageBox" of cd "sharePreview" + 130)
   
   set the bottom of graphic "snapshotRect" of cd "sharePreview" to (the bottom of graphic "snapshotRect" of cd "sharePreview" + 16) -- move to bottom by 20 pixels
   go to cd "mainContent" -- back to main cd
   unlock screen
end preparePostcard

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7240
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Exporting a snapshot more larger than the card containin

Post by jacque » Sat Jan 26, 2013 8:44 pm

It looks like you want to get a snapshot of only a particular area of the card (snapshotRect), not the entire card. If so, the grouping the objects and exporting a snapshot from the group is the right approach. If the snapshot has border lines then one of the objects might have its showBorder set to true.

Try grouping everything, exporting a snapshot, and then uploading that image here so we can see what you get.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Exporting a snapshot more larger than the card containin

Post by Mag » Sat Jan 26, 2013 9:58 pm

Thank you jacque, I do some testing following your advice and I discover that the the black border were due by the black background of the stack ( I use the black bg because it's the best option for the flip effect) I then set card by card the white bg. I solved the problem making opaque and white the rect I use as "container" for the snapshot (snapshotRect). Now all works fine!

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Exporting a snapshot more larger than the card containin

Post by Mag » Sat Jul 19, 2014 4:51 pm

Hi all!

So, I'm here with a new question about this powerful command.

This is what I learnt about export snapshot command to date:


export snapshot from rect
crops everything is not currently displayed on the card

export snapshot from group
exports everything is content in the group so you can't choose e rectangle from which to export
(BTW when you use it remember to set the margins to the group to 0 to avoid to include card bg parts)

crop command
can't use it before to export a snapshot if you have an image that displays a file referenced

set the imagedata
set the imagedata of an image to the imagedata of the same image don't work for referencing images so can't use to then use the command crop


At this point I can't imagine a way to export a part of an image that is not completely displayed in a card.

Any help will be appreciated! :oops:

Klaus
Posts: 13831
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Exporting a snapshot more larger than the card containin

Post by Klaus » Sat Jul 19, 2014 5:54 pm

Hi Mag,
Mag wrote:At this point I can't imagine a way to export a part of an image that is not completely displayed in a card.
WHAT part of an image do you want to "snapshot"?

Just created a little stack with an image that covers more than the card and put this into button script
to export a part of the image that is not visible on the card:

Code: Select all

on mouseUp
   put specialfolderpath("desktop") & "/snap.jpg" into tFile
   export snapshot from rect(20,20,560,360) of img 1 to file tFile as JPEG
end mouseUp
Worked as exspected! 8)


Best

Klaus

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Exporting a snapshot more larger than the card containin

Post by Mag » Sat Jul 19, 2014 9:09 pm

Hi Klus, unfortunately it seems to me that it crops the non visible part of the image... :roll:

I'm doing something wrong... let me double check...

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Exporting a snapshot more larger than the card containin

Post by Mag » Sat Jul 19, 2014 10:08 pm

I again,

so I had forget to refer to the image object:

export snapshot from rect(20,20,560,360) of img 1 of card xy to file tFile as JPEG

all work fine now, thank you for the help! :mrgreen:

Post Reply

Return to “Multimedia”