Cloning and the MagickWand API
Posted: 2009-03-31T10:49:15-07:00
I've been looking at the MagickWand API and I have two questions.
1. I see the CloneMagickWand method makes an exact copy of a wand. Given a wand with several images, how would I go about creating a new wand that contains a subset of those images? For example, given wand A containing 4 images, create wand B that is otherwise-identical but contains only images 2 and 3.
2. My memory is that a cloned image shares the pixel cache with the original image until one of the images tries to modify a pixel, at which point the cache is duplicated. That is, the pixel cache has copy-on-write semantics. Is that correct?
Where I'm going with this is that I'd like to be able to read a multi-image file into a wand, select one or more of the images into a new wand, and then do some operations on the new wand. It would be useful if there was only one copy of the pixel data as long as neither wand modifies the pixels.
1. I see the CloneMagickWand method makes an exact copy of a wand. Given a wand with several images, how would I go about creating a new wand that contains a subset of those images? For example, given wand A containing 4 images, create wand B that is otherwise-identical but contains only images 2 and 3.
2. My memory is that a cloned image shares the pixel cache with the original image until one of the images tries to modify a pixel, at which point the cache is duplicated. That is, the pixel cache has copy-on-write semantics. Is that correct?
Where I'm going with this is that I'd like to be able to read a multi-image file into a wand, select one or more of the images into a new wand, and then do some operations on the new wand. It would be useful if there was only one copy of the pixel data as long as neither wand modifies the pixels.