Advertisement
sanych_dv

Untitled

Apr 13th, 2016
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static public function setDnpPaper(bd:BitmapData):BitmapData
  2.         {
  3.             var resultPictureSize:Rectangle =  new Rectangle(0, 0, PND_PAPER_SIZE.width - parseInt( Main._config.vendor.margins[0] - parseInt( Main._config.vendor.margins[1]  ), PND_PAPER_SIZE.height - parseInt( Main._config.vendor.margins[2] - parseInt( Main._config.vendor.margins[3] ) );
  4.            
  5.             var sourceRatio:Number = bd.width / bd.height;
  6.            
  7.             var destRatio:Number = resultPictureSize.width / resultPictureSize.height;
  8.            
  9.             var matrix:Matrix;
  10.            
  11.             var ratio:Number;
  12.            
  13.             if (sourceRatio > destRatio)
  14.             {
  15.                 ratio = resultPictureSize.width / bd.width;
  16.             }
  17.             else
  18.             {
  19.                 ratio = resultPictureSize.height / bd.height;
  20.                
  21.             }
  22.            
  23.             matrix = new Matrix();
  24.             matrix.scale(ratio, ratio);
  25.            
  26.             var result_bd:BitmapData = new BitmapData(resultPictureSize.width, resultPictureSize.height, false, 0xFFFFFF);
  27.            
  28.             result_bd.draw(bd, matrix, null, null, null, true);
  29.            
  30.             var pnd_paper_bd:BitmapData = new BitmapData(PND_PAPER_SIZE.width, PND_PAPER_SIZE.height, false, 0xFFFFFF);
  31.            
  32.             matrix = new Matrix();
  33.            
  34.             matrix.tx = parseInt( Main._config.vendor.margins[0] ;
  35.             matrix.ty = parseInt( Main._config.vendor.margins[2];
  36.            
  37.             pnd_paper_bd.draw(result_bd, matrix, null, null, null, true);
  38.            
  39.             return pnd_paper_bd;
  40.  
  41.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement