Difference in browsersnapshot mac ctr Win !?!?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
kresten
Posts: 153
Joined: Tue Sep 30, 2008 3:01 pm
Contact:

Difference in browsersnapshot mac ctr Win !?!?

Post by kresten » Tue Dec 04, 2012 4:24 pm

I have included an option to snapshot the visible in live code browser, inspired by Mark Frazier (substack of "Phenomenalog") which works in the windows version, but using the same handler in the mac version gives en empty image ( a vague small spots & lines crossing pict)-
The same effect comes from snapshot-function of another sub-stack (only in mac, not in windows), so it seems not specific for the browser.
But for another substack snapshotting works perfect for 9 different card windows !
Did anybody meet this type of situation and /or have some advice.
Best regards
Kresten Bjerg

www.phenomenalog.dk

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Difference in browsersnapshot mac ctr Win !?!?

Post by bn » Tue Dec 04, 2012 5:17 pm

Hi Kristen,

this is a known bug of revBrowserSnapshot. It has been fixed now and will appear in the next release of Livecode. (Bug 4967 and Bug 10509)

A work around is to take the snapshot from the global coordinates of the browser location. You know the rect of the revBrowser and if you convert the coordinates from local to global using globalLoc -> dictionary you can do
e.g. export snapshot from rect "0,0,200,200" to file "Nav.jpg" as JPEG

Kind regards
Bernd

kresten
Posts: 153
Joined: Tue Sep 30, 2008 3:01 pm
Contact:

Re: Difference in browsersnapshot mac ctr Win !?!?

Post by kresten » Wed Dec 05, 2012 12:26 am

Dear Bernd
Thank you for that info
I am not sure how to code that local to global thing. Is it so simple, that you could edit it into the present handler ?

on mouseUp
global sBrowserId, phenodate
put globalLoc (the topleft of grc "browser Rect" ) into tTopLeft
put globalLoc (the bottomright of grc "browser Rect" ) into tBotRight
put tTopLeft & "," & tBotRight into tRectSnap
wait 10 milliseconds with messages
put the effective filename of this stack into screensnap
set the itemdelimiter to "/"
delete last item of screensnap
delete last item of screensnap
delete last item of screensnap
delete last item of screensnap
put "/Screenshots" after screensnap
put the time into tidspunkt
put"_" into char 3 of tidspunkt
put screensnap & "/" & phenodate & "_" & tidspunkt into navn
export snapshot from rect tRectSnap to file navn & ".jpg" as jpg
beep 4
end mouseUp

That would be very very nice.

But , as I wrote, same failure comes when snapshotting one other substack, and only in mac, while snapping 3 other substacks work equally well in windows and in mac.
Have others met those not browser-related problems ?

Hopefully
Kresten

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Difference in browsersnapshot mac ctr Win !?!?

Post by bn » Wed Dec 05, 2012 12:48 am

Hi Kresten,

your code works for me except for the export snapshot line

Instead of using

Code: Select all

export snapshot from rect tRectSnap to file navn & ".jpg" as jpg
you should use

Code: Select all

export snapshot from rect tRectSnap to file navn & ".jpg" as JPEG
note the difference is actually only JPEG instead of your original "jpg"

I just put it on the desktop but otherwise I used the code you posted and it takes a snapshot from the browser.

Kind regards
Bernd

kresten
Posts: 153
Joined: Tue Sep 30, 2008 3:01 pm
Contact:

Re: Difference in browsersnapshot mac ctr Win !?!?

Post by kresten » Wed Dec 05, 2012 11:26 am

Dear Bernd
Thanks, but the error is not so simply repaired on my mac. I wonder, why it is on yours, as you refer to the acknowledged bug. I would like to try the local-to-global method, if you could upgrade my handler to that effect.
best regards
Kresten

Klaus
Posts: 14213
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Difference in browsersnapshot mac ctr Win !?!?

Post by Klaus » Wed Dec 05, 2012 11:39 am

Hi guys,

you should use BRACKETS when creating (file) names!
...
export snapshot from rect tRectSnap to file (navn & ".jpg") as JPEG
...


Best

Klaus

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Difference in browsersnapshot mac ctr Win !?!?

Post by bn » Wed Dec 05, 2012 11:56 am

Hi Klaus,
I tried without and it worked but I agree one should use BRACKETS.

Hi Kresten,

here is the exact script I used. Note instead of a graphic I use an image for the rect of the browser, should not make any difference.

After creating a folder "Screenshots" in documents folder it worked fine. I have no idea what is causing you trouble. It would help if you posted the error messages you get and at what line of your code you get them.

Code: Select all

on mouseUp
   put globalLoc (the topleft of img "browserImage" ) into tTopLeft
   put globalLoc (the bottomright of img "browserImage" ) into tBotRight
   put tTopLeft & "," & tBotRight into tRectSnap
   wait 10 milliseconds with messages
   put the effective filename of this stack into screensnap
   set the itemdelimiter to "/"
   delete last item of screensnap
   delete last item of screensnap
   delete last item of screensnap
   delete last item of screensnap
   put "/Screenshots" after screensnap
   put the time into tidspunkt
   put"_" into char 3 of tidspunkt
   put screensnap & "/" & phenodate & "_" & tidspunkt into navn
   export snapshot from rect tRectSnap to file (navn & ".jpg") as JPEG
   beep 4
end mouseUp
this is the filename I get:
phenodate_11_46 AM.jpg
obviously it is "phenodate" since I omitted the global phenodate since I don't know what it is supposed to contain. I did not the use sBrowserID since this works without reference to the browser ID


Kind regards
Bernd

kresten
Posts: 153
Joined: Tue Sep 30, 2008 3:01 pm
Contact:

Re: Difference in browsersnapshot mac ctr Win !?!?

Post by kresten » Wed Dec 05, 2012 1:16 pm

Thanks for advices.
Brackets did not help.
And the "browserimage" reference does not work, -is not found, stalls the script.
The problem with my handler is, that it does not "fail", but runs smoothly and produce a jpg. But the jpg is, as described" a scatter of traces, some bits coloured, reflecting I think, colours of the source-image.

As I started to complain: that type of output also came from snapping one other substack, - but I just found a way to repair it there, by adding a "of window (the windowid of this stack)" !!!

But I tested such addition to the browser-snapshotting but it couldnt make sense there

The pictures I get are app 580 KB, perhaps too large to attach here, but I guess other people may have ended up with such mis-snaps, - if such have a name, it would help knowing it, for searching the forum
best regards
Kresten

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Difference in browsersnapshot mac ctr Win !?!?

Post by bn » Wed Dec 05, 2012 4:23 pm

Hi Kresten,

I made a simple stack that shows a browser on opencard.

One button to make the snapshot from global coordinates.
It will save the resulting image to the desktop.
And it will open the document in Preview on a Mac.

Please try this stack and see if it works for you. If it does then use the code in the button to adjust your code.
globalSnapBrowserKresten.livecode.zip
(1.49 KiB) Downloaded 306 times
Kind regards
Bernd

kresten
Posts: 153
Joined: Tue Sep 30, 2008 3:01 pm
Contact:

Re: Difference in browsersnapshot mac ctr Win !?!?

Post by kresten » Thu Dec 06, 2012 12:41 am

Hi Bernd
Thank you for taking the trouble.
But your browser produces only empty images here, both on Win and on Mac ! (mine actually works on win)

I am only running livecode 4.5.1 could that be an explanation ?

best regards
Kresten

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Difference in browsersnapshot mac ctr Win !?!?

Post by bn » Thu Dec 06, 2012 1:04 am

Hi Kresten,

I now tested above stack (globalSnapBrowserKresten.livecode.zip) with Revolution 4.0, LiveCode 4.5.3, LiveCode 5.5.3 on a Mac and it works in all versions as intended.
I starts up and makes a revBrowser that is set to google.com. The script is in the card script. If I then click on the button "generate snapshot" a file is created on the desktop, named like:
phenodate_00_51.jpg

This file is automatically opened by the application "Preview" and shows the correct snapshot.

I suggest you close LiveCode completely and reopen it.

Then the ONLY stack you run is the one mentioned above. (globalSnapBrowserKresten.livecode)

If it still does not work I am at a loss and have no further idea.

Please look at your desktop for files starting with "phenodate". If you find any on your desktop try to open them by double-clicking.

Please tell us how it goes. Any bit of information can help.

Maybe someone else could also test the stack and chime in/or has an idea what could go wrong.

Kind regards
Bernd

Post Reply