'loadgraphic' problem/bug/feature?

new BookmarkLockedFalling
tenochtitlanuk
New Member
*

tenochtitlanuk Avatar

Posts: 25

Post by tenochtitlanuk on Dec 20, 2008 16:35:36 GMT -5

I have been playing with serving up screengrabs of whatever happens to be on my server screen, saved by a LB timed bmpsave & converted to jpg.
The RB lines....
loadgraphic #picture, "C:\rbp101\public\images\window.jpg"
render #picture

......fail if the jpg is of the whole screen with a 'primitive failed' error, but work if I use a 50% reduced size.
Is the error to do with the file size, or the image width/height dimensions?

edit- it works if I have the image in public, not one level deeper where I hoped to remove extant copies along with other rendered graphics
Last Edit: Dec 20, 2008 16:46:15 GMT -5 by tenochtitlanuk
Carl Gundel - admin
Administrator
*****

Carl Gundel - admin Avatar

Posts: 550

tenochtitlanuk
New Member
*

tenochtitlanuk Avatar

Posts: 25

Post by tenochtitlanuk on Dec 21, 2008 19:00:28 GMT -5

It's looking as if I'm getting some unexpected interaction between the LB, RB & the dll calls. I am getting hangs as well as the error message, and the filesize seems NOT to be the problem. Sometimes it all works fine- other times goes funny. The dll is on my site if you want to try it out. Its not the loadgraphic- as you'll see I've used your img tag method. Separate prob- the page refreshes without loading the latest jpg..

LB runs

' LB side of LB-RB data-passing ing via public...screen.jpg'.
' You set up and at timed intervals put a screengrab as a jpg in there
' The rest of the time this program sleeps.
' Close the mini-window at top LH screen when you want it to stop updating.

' You also need PCT_DLL.dll in the system dir or same as this prog is in.

' Interestingly, kill needs backslash but the dll accepts forward or back.

nomainwin

WindowWidth = 10
WindowHeight = 2
UpperLeftX = 1
UpperLeftY = 1

open "LB" for graphics as #main

print #main, "trapclose [quit.main]"
hW =hwnd( #main)
calldll #user32, "GetParent", hW as long, hP as long

[run]
'Save all screen to window.bmp in ramdrive R:
dest$ ="C:\rbp101\public\window.bmp"
hP =0' so will grab whole screen
open "PCT_DLL.dll" for dll as #conv
calldll #conv, "formtobmp", hP as ulong, dest$ as ptr, r as long
'then convert it to window.jpg
source$ ="C:\rbp101\public\window.bmp": dest$ ="C:\rbp101\public\window.jpg"
calldll #conv, "tojpeg", source$ as ptr, dest$ as ptr, r as long
close #conv

kill "C:\rbp101\public\window.bmp" 'and then remove the bmp version

calldll #kernel32, "Sleep", 10000 as ulong, r as void
' ie 10000 ms or 10 sec- change as you wish.
scan
goto [run]

[quit.main]
close #main
end



RB runs

html "<meta http-equiv=""Refresh"" content=""30"">"

html "<center>"
html "<b>Server Screen display</b>"
html "<p>"
html "<p>"
print "The page refreshes every 30 sec from server screen grabbed every 10 sec."

html "<img src=""/window.jpg""/>"

end
Last Edit: Dec 21, 2008 19:03:34 GMT -5 by tenochtitlanuk
Carl Gundel - admin
Administrator
*****

Carl Gundel - admin Avatar

Posts: 550

Post by Carl Gundel - admin on Dec 21, 2008 21:45:13 GMT -5

Maybe Run BASIC is sometimes trying to read the image before it is finished being written? You could put a delay in there and you might also generate the file with one name and then rename it to the filename that your RB program expects only after it is written.

Or, don't read the file into your program. Just put an image tag in the page and let the RB web server serve up the file directly.

-Carl
tenochtitlanuk
New Member
*

tenochtitlanuk Avatar

Posts: 25

Post by tenochtitlanuk on Dec 22, 2008 7:37:25 GMT -5

Merry Xmas, & thanks, Carl!!

I was thinking on the same lines. Rewrote the LB part so it uses Timer 10 sec delays between creating bitmap, converting & deleting. That seems stable..

' LB side of LB-RB data-passing ing via 'C:/rb101/public/screen.jpg'.
' It puts in 'public' a screengrab bmp, then converts it to a jpg and deletes bmp.
' The rest of the time this program sleeps, by using timer intervals.
' Close the mini-window at top LH screen when you want it to stop updating.

' You also need PCT_DLL.dll in the system dir or same dir as this prog is in.

' Interestingly, kill needs backslash but the dll accepts forward or back.

nomainwin

WindowWidth = 100
WindowHeight = 40
UpperLeftX = 1
UpperLeftY = 1

open "LB" for graphics as #main

print #main, "trapclose [quit.main]"

'hW =hwnd( #main)
'calldll #user32, "GetParent", hW as long, hP as long

timer 10000, [grabscreen]
wait

end

[grabscreen]
'print "grabscreen"
timer 0
'Save all screen to window.bmp in ramdrive R:
dest$ ="C:\rbp101\public\window.bmp"
hP =0 ' so will grab whole screen
open "PCT_DLL.dll" for dll as #conv
calldll #conv, "formtobmp", hP as ulong, dest$ as ptr, r as long
close #conv
timer 10000, [convert]
wait

[convert]
'print "convert"
timer 0
'then convert it to window.jpg
source$ ="C:\rbp101\public\window.bmp": dest$ ="C:\rbp101\public\window.jpg"
open "PCT_DLL.dll" for dll as #conv
calldll #conv, "tojpeg", source$ as ptr, dest$ as ptr, r as long
close #conv
timer 10000, [delete]
wait

[delete]
'print "deleting"
timer 0
kill "C:\rbp101\public\window.bmp"
timer 10000, [grabscreen]
wait

[quit.main]
close #main
end


The RB end I'd already changed to html "<img... and added the size parameters.

html "<meta http-equiv=""Refresh"" content=""30"">"

html "<center>"
html "<b>Server Screen display</b>"
html "<p>"
html "<p>"
print "The page refreshes every 30 sec from server screen grabbed every 30 sec."
print "If nothing changes I'm probably working on laptop not server- or away!"

html "<img src=""/window.jpg"" width=""512"" height=""384/>"

end


Now seems to run well.
tenochtitlanuk
New Member
*

tenochtitlanuk Avatar

Posts: 25

Last Edit: Dec 24, 2008 13:11:35 GMT -5 by tenochtitlanuk
mikeukmid
Guest

Guest Avatar

Post by mikeukmid on Dec 24, 2008 17:38:13 GMT -5

Happy holidays everyone!

Carl Gundel - admin Avatar


Or, don't read the file into your program. Just put an image tag in the page and let the RB web server serve up the file directly.

-Carl


But you then can't serve webcam image from a ramdisk, can you? That's why I use loadgraphic and the image often does not change even though I can see that the image in ramdisk has changed.

The rendered image from loadgraphic seems to get 'stuck' such that when the page is refreshed, the old image is re-rendered, not the newer image.

Mike.
laurent
New Member
*

laurent Avatar

Posts: 2Male