MagickAddImage() adds to inconsistant position
Posted: 2007-07-15T04:24:59-07:00
The doc for MagickAddImage() says it 'adds the specified images at the current image location.'
I have two problems
The relevant code seems to be at lines 443 and 453 of wand/magick-image.c
What I was doing:-
I have two problems
- If I iterate to the required position MagickAddImage() adds the images to the end of the list rather than in the middle where I want it.
- If I explicitly set the 'current image location' with MagickSetIteratorIndex(), MagickAddImage() inserts the images before the 'current image location'. I would have expected it to add them after.
The relevant code seems to be at lines 443 and 453 of wand/magick-image.c
What I was doing:-
Code: Select all
# without declarations or return value checks
rgb = NewMagickWand()
MagickSetSize(rgb, 64, 64)
MagickSetLastIterator(rgb); MagickReadImage(rgb, 'xc:red')
MagickSetLastIterator(rgb); MagickReadImage(rgb, 'xc:green')
MagickSetLastIterator(rgb); MagickReadImage(rgb, 'xc:blue')
rgb2 = CloneMagickWand(rgb) # copy for 2nd test
cmy = NewMagickWand()
MagickSetSize(cmy, 64, 64)
MagickSetLastIterator(cmy); MagickReadImage(cmy, 'xc:cyan')
MagickSetLastIterator(cmy); MagickReadImage(cmy, 'xc:magenta')
MagickSetLastIterator(cmy); MagickReadImage(cmy, 'xc:yellow')
# test 1 -- iterating to position
MagickResetIterator(rgb)
MagickNextImage(rgb) # red is current
MagickNextImage(rgb) # green is current
MagickAddImage(rgb, cmy) # I expect "r g C M Y b"
result = MagickAppendImages(rgb, 0)
MagickWriteImage(result, 'X:') # I get "r g b C M Y"
# test 2 -- explicitly set position
MagickSetIteratorIndex(rgb2, 1) # green is current
MagickAddImage(rgb2, cmy) # I expect "r g C M Y b"
result = MagickAppendImages(rgb2, 0)
MagickWriteImage(result, 'X:') # I get "r C M Y g b"