Page 1 of 1

how to write into filehandle

Posted: 2009-03-03T06:27:57-07:00
by dheeraj
Hi,

I want to write image into a FILE * fp from ImageInfo structure where FILE *file containd the image stram ;
I tried like
size_t size;
char * output;

FILE *output_file = open_memstream(output, &size);

images->file = output_file;
WriteImage(image_info,images);

but i got compilation error like there is Image does no have any member named as file

could you plz suggest how would I write image to a filehandle

Thanks in advance
Dheeraj

Re: how to write into filehandle

Posted: 2009-03-03T07:44:42-07:00
by magick
Assign your file descriptor to the ImageInfo structure rather than the Image structure (e.g. image_info->file = file).

Re: how to write into filehandle

Posted: 2009-03-03T21:25:16-07:00
by dheeraj
I think in WriteImage function it reads from ImageInfo structure and wtites to Image stucture
please suggest if I am wrong
so the problem is i want to write to file discriptor and Image stucture does not have any member of "FILE *" type,
Are there some other APIs where I can write to file descriptor or can I modify this WriteImage function?

Re: how to write into filehandle

Posted: 2009-03-03T23:49:12-07:00
by dheeraj
magick wrote:Assign your file descriptor to the ImageInfo structure rather than the Image structure (e.g. image_info->file = file).
As ImageInfo->file member has been initialised with input file
wont it overwrite the same ?

Pls see the code below - and confim if this is what you suggest:

image_info->file = fmemopen(input, input_len, "r");
images=ReadImage(image_info,exception);

FILE *output_file = open_memstream(output, &size);
image_info->file = output_file;
WriteImage(image_info,thumbnails);

In this case what is the sigbnificance of 2nd paramter -thumbnails?