I am working in a c# warper for Advanced Encoder API with acess to encoder parameters and the new Near lossless encoding. But i do not know well the C languaje
I have several questions. I copy the C code and coment the questions in red colour:
#include "webp/encode.h"
WebPConfig config;
WebPConfigInitInternal(&config, WEBP_DECODER_ABI_VERSION);
// I need call to this function. I dont find documentation about this use.
//
WebPConfigInitInternal
allocate the memory for config variable?
// I think that not, because I don't found one funcion for
free their memory,
I'm not sure
if (!WebPConfigPreset(&config, WEBP_PRESET_PHOTO, quality_factor)) return 0;
config.sns_strength = 90;
config.filter_sharpness = 6;
config.alpha_quality = 90;
config_error = WebPValidateConfig(&config);
WebPPicture pic;
if (!WebPPictureInit(&pic)) return 0;
//
WebPPictureInit
allocate the memory for
pic struct
?
// I think that not, but
I'm not sure
pic.width = width;
pic.height = height;
if (!WebPPictureAllocate(&pic)) return 0;
if (!
WebPPictureImportBGR(&pic, bmpData.Scan0, bmpData.Stride)
return 0;
//
bmpData.Scan0
is the pointer to BGR values.
bmpData.Stride is stride value of BGR lines
WebPMemoryWriter writer;
//
WebPMemoryWriter
allocate the memory for
writer
variable?
// I think that not, but
I'm not sure
WebPMemoryWriterInit(&writer);
pic.writer = WebPMemoryWrite;
//
pic.writer = the pointer to function
WebPMemoryWrite (delegate in c#)?
//
pic.writer = 1 if i want use
WebPMemoryWrite?
pic.custom_ptr = &writer;
int ok = WebPEncode(&config, &pic);
WebPPictureFree(&pic);
if (!ok) {
printf("Encoding error: %d\n", pic.error_code);
} else {
printf("Output size: %d\n", writer.size);
}
I`ll put here the fullcode and examples when work.
Thanks in advance.