mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-27 06:08:21 +01:00
Add example code snippet for demux API
Change-Id: I4e9f32d030dd7f184e1cedf5b37f6f640ba4845e
This commit is contained in:
parent
5f557f3c1b
commit
38a91e990b
@ -8,7 +8,39 @@
|
||||
// Demux API.
|
||||
// Enables extraction of image and extended format data from WebP files.
|
||||
|
||||
// TODO(urvang): Add an example code snippet (similar to mux.h).
|
||||
// Code Example: Demuxing WebP data to extract all the frames, ICC profile
|
||||
// and EXIF/XMP metadata.
|
||||
//
|
||||
// WebPDemuxer* demux = WebPDemux(&webp_data);
|
||||
//
|
||||
// uint32_t width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH);
|
||||
// uint32_t height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT);
|
||||
// // ... (Get information about the features present in the WebP file).
|
||||
// uint32_t flags = WebPDemuxGetI(demux, WEBP_FF_FORMAT_FLAGS);
|
||||
//
|
||||
// // ... (Iterate over all frames).
|
||||
// WebPIterator iter;
|
||||
// if (WebPDemuxGetFrame(demux, 1, &iter)) {
|
||||
// do {
|
||||
// // ... (Consume 'iter'; e.g. Decode 'iter.fragment' with WebPDecode(),
|
||||
// // ... and get other frame properties like width, height, offsets etc.
|
||||
// // ... see 'struct WebPIterator' below for more info).
|
||||
// } while (WebPDemuxNextFrame(&iter));
|
||||
// WebPDemuxReleaseIterator(&iter);
|
||||
// }
|
||||
//
|
||||
// // ... (Extract metadata).
|
||||
// WebPChunkIterator chunk_iter;
|
||||
// if (flags & ICCP_FLAG) WebPDemuxGetChunk(demux, "ICCP", 1, &chunk_iter);
|
||||
// // ... (Consume the ICC profile in 'chunk_iter.chunk').
|
||||
// WebPDemuxReleaseChunkIterator(&chunk_iter);
|
||||
// if (flags & EXIF_FLAG) WebPDemuxGetChunk(demux, "EXIF", 1, &chunk_iter);
|
||||
// // ... (Consume the EXIF metadata in 'chunk_iter.chunk').
|
||||
// WebPDemuxReleaseChunkIterator(&chunk_iter);
|
||||
// if (flags & XMP_FLAG) WebPDemuxGetChunk(demux, "XMP ", 1, &chunk_iter);
|
||||
// // ... (Consume the XMP metadata in 'chunk_iter.chunk').
|
||||
// WebPDemuxReleaseChunkIterator(&chunk_iter);
|
||||
// WebPDemuxDelete(demux);
|
||||
|
||||
#ifndef WEBP_WEBP_DEMUX_H_
|
||||
#define WEBP_WEBP_DEMUX_H_
|
||||
@ -120,7 +152,8 @@ WEBP_EXTERN(int) WebPDemuxPrevFrame(WebPIterator* iter);
|
||||
WEBP_EXTERN(int) WebPDemuxSelectFragment(WebPIterator* iter, int fragment_num);
|
||||
|
||||
// Releases any memory associated with 'iter'.
|
||||
// Must be called before destroying the associated WebPDemuxer with
|
||||
// Must be called before any subsequent calls to WebPDemuxGetChunk() on the same
|
||||
// iter. Also, must be called before destroying the associated WebPDemuxer with
|
||||
// WebPDemuxDelete().
|
||||
WEBP_EXTERN(void) WebPDemuxReleaseIterator(WebPIterator* iter);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user