A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: sephiroth printscreen and GD Library problem..

  1. #1
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875

    sephiroth printscreen and GD Library problem..

    I'm using the above class to save an image out of flash when a user clicks a Save button i.e I am using http://www.sephiroth.it/tutorials/fl...en/page002.php

    I have used this class a few times before but for some reason i am having problems saving out the image to the folder when the specified image size is of a certain dimension or higher:

    e.g my flash code is:

    Code:
    import it.sephiroth.PrintScreen;
    loader._xscale = 0;
    
    
    var listener:Object = new Object();
    
    // copy in progress...
    listener.onProgress = function(target:MovieClip, loaded:Number, total:Number)
    {
    	var perc = Math.round((loaded/total)*100)
    	loader._xscale = perc;
    }
    
    // copy is complete, send the result LoadVars to PHP
    listener.onComplete = function(target:MovieClip, load_var:LoadVars)
    {
    	trace("done")
    	load_var.filename = new Date().getTime()+".jpg";
    	load_var.sendAndLoad("http://localhost/timesheet/pixels.php", load_var, "POST");
    }
    
    saver.onRelease = save;
    
    function save()
    {
    	pn = new PrintScreen();	// initialize the PrintScreen class
    	pn.addListener( listener );	// assign a listener
    	
    	
    	//pn.print(_root, 0, 0, 700,200)	// - this works
    	//pn.print(_root, 0, 0, 700,300)	//  - this works
    	//pn.print(_root, 0, 0, 700,400)	// - this work
    	pn.print(_root, 0, 0, 700,500); // NOW FROM THIS SIZE AND GREATER IT DOES NOT SAVE Out the image???????
    	
    }
    So as you can see the last line does not work... the previous lines save out an image to the 'posters' folder successfully ... is there some GD setting that is causing this issue? Any help is appreciated..been stuck on this for the last hour!!

    my php file is as follows:

    Code:
    <?php
    
    /**
     * Get the width and height of the destination image
     * from the POST variables and convert them into
     * integer values
     */
    $w = (int)$_POST['width'];
    $h = (int)$_POST['height'];
    $filename = $_POST['filename'];
    set_time_limit (300);
    
    
    // create the image with desired width and height
    
    $img = imagecreatetruecolor($w, $h);
    
    // now fill the image with blank color
    // do you remember i wont pass the 0xFFFFFF pixels 
    // from flash?
    imagefill($img, 0, 0, 0xFFFFFF);
    
    $rows = 0;
    $cols = 0;
    
    // now process every POST variable which
    // contains a pixel color
    for($rows = 0; $rows < $h; $rows++){
        // convert the string into an array of n elements
        $c_row = explode(",", $_POST['px' . $rows]);
        for($cols = 0; $cols < $w; $cols++){
            // get the single pixel color value
            $value = $c_row[$cols];
            // if value is not empty (empty values are the blank pixels)
            if($value != ""){
                // get the hexadecimal string (must be 6 chars length)
                // so add the missing chars if needed
                $hex = $value;
                while(strlen($hex) < 6){
                    $hex = "0" . $hex;
                }
                // convert value from HEX to RGB
                $r = hexdec(substr($hex, 0, 2));
                $g = hexdec(substr($hex, 2, 2));
                $b = hexdec(substr($hex, 4, 2));
                // allocate the new color
                // N.B. teorically if a color was already allocated 
                // we dont need to allocate another time
                // but this is only an example
                $test = imagecolorallocate($img, $r, $g, $b);
                // and paste that color into the image
                // at the correct position
                imagesetpixel($img, $cols, $rows, $test);
            }
        }
    }
    
    //// print out the correct header to the browser
    //header("Content-type:image/jpeg");
    // display the image
    imagejpeg($img, "posters/".$filename);
    ?>
    thanks in advance for your help..
    Last edited by silentweed; 12-17-2008 at 12:58 PM.
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    php processes are usually limited to some memory size on the server (e.g 4M or 8M)
    Now the php variables take space, and the image itself takes space (3 or 4 bytes/px)
    Also, the script attempts to set a longer time limit than usual ... whether the server accepts that is a different story

    Musicman

  3. #3
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    cheers musicman yeah it was indeed a php script timeout issue... all sorted now..thanks for your help
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center