Dear fellows,
Does anyone know how I convert a headerless image raw file into any format using IM ? I'm working with a "C" program which captured an image from a webcam. The resultant file has 640x480, 24-bits per pixel (size:921600 bytes). Note that this file has no header or pallete associated.
Any help much appreciated.
Thank you in advance,
Fabio Vaz.
Webcam Raw image
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: Webcam Raw image
If you can modify the C program, you can build the conversion into it using the MagickWand API.
Just edit this function into the program.
Once it works you should add some error checking just in case the Constitute or the Write fail.
If you can't change the program, you can use Imagemagick's convert program to do the file format conversion. Prefix your filename with "rgb:" to tell IM the structure of the file.
Pete
Just edit this function into the program.
Code: Select all
#include <wand/MagickWand.h>
void convert_webcam(unsigned char *image,char *fname)
{
MagickWand *mw;
MagickWandGenesis();
mw = NewMagickWand();
// transfer the raw image to a MagickWand
MagickConstituteImage(mw,640,480,"RGB",CharPixel,image);
// and use MagickWand to write it out in any format you like
MagickWriteImage(mw,fname);
mw = DestroyMagickWand(mw);
MagickWandTerminus();
}
If you can't change the program, you can use Imagemagick's convert program to do the file format conversion. Prefix your filename with "rgb:" to tell IM the structure of the file.
Code: Select all
convert -size 640x480 -depth 8 rgb:input_file output.png
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
See my message in this topic for a link to a zip of all the files.
Re: Webcam Raw image (SOLVED)
Pete,
It worked fine with imageMagick convert command you sent !!!!!!!! I'll try to work with the MagickWand APi now.
Thank you very very much for your help !
It worked fine with imageMagick convert command you sent !!!!!!!! I'll try to work with the MagickWand APi now.
Thank you very very much for your help !