so I am trying to use the Magick++ library to do some image manipulation to an image.
I can get a pixel array from the image, so my question is, how do can i use a pixel array to push it into a readPixels() function and how can i get it to fit my pixel array format when i do a getPixels() - i don't like this pixelpacket business >.<
ok, here's some pseudo code:
Code: Select all
#include <ImageMagick/Magick++.h>
using namespace Magick;
Image blank_image("320x240", "white");
PixelPacket *mypixelpacket;
myMovie.loadMovie("movies/myMovie.mov");
myMovie.play();
myMovie.setLoopState(OF_LOOP_NORMAL);
while (1) {
myMovie.update(); //update the video frame
bool bNewFrame = false;
bNewFrame = myMovie.isFrameNew(); //checks if the video is at a new frame since the app runs more than 30 fps
if (bNewFrame) { //if we are at a new frame
blank_image.readPixels(RGBQuantum, myMovie.getPixels() ); //tell the blank_image to read the pixels from myMovie
blank_image.blur(6, 1.5); //blur the image
blank_image.syncPixels(); //sync pixels
mypixelpacket = blank_image.getPixels(0,0,320,240); //put the pixels in a pixel packet
myMagickImage.setFromPixels((unsigned char*)mypixelpacket, 320, 240, RGBImage); //convert the pixel packet to an unsigned char array and feed it
}
myMovie.draw(20,20); //draws the video at X:20 and Y:20 on a canvas
myMagickImage.draw(400, 20); //draws the image at it's respective X and Y next to it.
}
Code: Select all
myMovie.getPixels() == unsigned char myPixelArray[widthOfImage*HeightOfImage*AmmountOfDataPerPixel] = { 10, 30, 100, 63, 42, 86, 24}
now with this setup i get a bunch of lines in my Magick image, see my image link, original is on the left, modified is on the right.

and in a very weird twist, although i can do this:
Code: Select all
myMagickImage.setFromPixels((unsigned char*)mypixelpacket, 320, 240, RGBImage);
Code: Select all
unsigned char *myPixelArray = (unsigned char*)mypixelpacket;
sooo, any help on this pixelpacket to to unsigned char issue i am having?