8 Replies Latest reply on Mar 22, 2010 7:36 PM by Ron Colmen

    Send a bitmap

    Ron Colmen Level 2

      My website

      Draw your idea  >> Convert to bitmap button >> Submit Form.

       

      What I need to know (*)

      MOVIECLIP  >> BITMAP using bitmapdata.draw  >>  * SEND via EMAIL

       

      How to send a bitmap via email?

        • 1. Re: Send a bitmap
          kglad Adobe Community Professional & MVP

          you'll need to use server-side code.

          • 2. Re: Send a bitmap
            Ron Colmen Level 2

            I'm using PHP to submit the data in the FORM. But how to edit it to send the bitmap?

             

            <?PHP
            $to = "my@mail.com";

             

            $subject = "$thecompany Request";
            $headers = "From:" .$email."\r\n";
            $message = "Name: " . $thename;
            $message .= "\nCompany: " . $thecompany;

            $sentOk = mail("$to",$subject,$message,$headers);

            echo "sentOk=" . $sentOk;

            PHP>

             

            var senderLoad:LoadVars = new LoadVars();
            var receiveLoad:LoadVars = new LoadVars();

            sender.onRelease = function () {
            senderLoad.category = thename.text;
            senderLoad.namez = thecompany.text;
            senderLoad.sendAndLoad("www.website.com/abc.php" );
            }

            receiveLoad.onLoad = function () {
            if(this.sentOk) {
              _root.gotoAndStop("success");
            }
            else {
              _root.gotoAndStop("failed");
            }
            }

            • 3. Re: Send a bitmap
              kglad Adobe Community Professional & MVP

              you have 2 parts to this:

               

               

              1.  reconstitute your image using php.  (check the imagecreatetruecolor() php function.)

               

              2.  attach an image to email using php.  (search for php code to do this.)

              1 person found this helpful
              • 4. Re: Send a bitmap
                Ron Colmen Level 2

                Thank you!

                 

                That's the PHP part - I believe that's the 2nd stage. But how do I send the image (wahich was created using bitmapdata draw) from flash to PHP?

                • 5. Re: Send a bitmap
                  kglad Adobe Community Professional & MVP

                  i loop through all the pixels in the bitmap and construct a string that's sent to the php.  in the php i reconstruct the image from the string.

                   

                  dave mennonoh (i believe) had a simple but effective idea for compressing this data which works very well. instead of enumerating each pixel, you only enumerate unique pixels.  if pixel n and n+1 are the same, pixel n+1 is listed as "" which takes far less memory than a (repeat) pixel like 0xaabbcc.  because in most images 1/2 or more pixels are duplicates of their neighbor, this compresses the string by a factor of 2 or more.

                  1 person found this helpful
                  • 6. Re: Send a bitmap
                    Ron Colmen Level 2

                    Thank you! It seems a bit complicated. Anyway I'd like to go through it step by step.

                     

                    What commands do I need to use to construct the string in flash? Could you please show me an example. Below is the script I use to convert the movieclip to a bitmap.

                     

                    import flash.display.BitmapData;
                    import flash.geom.Matrix;

                     

                    two_slct.onRelease = function() {
                    var bmd:BitmapData = new BitmapData(375,400);
                    var mat:Matrix=new Matrix();
                    mat.a=mat.d=1.5;
                    md.draw(_root.gmc_mc,mat)

                    };

                    • 7. Re: Send a bitmap
                      kglad Adobe Community Professional & MVP

                      var dataS:String = compressArray(PixelAF(bmd)).toString();

                       

                      function PixelAF(bmp:BitmapData):Array {
                           var w = bmp.width;
                          var h = bmp.height;
                          var pixelA:Array = new Array();

                          for (var a = 0; a<=w; a++) {
                              for (var b = 0; b<=h; b++) {
                                  var tmp = bmp.getPixel(a, b).toString(16);
                                  pixelA.push(tmp);
                              }
                          }
                          return pixelA;
                      }

                       

                      function compressArray(orig:Array):Array {
                          var compressedA:Array = [];

                         // lei=last empty index
                          var lei:Number = 0;
                          for (var i = 0; i<orig.length; i++) {
                              if (orig[i] != compressedA[lei]) {
                                  compressedA[i] = orig[i];
                                  lei = i;
                              } else {
                                  compressedA[i] = "";
                              }
                          }
                          return compressedA;
                      }

                      • 8. Re: Send a bitmap
                        Ron Colmen Level 2

                        Thank you!! I appriciate it very much. Using this I will try few thing on my own and return.