Hey! I am making screenshot system for gmod.
1. Can i send render.Capture data to webserver?
2. If i can, how i would do it using http.Post?
You can convert the image to a "string" and send it over.
On the webserver you'd have to find some language like php to handle the saving.
There are public and free addons that do this.
[QUOTE=freakyy;47141539]You can convert the image to a "string" and send it over.
On the webserver you'd have to find some language like php to handle the saving.
There are public and free addons that do this.[/QUOTE]
And how do i convert it to string, so that php could decode it?
render.Capture returns a string, you might also want to use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/util/Compress]util.Compress[/url] and then decompress it on the webserver, but that's not essential
render.Capture already outputs a string.
[QUOTE=Robotboy655;47142231]render.Capture already outputs a string.[/QUOTE]
Wait wait. I writed it to file and there was strange icons/things in the file. Does that count as string??
[QUOTE=SteppuFIN;47144061]Wait wait. I writed it to file and there was strange icons/things in the file. Does that count as string??[/QUOTE]
A string can be used to represent any binary data. http.Post ( or your webserver ) may not support specific characters such as null characters. Try using util.Base64Encode on your data before sending it and on your webserver decode that.
[QUOTE=Willox;47144069]A string can be used to represent any binary data. http.Post ( or your webserver ) may not support specific characters such as null characters. Try using util.Base64Encode on your data before sending it and on your webserver decode that.[/QUOTE]
Yeah, Base64 is good. How do i post it? I dont get the tutorial and it is without example...
[code]
http.Post( "http://example.com/", { data = util.Base64Encode( my_data ) } )
[/code]
You'd access the data on your website as the "data" parameter of the post data. In php that'd be $_POST['data'].
[QUOTE=Willox;47144097][code]
http.Post( "http://example.com/", { data = util.Base64Encode( my_data ) } )
[/code]
You'd access the data on your website as the "data" parameter of the post data. In php that'd be $_POST['data'].[/QUOTE]
[CODE]<?php
$data = $_POST['data'];
$imageData = base64_decode($data);
$source = imagecreatefromstring($data);
$rotate = imagerotate($source, 0, 0); // if want to rotate the image
$imageSave = imagejpeg($rotate, "test", 100);
imagedestroy($source);
?>[/CODE]
This didn't work...
Error:
[CODE][15-Feb-2015 07:23:32 UTC] PHP Warning: imagecreatefromstring(): Empty string or invalid image in screenshot.php on line 5
[15-Feb-2015 07:23:32 UTC] PHP Warning: imagerotate() expects parameter 1 to be resource, boolean given in on line 6
[15-Feb-2015 07:23:32 UTC] PHP Warning: imagejpeg() expects parameter 1 to be resource, boolean given in screenshot.php on line 7
[15-Feb-2015 07:23:32 UTC] PHP Warning: imagedestroy() expects parameter 1 to be resource, boolean given in screenshot.php on line 8[/CODE]
And my lua code:
[CODE]
function sendScreenshot()
local RCD = { }
RCD.format = "jpeg"
RCD.h = ScrH()
RCD.w = ScrW()
RCD.quality = 100 //100 is max quality, but 70 is good enough.
RCD.x = 0
RCD.y = 0
local Picdata = render.Capture(RCD)
http.Post( "http://futuretechs.eu/screenshot/screenshot.php", { data = util.Base64Encode( Picdata ) } )
print("Sent")
end[/CODE]
Calling the sendScreenshot() manually.
[code]
$imageData = base64_decode($data);
$source = imagecreatefromstring($data);
[/code]
You did it wrong.
[QUOTE=Willox;47144125][code]
$imageData = base64_decode($data);
$source = imagecreatefromstring($data);
[/code]
You did it wrong.[/QUOTE]
I don't see difference, i may be dumb...
I didn't change it. Fix your own crap :v:
[QUOTE=Willox;47144134]I didn't change it. Fix your own crap :v:[/QUOTE]
Lol, alright i realized that. Still the same problem, changed $data to $imageData
[editline]15th February 2015[/editline]
Well, i dont get it tried 5 examples and all says that the string may be null?
[editline]15th February 2015[/editline]
Rewriting time then, i will send it to player.
Any way to open the Picdata at client? I mean like browser, expect it opens the text file as jpeg?
Sorry, you need to Log In to post a reply to this thread.