A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Another 'save as image' thread..

Threaded View

  1. #1
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755

    Another 'save as image' thread..

    ok.. so I finally wanted to actually try instead of just reading it.. (ie: had a need for it)


    I read the same basic threads/posts that go to the same tuts.. however I couldnt get things to work..

    not sure if AS, PHP..or if a hosting problem possibly? (permissions)

    long story short.. I am trying to get the most straight forward (no filters..no video capture..etc) method to work.

    just a clip on stage.. has some scribbles or other movieClip attached inside fo it.. but whatever is inside tis 'containerClip' should be copied 7 sent to a php script to be made into an image..



    AS:
    PHP Code:
    import flash.display.BitmapData;

    button1.onPress = function(){
        
    output();
    }

    function 
    output() {
        var 
    snap:BitmapData = new BitmapData(containerClip._widthcontainerClip._heightfalse0xFFFFFF);
        
    snap.draw(containerClip);
        var 
    pixels:Array = new Array();
        var 
    w:Number snap.width;
        var 
    h:Number snap.height;
        for (var 
    0a<=wa++) {
            for (var 
    0b<=hb++) {
                var 
    tmp snap.getPixel(ab).toString(16);
                
    pixels.push(tmp);
            }
        }
        
        
    //send to php for image creation
        
    var output:LoadVars = new LoadVars();
        
    output.img pixels.toString();
        
    output.height h;
        
    output.width w;
        
    output.send("http://www.domainname.com/folder/show.php""output""POST");



    PHP:
    PHP Code:
    <?php
        $data 
    explode(","$_POST['img']);
        
    $width $_POST['width'];
        
    $height $_POST['height'];
        
    $image=imagecreatetruecolor$width ,$height );
        
    $background imagecolorallocate$image ,);
        
    //Copy pixels
        
    $i 0;
        for(
    $x=0$x<=$width$x++){
            for(
    $y=0$y<=$height$y++){
                
    $int hexdec($data[$i++]);
                
    $color ImageColorAllocate ($image0xFF & ($int >> 0x10), 0xFF & ($int >> 0x8), 0xFF $int);
                
    imagesetpixel $image $x $y $color );
            }
        }
        
    //Output image and clean
        
    header"Content-type: image/jpeg" );
        
    ImageJPEG$image );
        
    imagedestroy$image );    
    ?>
    I see it looks to be currently set-up for.jpg output.. I would eventually want it to be a .gif or .png.. so does that mean in the AS using getPixe32() instead? or is there other changes?

    Thanks


    sorry this is AS2.0 only (Flash 8)

    this link:
    http://www.quasimondo.com/archives/000572.php

    source files are sorta working out of the box.. as I see the image being created.. however he is using a custom class with the file upload reference included..and Id like to have something just VERY simple and then move forward..

    on click on button..take pre-determined containerClip (and all nested content).. send the data to php script on server,.. php script takes bitmap data/array creates a .png (or whatever at this point).. and then returns some message back to flash.. saying all is complete.. and maybe a url?

    at this point.. thing will change.. but Id like to get here if anyone can help or offer suggestions? ultimately I guess id like for it to be emailed..

    or just have it open in a new page?..

    thanks

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