Creating a Blob
Creating a Blob
Does someone know how to create a Magick++ Blob with raw image data such as RGBA? If someone has a code sniplet, that would be great too.
Re: Creating a Blob
I know how to read raw data from file into a Magick::Blob object . Is that what you're after, or do you mean create the raw data from scratch?
Re: Creating a Blob
Here's some example code that reads from a raw uyvy image into a Blob, and then into an Image. It's lacking headers etc. and it uses naked arrays, but its mechanism should be clear to you.
'Chops
Code: Select all
char buffer1[4147200]; // enough for exactly one image's worth of bytes in this example
void* data1 = &buffer1[0]; // A void pointer to be passed to the Blob constructor
// Open image file
std::ifstream input_file("frame1.uyvy", std::ios::in | std::ios::binary);
// Read data into buffer
input_file.read (&buffer1, 4147200);
// Create Blob with data from buffer
Magick::Blob tempDataStore1(data1, 4147200);
// Create image from Blob
Magick::Image image1(tempDataStore1, "1920x1080", 3, "UYVY");
// Write that image as a png file
image1.write( "fromBlob.png");
Re: Creating a Blob
You can also look at the ImageMagick source distribution for Magick++/tests/readWriteBlob.cpp. It is an example program that reads and writes blobs.
Re: Creating a Blob
Yes, I am. I'm using it because that's a depth appropriate to the raw images I wrote this code for.kh263 wrote:Are you using a depth of 3 in this example? If so, why?