在 Flex 中的 BitmapData 上绘制文本
好吧,问题可能很简单,但我无法弄清楚。我有一个图像加载到 BitmapData 中。现在我想从文本输入中获取文本并将其放在 BitmapData 上。基本上,它是在 BitmapData 上绘制文本,并以另一个 BitmapData 形式获取结果,该结果将由原始 BitmapData 以及在其上指定位置绘制的文本组成。在 Flex 中实现这一目标的最佳方法是什么?
Well, the problem may be a simple one but I can't figure it out. I have an image loaded into BitmapData. now I want to take text from a textinput and put it on the BitmapData. Basically it's drawing a text on the BitmapData and get the result as another BitmapData that will consist of the original BitmapData with the text drawn over it on a specified position. What's the best way to achieve this in flex?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要将文本放入位图中,您可以执行以下操作:
To put the text inside a bitmap you can do:
你不能根据位图数据来绘制,但你可以从数据中组合它。由于您拥有 BitmapData,因此很容易将其更改为位图 (
var bitmap:Bitmap = new Bitmap(bitmapData);
),然后将其添加为图像源。现在舞台上已经有了实际的图像,您现在可以使用您喜欢的内容(文本、标签、文本区域等)在其上方添加文本,然后可以在尺寸上执行
Bitmap.draw
图像的像素信息返回到 BitmapData(在 Bitmap.bitmapData 下)。You can't draw over bitmapdata per say, but you could compose it from the data. Since you have BitmapData, it's easy enough to change it to a bitmap (
var bitmap:Bitmap = new Bitmap(bitmapData);
) and then add it as source for an image.Now that you have an actual image on the stage, you can now add text above that using what you like (text, label, textarea, etc) and then you can do a
Bitmap.draw
over the dimensions of the image to get the pixel information back into a BitmapData (under Bitmap.bitmapData).