Trying to capture stage area using BitmapData

前端 未结 3 1823
半阙折子戏
半阙折子戏 2020-12-19 14:24

I am trying to grab part of stage area using BitmapData and copyPixels method:

bmd = new BitmapData(stage.stageWidth, stage.stageHeight);

b         


        
相关标签:
3条回答
  • 2020-12-19 14:34

    Finally used this solution to copy part of the stage

    (I copied everything that is on stage from (360, 20) and after)

    var bitmapdata:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight);
    
    bitmapdata.draw(stage);
    
    var bitmapDataA: BitmapData = new BitmapData(300, 250);
    
    bitmapDataA.copyPixels(bitmapdata, new Rectangle(360, 20, 320, 240), new Point(0, 0));
    
    var myEncoder:JPGEncoder = new JPGEncoder(90);
    
    var byteArray:ByteArray = myEncoder.encode(bitmapDataA);
    
    0 讨论(0)
  • 2020-12-19 14:57

    Can't you just call bmd.draw(stage)?

    0 讨论(0)
  • 2020-12-19 14:57
      var stage_snapshot:BitmapData = new BitmapData(600, 120);
    
      var myRectangle:Rectangle = new Rectangle(0, 0, 600, 120);
    
    
      var myMatrix:Matrix = new Matrix();
    
      var translateMatrix:Matrix = new Matrix();
    
      translateMatrix.translate(-100, -225);
    
      myMatrix.concat(translateMatrix);
    
      stage_snapshot.draw(stage,myMatrix,null,null,myRectangle);
    
      var encoded_jpg:JPGEncoder = new JPGEncoder(100);
    
      var jpg_binary:ByteArray = new ByteArray();
    
      jpg_binary = encoded_jpg.encode(stage_snapshot);
    
    0 讨论(0)
提交回复
热议问题