2 Replies Latest reply on Sep 1, 2013 8:24 PM by DannyMH

    problem with bitmapData.draw method or bug in Flash ?

    Lexxx_87

      HI,
      I have problem when drawing transparent png image on transparent bitmapData.

       

      code of first frame:

       

      stop();

      import flash.display.Bitmap;
      import flash.display.BitmapData;
      import flash.display.BlendMode;
      import flash.geom.ColorTransform;
      import flash.geom.Matrix;

       

      var bmd: BitmapData = new BitmapData(500, 400, true, 0);
      var bitmap: Bitmap = new flash.display.Bitmap(bmd);
      addChildAt(bitmap, 1);

       

      var img: BitmapData = new particle13(10, 10);
      var matrix: Matrix = new Matrix();
      var ct: ColorTransform = new ColorTransform();

       

      for (var i:int = 0; i < 150; i++)
      {
      matrix.tx = Math.random() * 500;
      matrix.ty = Math.random() * 400;

       

      var scale = 1 + Math.random() * 2;
      matrix.a = scale;
      matrix.d = scale;

       

      bmd.draw(img, matrix, ct, BlendMode.ADD, null, true);
      }

       

      Bugs are lines over png image edges

      problem.PNG

       

      example atached

        • 1. Re: problem with bitmapData.draw method or bug in Flash ?
          Lexxx_87 Level 1

          Problem solved.

          Just round the position coordinates and scale

           

           

          stop();

           

          import flash.display.Bitmap;
          import flash.display.BitmapData;
          import flash.display.BlendMode;
          import flash.display.PixelSnapping;
          import flash.geom.ColorTransform;
          import flash.geom.Matrix;

           

          var bmd: BitmapData = new BitmapData(500, 400, true, 0);
          var bitmap: Bitmap = new Bitmap(bmd,PixelSnapping.NEVER,true);
          addChildAt(bitmap, 1);

           

          var img: BitmapData = new particle13(40, 40);
          var matrix: Matrix = new Matrix();
          var ct: ColorTransform = new ColorTransform();

           

          for (var i:int = 0; i < 150; i++)
          {
              matrix.tx = Math.round(Math.random() * 500);
             matrix.ty = Math.round(Math.random() * 400);

           

            
             var scale = 1  + Math.round(Math.random() * 2);
             matrix.a = scale;
             matrix.d = scale;
            
             bmd.draw(img, matrix, ct, BlendMode.ADD, null, true);
          }

           

          http://img525.imageshack.us/img525/4195/14450148.png

          • 2. Re: problem with bitmapData.draw method or bug in Flash ?
            DannyMH

            I just wonderd how to solve this problem when I need draw a particle. because a particle really need to scale to a value that smaller than 1.0