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
-
gyroscope
- Livecode Opensource Backer

- Posts: 404
- Joined: Tue Jan 08, 2008 3:44 pm
-
Contact:
Post
by gyroscope » Sun May 17, 2009 1:45 pm
Hi, trying a test to apply to one of my apps eventually. Cobbled the scripts from Rev's Rev Browser sample. It works fine there, but taking the necessary code to a test stack, there's an error which is: unknown browser id. I can't work out why it doesn't work.
So basically I have two image areas, one large called "browserimage", one small called "thumbnail" and a button with the following script:
Code: Select all
local tImgData, tBrowserId, tOldRect
on mouseUp
put empty into tImgData
put the windowid of this stack into tWinID
put revBrowserOpen(tWinID,"http://www.google.com") into sBrowserId
put sBrowserId into img "browserimage"
revBrowserSet sBrowserId, "showborder","true"
revBrowserSet sBrowserId, "rect",rect of img "browserimage"
wait 1 second
revBrowserSnapshot tBrowserId, "tImgData"
put the rect of img "thumbnail" into tOldRect
set the rect of img "thumbnail" to the rect of img "browserImage"
set the imageData of img "thumbnail" to tImgData
set the resizeQuality of img "thumbnail" to "best"
set the rect of img "thumbnail" to tOldRect
end mouseUp
Can anyone explain why the line "revBrowserSnapshot tBrowserId, "tImgData"" isnt working, i.e why it can't recognise "tBrowserId" please

-
Janschenkel
- VIP Livecode Opensource Backer

- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
-
Contact:
Post
by Janschenkel » Sun May 17, 2009 2:37 pm
The variable 'tBrowserId' is not declared anwyhere in your script, so Revolution will automatically create a brand-new variable with as content the string "tBrowserId" - which is not a valid browser ID; replace the line
Code: Select all
revBrowserSnapshot tBrowserId, "tImgData"
with
Code: Select all
revBrowserSnapshot sBrowserId, "tImgData"
That's the danger of pulling together scripts from several source: it's your job to check and rename all the variables to make sure everything works correctly.
Jan Schenkel.
-
gyroscope
- Livecode Opensource Backer

- Posts: 404
- Joined: Tue Jan 08, 2008 3:44 pm
-
Contact:
Post
by gyroscope » Sun May 17, 2009 2:46 pm
The variable 'tBrowserId' is not declared anwyhere in your script
D'oh!

tBrowserId was one of my variables when I was "playing around" with the script.
That's the danger of pulling together scripts from several source: it's your job to check and rename all the variables to make sure everything works correctly.
You're absolutely right there, Jan, I should have double-checked the code. Thank you for your help.
I've got it working now but the thumbnail image is distorted with interference lines through it. Does anyone know why please and is there a way to correct it

-
bn
- VIP Livecode Opensource Backer

- Posts: 4172
- Joined: Sun Jan 07, 2007 9:12 pm
Post
by bn » Sun May 17, 2009 4:47 pm
gyroscope,
I've got it working now but the thumbnail image is distorted with interference lines through it
you set the rect of the browser to the rect of the image and than you tell the browser to
Code: Select all
revBrowserSet gBrowserId, "showborder","true"
this cuts 2 pixels off of the browser on every side.
Assume your Image "browserimage" would be 640 by 480 than you would say
Code: Select all
set the width of image "thumbnail" to 636
set the height of image "thumbnail" to 476
since you just pass the imageData and imageData needs absolutely the correct width and height. Once you have put it into the thumbnail image you can resize as you do.
So if you want the browser to showborder then you have to adjust the imagesize accordingly. subtract 4 from width and 4 from height of the dimensions of the receiving image.
(btw took me a while to figure it out, was fun)
regards
Bernd
-
bn
- VIP Livecode Opensource Backer

- Posts: 4172
- Joined: Sun Jan 07, 2007 9:12 pm
Post
by bn » Sun May 17, 2009 5:36 pm
gyroscope,
a more generic approach would be:
Code: Select all
put revBrowserGet(gBrowserId, "rect") into tBrowserRect
put revBrowserGet(gBrowserId, "showBorder") into tHasBorder
put item 3 of tBrowserRect - item 1 of tBrowserRect into tBrowserWidth
put item 4 of tBrowserRect - item 2 of tBrowserRect into tBrowserHeight
if tHasBorder then
subtract 4 from tBrowserWidth
subtract 4 from tBrowserHeight
end if
and than
Code: Select all
set the width of image "thumbnail" to tBrowserWidth
set the height of image "thumbnail" to tBrowserHeight
as I found out you apparently have to set
Code: Select all
revBrowserSet gBrowserId, "showborder","false"
if you dont want a border and want to test for showBorder, otherwise it will not return FALSE but it will return TRUE, although the default is false and the script did not set a showborder to true.
Looks like something for the QA department, if others can confirm this. And I did not see any mention of the bordersize and its influence on the revBrowserSnapshot. At least not in the documentation. Might be something for the new collaborative documentation feature...
regards
Bernd
-
gyroscope
- Livecode Opensource Backer

- Posts: 404
- Joined: Tue Jan 08, 2008 3:44 pm
-
Contact:
Post
by gyroscope » Sun May 17, 2009 10:07 pm
Hi Bernd, I appreciate your help but unfortunately it still is distorted.
Perhaps I've misunderstood something: I've added in your code as follows:
Code: Select all
local tImgData, tBrowserId, tOldRect
on mouseUp
put empty into tImgData
put the windowid of this stack into tWinID
put revBrowserOpen(tWinID,"http://www.google.com") into sBrowserId
put sBrowserId into img "browserimage"
revBrowserSet sBrowserId, "showborder","true"
revBrowserSet sBrowserId, "rect",rect of img "browserimage"
wait 1 second
revBrowserSnapshot tBrowserId, "tImgData"
-----------------------
put revBrowserGet(gBrowserId, "rect") into tBrowserRect
put revBrowserGet(gBrowserId, "showBorder") into tHasBorder
put item 3 of tBrowserRect - item 1 of tBrowserRect into tBrowserWidth
put item 4 of tBrowserRect - item 2 of tBrowserRect into tBrowserHeight
if tHasBorder then
subtract 4 from tBrowserWidth
subtract 4 from tBrowserHeight
end if
set the width of image "thumbnail" to tBrowserWidth
set the height of image "thumbnail" to tBrowserHeight
-----------------------------------------
put the rect of img "thumbnail" into tOldRect
set the rect of img "thumbnail" to the rect of img "browserImage"
set the imageData of img "thumbnail" to tImgData
set the resizeQuality of img "thumbnail" to "best"
set the rect of img "thumbnail" to tOldRect
end mouseUp
I guess I'm being a bit slow here...the width and height of the thumbnail becomes the size of browserimage, as per your two lines of code, but I would want it a quarter of the size.
-
bn
- VIP Livecode Opensource Backer

- Posts: 4172
- Joined: Sun Jan 07, 2007 9:12 pm
Post
by bn » Sun May 17, 2009 11:04 pm
gyroscope,
here is your script with comments
the distortion came from setting the width and height of the thumbnail to the browserimage, not the reduced size. see comments, that makes your distortion.
You picked up the rect of the thumbnail after having changed its size, pick it up earlier and it will return to its original size. see comments
Code: Select all
local tImgData, sBrowserId, tOldRect
on mouseUp
put empty into tImgData
put the windowid of this stack into tWinID
put revBrowserOpen(tWinID,"http://www.google.com") into sBrowserId
put sBrowserId into img "browserimage"
revBrowserSet sBrowserId, "showborder","true"
revBrowserSet sBrowserId, "rect",rect of img "browserimage"
wait 1 second
revBrowserSnapshot sBrowserId, "tImgData"
-----------------------
put revBrowserGet(sBrowserId, "rect") into tBrowserRect
put revBrowserGet(sBrowserId, "showBorder") into tHasBorder
put item 3 of tBrowserRect - item 1 of tBrowserRect into tBrowserWidth
put item 4 of tBrowserRect - item 2 of tBrowserRect into tBrowserHeight
if tHasBorder then
subtract 4 from tBrowserWidth
subtract 4 from tBrowserHeight
end if
-- get the rect here, before changing
put the rect of img "thumbnail" into tOldRect
set the width of image "thumbnail" to tBrowserWidth
set the height of image "thumbnail" to tBrowserHeight
-----------------------------------------
-- wrong place, you just changed the width and height
-- put the rect of img "thumbnail" into tOldRect
-- this really makes the distortion, you set the rect to the rect of the browserimage
-- but before you had taken care to reduce width and height
-- set the rect of img "thumbnail" to the rect of img "browserImage"
set the imagedata of img "thumbnail" to tImgData
set the resizequality of img "thumbnail" to "best"
set the rect of img "thumbnail" to tOldRect
end mouseUp
this works for me, let me know if it works for you
regards
Bernd
-
gyroscope
- Livecode Opensource Backer

- Posts: 404
- Joined: Tue Jan 08, 2008 3:44 pm
-
Contact:
Post
by gyroscope » Sun May 17, 2009 11:26 pm
No joy there, Bernd, I'm sorry to say; it worked the first time but pressing the button again it became distorted (black and white) then a pink block, then black and white distorted again. Most strange why it's not reading the data correctly.
I've just remembered trying this with browserimage having scrollbars. The thumbnail was fine if none of the scrollbars were in any one of the corners: most strange...
Thank you for helping, all the same.
-
bn
- VIP Livecode Opensource Backer

- Posts: 4172
- Joined: Sun Jan 07, 2007 9:12 pm
Post
by bn » Mon May 18, 2009 12:01 am
I noticed that the imagedata size changes when e.g there is a scrollbar, but the rect is always the same, in my case 640*480. So it is not only the showborder, it must be something else going on, that I dont know.
What made me always stay away from the browser is that you get exactly the same problem in the demo stack, the first image works and than it is distorted. I did not even feel like digging into this. So today I took your example to look into the snapshot and the browser.
May be someone has experience with the snapshot and the browser.
So the question is: Has someone gotten a working example for the browser and the snapshots?????
The revolution Quality Control Center has no bug reports regarding the revBrowserSnapshot except for 2 documentation errors.
Not the example in the 3.5 Resource center, that does not work for the snapshots, at least not more than once. It has not worked since the browser was introduced in version 2.8.1 I think.
Well, it was a nice try though.
Bernd
-
bn
- VIP Livecode Opensource Backer

- Posts: 4172
- Joined: Sun Jan 07, 2007 9:12 pm
Post
by bn » Mon May 18, 2009 12:25 am
gyroscope,
if you set the showBorder to false then the revBrowserSnapshot works pretty good, at least repeatedly with different websites I get snapshots. No distortions or pink colors.
Bernd
-
gyroscope
- Livecode Opensource Backer

- Posts: 404
- Joined: Tue Jan 08, 2008 3:44 pm
-
Contact:
Post
by gyroscope » Mon May 18, 2009 1:58 pm
Hi Bernd, well, it's working now, even without setting showBorder to false. Most strange; but I can't remove it from memory or quit Rev, so something's still not right. I've had this problem before when working with RevBroswerSet and Rev BrowserSnapshot, it has caused other odd behaviour as well.
Thanks for your help again!
Edit: with or without showBorder to false added, it works until I change the web address, press the button again, and the distortion appears once more. Must be something to do with the binary imagedata I guess, not mapping correctly for some reason...