teasame / webp

Automatically exported from code.google.com/p/webp
0 stars 0 forks source link

Encoding implementation does not generate webp file. #88

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use source as reference: examples/cwebp.c to save .webp as file.
2. Loaded a WebPPicture from a bitmap data. (can DumpPicture to pgm ok)
3. Added relevant sections to Encode and save the output file.

What is the expected output? What do you see instead?
I want to generate a .webp image file just like the cwebp command does.
The file writer creates a new file but it is empty.

What version of the product are you using? On what operating system?
Lib version: 0.1.2
OS: Windows 7 Home
Env: Visual Studio 2010.

Please provide any additional information below.

I realize this isn't likely a bug but my misunderstanding. I don't know where 
to get help.

regarding these lines

File: examples/cwebp.c
889     picture.writer = MyWriter;
890     picture.custom_ptr = (void*)out;

917   if (!WebPEncode(&config, &picture)) {

930     DumpPicture(&picture, dump_file);

I can create a pgm file from my WebPPicture using DumpPicture, That works but I 
don't understand how to save the webp file. I don't see where the code actually 
invokes the MyWriter function with data. Where is the data stored?

If WebPPicture picture is a data structure and we set writer and custom_ptr, 
who is supposed to fwrite to the file?

Perhaps someone could point me to a relevant section of the code an I can 
figure it out.

Also I am not calling: WebPPictureCrop, WebPPictureRescale.

I would really appreciate any input on this,
Thanks
Jon Taylor 

Original issue reported on code.google.com by JonDTay...@gmail.com on 8 Aug 2011 at 5:48

GoogleCodeExporter commented 9 years ago
the 'picture.writer' function is called during the main call to WebPEncode().
Each time some compressed bytes need to be output, stored, etc., this hook is 
called,
but pointers to the data, as well as user-defined opaque pointer 'custom_ptr'.

In cwebp, this custom_ptr is just the handle to the FILE we stored data in. But 
it could be any other data.

Did you check there was no encoding errors (returned by WebPEncode())? In such 
occurrence, no bytes may have been output.

I'd recommend simply putting a 'printf("Hello world!");" in your custom writer, 
just to be sure the hook is called at all...

Original comment by pascal.m...@gmail.com on 11 Aug 2011 at 6:31

GoogleCodeExporter commented 9 years ago
Perfect. That's exactly what I was looking for.
Thanks

Original comment by JonDTay...@gmail.com on 12 Aug 2011 at 6:49

GoogleCodeExporter commented 9 years ago
This appears to have been resolved. If an issue still remains, feel free to 
re-open this bug.

Original comment by jz...@google.com on 1 Sep 2011 at 1:46