Search Unity

screenshots and displaying them in a webbrowser

Discussion in 'Scripting' started by Crisium, Jun 2, 2011.

  1. Crisium

    Crisium

    Joined:
    Aug 7, 2010
    Posts:
    67
    Hi,

    i'm trying to take a screenshot then send the data to my server and display it in an img tag.

    In unity I do the stardard EncodeToPng thingy.
    // Encode texture into PNG
    var bytes = tex.EncodeToPNG();

    I assumed that the encode is an uri encoding?

    so I expected that I could do the following:

    Application.OpenURL( "http://whatever/showimg.php?data="+bytes );

    where in the showimg.png

    I do a:

    <?php

    $data = urldecode ($_GET["data"]);

    echo "<img src='data:image/png;base64, $data' alt=''>";

    ?>

    of course none of this works and I believe it because I'm assuming too much, but I'm sorry the documentation in Unity is not detailed enough for me to do anything else but assume.

    can someone help me?

    Peter
     
  2. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    hahaha

    There is a limit to URL lengths :)
     
  3. Crisium

    Crisium

    Joined:
    Aug 7, 2010
    Posts:
    67
    @NPSF3000

    length is not the problem at hand... you are off topic

    peter
     
  4. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Last edited: Jun 2, 2011
  5. Crisium

    Crisium

    Joined:
    Aug 7, 2010
    Posts:
    67
    @NPSF

    omg.. another 11 year old

    please re-read the post and you will see that it states "assume".. usually when you encode for the web it's because you want to send in a format that can be sent.... I also stated the encode part not the PNG == URI.. you are just be an a** now.

    EOD with you.
     
  6. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    "usually when you encode for the web it's because you want to send in a format that can be sent"

    Where do you encode for the web? Do you know what PNG is?

    But hey, if I as a *11 year old* can read the docs, then I guess there is no need to help ya.

    For the record, I have actually done something very similar like this.
     
  7. tonyf1121

    tonyf1121

    Joined:
    Apr 24, 2011
    Posts:
    42
    Crisium why do you assume hes an 11 year old...your acting very immature he was just trying to help you solve your problem...
     
  8. SkaredCreations

    SkaredCreations

    Joined:
    Sep 29, 2010
    Posts:
    296
    WWWForm reference contains an explicit example to send an image to a web page, you must use a form and add binary data and NPSF3000 is not offtopic, he's right because the limit in the URLs (that is page address+ GET parameters) exists.

    If you're used to web programming you can easily achieve the goal: post the image with WWWForm and when it finishes then do an ExternalCall to your page passing the URL of the image (that you can randomly create in your upload script and returns to WWW as text)
     
    Last edited: Jun 4, 2011
  9. bigmisterb

    bigmisterb

    Joined:
    Nov 6, 2010
    Posts:
    4,221
    Read what ZioRed posted, and furthermore, if your web page limits you to upload size, you can upload it in sections and let PHP put it back together on the other side.

    In the end you can then use the picture on a web page, or even in Unity.