For the past few hours I have been trying to clone an image in Flex (using the Spark Components, but also trying to convert between Bitmap and BitmapImage).
What I am trying exactly is to create a simple painting application which keeps track of each Brush-Stroke. As soon as the Image on the Canvas has changed, it is to be cloned and then the clone is to be put into the History-Panel on the bottom of the application.
Things I have tried include:
- Using ObjectUtils.clone(Object)
- Creating BitmapData from Image.content, then making it a Bitmap and simply display it (Image doesn’t have a content field, it says)
- Performing a byte-copy
and others I could find on the internet, of course.
So basically, how does one clone an Image (Spark Image) in Flex 4.6?
Thank you very much!
— Danny Nophut
Instead of cloning you can get the image of the drawing and set the bitmap of the image as source to the history image, do some thing like this
In some case if the width and height of the target is not working you can use the getbounds method to get the bounds of the object and from the bounds take the width and height.