first frame from a blob??
Posted: 2009-05-21T18:21:58-07:00
This is in continuity of thread viewtopic.php?f=1&t=13609. Since no replies are coming over there so I thought may be that too has become inactive.
I could not get the sampling going while streaming through an image. Can you please give an example for that.
Also I tried following plz have a look into it:
Magick::Image image;
image.subImage(3);
image.subRange(1);
I was trying to use the above methods to get the first scene from a mpg http://cid-7572e6fdaea4368b.skydrive.li ... ic/vid.mpg while using blob but it does not work like ("vid.mpg[0]")
I used the following code:
Code:
Though I only get the first scene by both methods but that happens even if I don't use [0] OR subImage() and subRange() methods at all.
But in first case (path+"[0]") the time taken is way less than during subImage(),subRange() methods which suggests that they are not doing the same thing.
How can we get the same effect as (path+"[0]") for the case where we want to read image from inside a file, from an offset other than zero, (i.e. in case of blobs)?
I could not get the sampling going while streaming through an image. Can you please give an example for that.
Also I tried following plz have a look into it:
Magick::Image image;
image.subImage(3);
image.subRange(1);
I was trying to use the above methods to get the first scene from a mpg http://cid-7572e6fdaea4368b.skydrive.li ... ic/vid.mpg while using blob but it does not work like ("vid.mpg[0]")
I used the following code:
Code:
Code: Select all
int main(int argc,char * argv)
{
InitializeMagick(argv);
std::string path("C:\\Tests\\vid.mpg");
/** Passing [0] in the file name itself **/
Image *image1=new Image();
image1->read(path+"[0]");
image1->write("C:\\Tests\\SceneInName.jpeg");
delete(image1);
cout<<"Copying from image done.";
/** Asking to retrieve only first frame by using subRange **/
ifstream fl(path.c_str(), ios::in | IOS_IN_BINARY );
fl.seekg(0, ios::end );
size_t blobLen = fl.tellg();
unsigned char* blobData = new unsigned char[blobLen];
char* c=reinterpret_cast<char *>(blobData);
fl.seekg(0,ios::beg);
fl.read(c, blobLen);
fl.close();
// Construct Magick++ Blob
Blob blob(static_cast<const unsigned char*>(blobData), blobLen);
delete [] blobData;
image1=new Magick::Image();
image1->subImage(3);
image1->subRange(1);
image1->magick("MPG");
image1->read( blob);
image1->write("C:\\Tests\\SceneInSubRange.jpeg");
delete(image1);
cout<<"Copying from Bytes done.";
}
Though I only get the first scene by both methods but that happens even if I don't use [0] OR subImage() and subRange() methods at all.
But in first case (path+"[0]") the time taken is way less than during subImage(),subRange() methods which suggests that they are not doing the same thing.
How can we get the same effect as (path+"[0]") for the case where we want to read image from inside a file, from an offset other than zero, (i.e. in case of blobs)?