2 Replies Latest reply on May 12, 2006 3:11 AM by blemmo

    How to converting a flash clip into a bmp file quickly

    shi_hang_nk
      Hi,
      I’d like to get help on converting a flash clip into a bmp file. I have an application developed with ActiveX technology. There is a flash control embedded in the ActiveX control, which has a printing button. The end users can press the printing button to print the flash picture as well as other text content.
      I get the flash picture for printing in follow steps:
      1.Create a BitmapData object
      var bmp:BitmapData = new BitmapData(w, h, false);
      2.Obtain the image of current flash
      bmp.draw(mc, mc.transform.matrix, new ColorTransform(), 1, new Rectangle(x, y, w, h));
      3.Get pixels of flash image one by one in loop, and save them into a PixelCollection
      bmp.getPixel(col, row);
      4.Move the PixelCollection into flash container
      fscommand("print", load_PixelCollection);
      5.Ocx control gets the PixelCollection and converts it into BMP format

      But I find it is very slow when action script gets pixels one by one. Getting pixels of a middle size flash may spend one minute. It is hard for our customer to stand. Does anyone have idea to get the flash image quickly? 
      Any help is appreciated.
      Shi Hang
        • 2. Re: How to converting a flash clip into a bmp file quickly
          blemmo Level 1
          What about the built-in print methods, wouldn't it be better to use those here?
          Getting all pixel values is a time intensive process, because of the amount of pixels. It may be a bit faster if you split the getPixel() loop over some frames, but I'm not exactly sure how to do that (just read it somewhere).
          If the content is fixed, you could create the pixel array in the background while the user looks at it. This is quite some overhead, but when the user decides to print, the array would already be there.

          Finally, not helpful here, but interesting:

          quote:

          BitmapData.getPixels()
          No longer do you have to loop through every pixel in a bitmap, one at a time with getPixel to send a bitmap to the server. This method returns a ByteArray containing the hexadecimal color value of each of the pixels in the specified rectangular region of a bitmap. Use this method in conjunction with the new ZLib compression method; ByteArray.compress() to compress and send a bitmap over the wire to a server so it can be converted into a file ready for downloading.

          (from http://www.flashguru.co.uk/actionscript-3-new-capabilities/)
          This will be available in AS 3.

          hth,
          blemmo