/** * Function addMorphedImages() morphs the images in $pre_morph_wnd, with * $num_morph_frames intermediary frames. The new sequence's images are then * set to display for $morph_delay 100th's of a second, and then added to the * end of $mgck_wnd's image list. * * @param resource MagickWand resource * @param resource MagickWand resource * @param int number of intermediary frames desired between the images * to be morphed * @param int desired length of time (in hundredths of a second) that * each frame in the newly morphed sequence will be * displayed * @param int Always __LINE__ (script current line number predefined * PHP constant) * * @return void */ function addMorphedImages($mgck_wnd, $pre_morph_wnd, $num_morph_frames, $morph_delay, $line) { $line = 'program line ' . $line . ', function line '; MagickSetFirstIterator($pre_morph_wnd); $morph_wnd =& checkWandError(MagickMorphImages($pre_morph_wnd, $num_morph_frames), $pre_morph_wnd, $line . __LINE__); MagickSetFirstIterator($morph_wnd); checkWandError(MagickRemoveImage($morph_wnd), $morph_wnd, $line . __LINE__); MagickSetLastIterator($morph_wnd); checkWandError(MagickRemoveImage($morph_wnd), $morph_wnd, $line . __LINE__); MagickResetIterator($morph_wnd); while (MagickNextImage($morph_wnd)) { checkWandError(MagickSetImageDelay($morph_wnd, $morph_delay), $morph_wnd, $line . __LINE__); } MagickSetLastIterator($morph_wnd); MagickSetLastIterator($mgck_wnd); checkWandError(MagickAddImages($mgck_wnd, $morph_wnd), $mgck_wnd, $line . __LINE__); DestroymagickWand($morph_wnd); }
/** * Function addMorphedImages() morphs the images in $pre_morph_wnd, with * $num_morph_frames intermediary frames. The new sequence's images are then * set to display for $morph_delay 100th's of a second, and then added to the * end of $mgck_wnd's image list. * * @param resource MagickWand resource * @param resource MagickWand resource * @param int number of intermediary frames desired between the images * to be morphed * @param int desired length of time (in hundredths of a second) that * each frame in the newly morphed sequence will be * displayed * @param int Always __LINE__ (script current line number predefined * PHP constant) * * @return void */ function addMorphedImages($mgck_wnd, $pre_morph_wnd, $num_morph_frames, $morph_delay, $line) { $line = 'program line ' . $line . ', function line '; /* Set the current active image in the $mgck_wnd MagickWand to the first image in its image list */ MagickSetFirstIterator($pre_morph_wnd); /* Perform the morph special effect on $pre_morph_wnd and assign the result to $morph_wnd */ $morph_wnd =& checkWandError(MagickMorphImages($pre_morph_wnd, $num_morph_frames), $pre_morph_wnd, $line . __LINE__); /* Set the current active image in the $morph_wnd MagickWand to the first image in its image list and remove it. */ MagickSetFirstIterator($morph_wnd); checkWandError(MagickRemoveImage($morph_wnd), $morph_wnd, $line . __LINE__); /* Set the current active image in the $morph_wnd MagickWand to the last image in its image list and remove it. */ MagickSetLastIterator($morph_wnd); checkWandError(MagickRemoveImage($morph_wnd), $morph_wnd, $line . __LINE__); /* Reset $morph_wnd's image list iterator; this has the effect that the next call to MagickNextImage($morph_wnd) sets $morph_wnd's current active image index to 0, i.e., to the first image. Contrast this behavior to MagickSetFirstIterator()'s, which sets the current active image's index to 0, causing the next call to MagickNextImage() to actually set the image index to 1, i.e., the second image in the MagickWand in question. This is an important distinction -- be careful. */ MagickResetIterator($morph_wnd); while (MagickNextImage($morph_wnd)) { /* Set the length of time the current active image is displayed to $morph_delay hundredths of a second. */ checkWandError(MagickSetImageDelay($morph_wnd, $morph_delay), $morph_wnd, $line . __LINE__); } MagickSetLastIterator($morph_wnd); /* Add the images in $morph_wnd to the end of $mgck_wnd */ MagickSetLastIterator($mgck_wnd); checkWandError(MagickAddImages($mgck_wnd, $morph_wnd), $mgck_wnd, $line . __LINE__); DestroymagickWand($morph_wnd); }