0

我正在创建一个通过相机捕获多张图像的 Air/flex 应用程序。现在我有了图像,我想将少数捕获的图像“粘贴”到另一个图像(我的主图像)上的预定义位置。任何人都可以提供一个例子或指出我正确的方向吗?

4

2 回答 2

1

您可以将此代码粘贴到项目中进行测试,注释会逐步向您展示它是如何工作的。希望这是你需要的!

import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;
import flash.display.Bitmap;

// This rectangle represents your photo: 500x500, pure red.
var myPhoto:BitmapData = new BitmapData (500,500,false,0xff0000)
// This is another photo (green rectangle) as Bitmapdata, also 500x500 px
var somethingToDrawOnTop:BitmapData = new BitmapData (500,500,false, 0x00ff00)
// Select a region of the green picture: a 50x50 region located at 100,100 of the green pic
var regionToCopy:Rectangle = new Rectangle(100,100,50,50)
// Decide where you want the copied green region to end up in the red picture
var destinationForTheCopy:Point = new Point(250,250)
// Copy the pixels
myPhoto.copyPixels(somethingToDrawOnTop, regionToCopy, destinationForTheCopy)

// show the result
var compositBitmap:Bitmap = new Bitmap(myPhoto)
addChild (compositBitmap)
于 2012-08-24T13:02:33.053 回答
0

BitmapData.copyPixels() 方法

于 2012-08-20T20:24:20.167 回答