
/ \\/ \/ _ \/ _ )/ _ \
\ / __/ _ \ __/
\__\__/\____/\_____/__/ ____ ___
/ _/ / \ \ / _ \/ _/
/ \_/ / / \ \ __/ \__
\____/____/\_____/_____/____/v1.0.2
WebPコーデック:WebP形式で画像をエンコード・デコードするためのライブラリ。このパッケージには、他のプログラムでWebPサポートを追加するために使用できるライブラリと、コマンドラインツール 'cwebp' および 'dwebp' が含まれています。
詳細:http://developers.google.com/speed/webp
最新のソースツリーは以下から入手可能です: https://chromium.googlesource.com/webm/libwebp
これはWebMプロジェクトと同じライセンスで公開されています。ライセンスの詳細については、http://www.webmproject.org/license/software/ または "COPYING" ファイルを参照してください。追加の知的財産権の付与は PATENTS ファイルに記載されています。
以下を実行:
nmake /f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output
これにより、ディレクトリ output\release-static(x64|x86)\bin にツール cwebp.exe および dwebp.exe が生成されます。ディレクトリ output\release-static(x64|x86)\lib には libwebp 静的ライブラリが含まれます。ターゲットアーキテクチャ(x86/x64)は、システムパスにあるVisual Studioコンパイラ(cl.exe)から Makefile.vc によって検出されます。
GNUツール(gcc および make)がインストールされているプラットフォームでは、以下を実行:
make -f makefile.unix
これにより、バイナリ examples/cwebp および examples/dwebp と、静的ライブラリ src/libwebp.a がビルドされます。システム全体へのインストールは提供されていません。これは、autoconf ツールに基づく完全なインストールシステム(下記参照)の簡単な代替手段です。追加の詳細とカスタマイズについては makefile.unix を参照してください。
前提条件: コンパイラ(例:gcc)、make、autoconf、automake、libtool。 Debian系システムでは、以下で最小限のビルドに必要なものがインストールされます: $ sudo apt-get install gcc make autoconf automake libtool
git ソースからビルドする場合、autogen.sh を実行して configure スクリプトを生成する必要があります。
./configure make make install
以上で、以下のファイルがインストールされるはずです:
/usr/local/include/webp/decode.h /usr/local/include/webp/encode.h /usr/local/include/webp/types.h /usr/local/lib/libwebp.* /usr/local/bin/cwebp /usr/local/bin/dwebp
注意:デコード専用ライブラリ libwebpdecoder は、'--enable-libwebpdecoder' フラグを使用して利用可能です。エンコードライブラリは別途ビルドされ、対応する Makefile.am configure ファイルに小さな変更を加えることで独立してインストールできます(コメントを参照)。詳細は './configure --help' を参照してください。
MIPS Linux ツールチェーンの安定版リリースは以下で入手可能: https://community.imgtec.com/developers/mips/tools/codescape-mips-sdk/available-releases/
export PATH=$PATH:/path/to/toolchain/bin
HOST=mips-mti-linux-gnu
MIPS_CFLAGS="-O3 -mips32r5 -mabi=32 -mtune=p5600 -mmsa -mfp64
-msched-weight -mload-store-pairs -fPIE"
MIPS_LDFLAGS="-mips32r5 -mabi=32 -mmsa -mfp64 -pie"
HOST=mips-img-linux-gnu
MIPS_CFLAGS="-O3 -mips64r6 -mabi=64 -mtune=i6400 -mmsa -mfp64
-msched-weight -mload-store-pairs -fPIE"
MIPS_LDFLAGS="-mips64r6 -mabi=64 -mmsa -mfp64 -pie"
./configure --host=${HOST} --build=config.guess
CC="${HOST}-gcc -EL"
CFLAGS="$MIPS_CFLAGS"
LDFLAGS="$MIPS_LDFLAGS"
make
make install
CMake を使用すると、libwebp、cwebp、dwebp、gif2webp、img2webp、webpinfo、および JS バインディングをコンパイルできます。
前提条件: コンパイラ(例:autotools 付き gcc)と CMake。 Debian系システムでは、以下で最小限のビルドに必要なものがインストールされます: $ sudo apt-get install build-essential cmake
git ソースからビルドする場合、cmake を実行して makefile を生成する必要があります。
mkdir build && cd build && cmake ../ make make install
実行ファイルも必要な場合は、CMake で有効にする必要があります。例:
cmake -DWEBP_BUILD_CWEBP=ON -DWEBP_BUILD_DWEBP=ON ../
または、お好みのインターフェース(ccmake や cmake-qt-gui など)を使用してください。
Windows での Unicode サポートには、オプション -DWEBP_UNICODE=ON を使用します(chcp 65001 と併用)。
最後に、インストール後、CMake プロジェクトで WebP を次のように使用できます:
find_package(WebP)
これにより、CMake 変数 WebP_INCLUDE_DIRS および WebP_LIBRARIES が定義されます。
Gradle のサポートは最小限で、libwebp、cwebp、dwebp、webpmux_example のコンパイルのみを支援します。
前提条件: コンパイラ(例:autotools 付き gcc)と gradle。 Debian系システムでは、以下で最小限のビルドに必要なものがインストールされます: $ sudo apt-get install build-essential gradle
git ソースからビルドする場合、適切なターゲットで Gradle ラッパーを実行する必要があります。例:
./gradlew buildAllExecutables
swig/libwebp.swig から言語バインディングを生成するには、少なくとも swig-1.3 (http://www.swig.org) が必要です。
現在、以下の関数がマッピングされています: デコード: WebPGetDecoderVersion WebPGetInfo WebPDecodeRGBA WebPDecodeARGB WebPDecodeBGRA WebPDecodeBGR WebPDecodeRGB
エンコード: WebPGetEncoderVersion WebPEncodeRGBA WebPEncodeBGRA WebPEncodeRGB WebPEncodeBGR WebPEncodeLosslessRGBA WebPEncodeLosslessBGRA WebPEncodeLosslessRGB WebPEncodeLosslessBGR
より詳細なビルド手順については、swig/README を参照してください。
Java バインディング:
swig で生成された JNI ラッパーコードをビルドするには、enum サポートのために少なくとも JDK-1.5(または同等)が必要です。出力は、System.loadLibrary("webp_jni") でロードできる共有オブジェクト / DLL を意図しています。
Python バインディング:
swig で生成された Python 拡張コードをビルドするには、少なくとも Python 2.6 が必要です。Python < 2.6 でも、libwebp.swig または生成されたコードに軽微な変更を加えればビルドできる可能性がありますが、未テストです。
examples/ ディレクトリには、画像をエンコードするためのツール(cwebp)とデコードするためのツール(dwebp)が含まれています。
最も簡単な使用法は以下のようになります: cwebp input.png -q 80 -o output.webp これは、入力ファイルを品質係数 80(0~100 のスケール、0 は最低品質、100 は最高品質、デフォルトは 75)で WebP ファイルに変換します。 -lossless フラグも試してみてください。これはソース(RGBA 形式)を無損失で圧縮します。この場合、-q 品質パラメータは、出力ファイルをできるだけ小さくするために費やす処理時間を制御します。
より長いオプションリストは、-longhelp コマンドラインフラグで表示できます:
cwebp -longhelp Usage: cwebp [-preset <...>] [options] in_file [-o out_file]
If input size (-s) for an image is not specified, it is assumed to be a PNG, JPEG, TIFF or WebP file.
Options: -h / -help ............. short help -H / -longhelp ......... long help -q ............. quality factor (0:small..100:big), default=75 -alpha_q ......... transparency-compression quality (0..100), default=100 -preset ....... preset setting, one of: default, photo, picture, drawing, icon, text -preset must come first, as it overwrites other parameters -z ............... activates lossless preset with given level in [0:fast, ..., 9:slowest]
-m ............... compression method (0=fast, 6=slowest), default=4 -segments ........ number of segments to use (1..4), default=4 -size ............ target size (in bytes) -psnr .......... target PSNR (in dB. typically: 42)
-s ......... input size (width x height) for YUV -sns ............. spatial noise shaping (0:off, 100:max), default=50 -f ............... filter strength (0=off..100), default=60 -sharpness ....... filter sharpness (0:most .. 7:least sharp), default=0 -strong ................ use strong filter instead of simple (default) -nostrong .............. use simple filter instead of strong -sharp_yuv ............. use sharper (and slower) RGB->YUV conversion -partition_limit . limit quality to fit the 512k limit on the first partition (0=no degradation ... 100=full) -pass ............ analysis pass number (1..10) -crop .. crop picture with the given rectangle -resize ........ resize picture (after any cropping) -mt .................... use multi-threading if available -low_memory ............ reduce memory usage (slower encoding) -map ............. print map of extra info -print_psnr ............ prints averaged PSNR distortion -print_ssim ............ prints averaged SSIM distortion -print_lsim ............ prints local-similarity distortion -d <file.pgm> .......... dump the compressed output (PGM file) -alpha_method .... transparency-compression method (0..1), default=1 -alpha_filter . predictive filtering for alpha plane, one of: none, fast (default) or best -exact ................. preserve RGB values in transparent area, default=off -blend_alpha ..... blend colors against background color expressed as RGB values written in hexadecimal, e.g. 0xc0e0d0 for red=0xc0 green=0xe0 and blue=0xd0 -noalpha ............... discard any transparency information -lossless .............. encode image losslessly, default=off -near_lossless ... use near-lossless image preprocessing (0..100=off), default=100 -hint ......... specify image characteristics hint, one of: photo, picture or graph
-metadata ..... comma separated list of metadata to copy from the input to the output if present. Valid values: all, none (default), exif, icc, xmp
-short ................. condense printed message -quiet ................. don't print anything -version ............... print version number and exit -noasm ................. disable all assembly optimizations -v ..................... verbose, e.g. print encoding/decoding times -progress .............. report encoding progress
Experimental Options: -jpeg_like ............. roughly match expected JPEG size -af .................... auto-adjust filter strength -pre ............. pre-processing filter
視覚品質をさらに調整するために試してみたい主なオプションは次のとおりです: -preset -sns -f -m
具体的には:
examples/dwebp.c にデコードサンプルがあり、.webp ファイルを PNG 画像ファイル(その他の形式も可能)にデコードします。これは API の使用法を示すためのものです。次のようにして、test.webp ファイルが test_ref.ppm と完全に一致することを確認できます:
cd examples ./dwebp test.webp -ppm -o test.ppm diff test.ppm test_ref.ppm
オプションの完全なリストは -h で表示できます:
dwebp -h Usage: dwebp in_file [options] [-o out_file]
Decodes the WebP image file to PNG format [Default] Use following options to convert into alternate image formats: -pam ......... save the raw RGBA samples as a color PAM -ppm ......... save the raw RGB samples as a color PPM -bmp ......... save as uncompressed BMP format -tiff ........ save as uncompressed TIFF format -pgm ......... save the raw YUV samples as a grayscale PGM file with IMC4 layout -yuv ......... save the raw YUV samples in flat layout
Other options are: -version ..... print version number and exit -nofancy ..... don't use the fancy YUV420 upscaler -nofilter .... disable in-loop filtering -nodither .... disable dithering -dither .. dithering strength (in 0..100) -alpha_dither use alpha-plane dithering if needed -mt .......... use multi-threading -crop ... crop output with the given rectangle -resize ......... scale the output (after any cropping) -flip ........ flip the output vertically -alpha ....... only save the alpha plane -incremental . use incremental decoding (useful for tests) -h ........... this help message -v ........... verbose (e.g. print encoding/decoding times) -quiet ....... quiet mode, don't print anything -noasm ....... disable all assembly optimizations
'webpinfo' を使用すると、WebP ファイルのチャンクレベルの構造とビットストリームヘッダー情報を出力できます。また、ファイルが有効な WebP 形式かどうかを確認することもできます。
使用法: webpinfo [options] in_files 注:複数の入力ファイルが可能です。オプションは入力ファイルの前に指定する必要があります。 オプション: -version ........... Print version number and exit. -quiet ............. Do not show chunk parsing information. -diag .............. Show parsing error diagnosis. -summary ........... Show chunk stats summary. -bitstream_info .... Parse bitstream header.
examples/ ディレクトリの下に、'vwebp' という簡単なセルフサービスの可視化ツールがあります。OpenGL を使用してシンプルな描画ウィンドウを開き、デコードした WebP ファイルを表示します。これは automake ビルドシステムにはまだ統合されていませんが、以下の推奨事項に従って手動でコンパイルしてみることができます。
使用法: vwebp in_file [options]
WebP 画像ファイルをデコードし、OpenGL を使用して可視化します。 オプション: -version ..... print version number and exit -noicc ....... don't use the icc profile if present -nofancy ..... don't use the fancy YUV420 upscaler -nofilter .... disable in-loop filtering -dither dithering strength (0..100), default=50 -noalphadither disable alpha plane dithering -usebgcolor .. display background color -mt .......... use multi-threading -info ........ print info -h ........... this help message
キーボードショートカット: 'c' ................ カラープロファイルの使用を切り替え 'b' ................ 背景色の表示を切り替え 'i' ................ ファイル情報をオーバーレイ 'd' ................ ブレンドと廃棄を無効化(デバッグ) 'q' / 'Q' / ESC .... 終了
前提条件:
2)(省略可能)qcms (Quick Color Management System) i. Mozilla / Chromium から qcms をダウンロード: http://hg.mozilla.org/mozilla-central/file/0e7639e3bdfb/gfx/qcms http://src.chromium.org/viewvc/chrome/trunk/src/third_party/qcms ii. ソースファイルをビルドし、libqcms.a / qcms.lib としてアーカイブ iii. makefile.unix / Makefile.vc を更新 a) WEBP_HAVE_QCMS を定義 b) qcms ディレクトリを参照するようにインクルード/ライブラリパスを更新
makefile.unix / Makefile.vc を使用してビルド: $ make -f makefile.unix examples/vwebp
nmake /f Makefile.vc CFG=release-static
../obj/x64/release-static/bin/vwebp.exe
'img2webp' ユーティリティは、一連の入力画像(PNG、JPEG など)をアニメーション WebP ファイルに変換できます。持続時間、エンコードモードなどを細かく制御できます。
使用法:
img2webp [file-level options] [image files...] [per-frame options...]
ファイルレベルオプション(圧縮開始時のみ使用): -min_size ............ サイズを最小化 -loop .......... ループ回数(デフォルト:0 = 無限ループ) -kmax .......... キーフレーム間の最大フレーム数 (0=キーフレームのみ) -kmin .......... キーフレーム間の最小フレーム数 (0=キーフレームを完全に無効化) -mixed ............... 損失あり/損失なしの自動モードを併用 -v ................... 詳細モード -h ................... このヘルプ -version ............. バージョン番号を表示して終了
フレームごとのオプション(後続の入力画像にのみ使用): -d ............. フレーム持続時間(ミリ秒、デフォルト:100) -lossless ........... 損失なしモードを使用(デフォルト) -lossy ... ........... 損失ありモードを使用 -q ........... 品質 -m ............. 使用するメソッド
例: img2webp -loop 2 in0.png -lossy in1.jpg -d 80 in2.tiff -o out.webp
注:引数としてファイル名が1つだけ渡された場合、そのファイルから引数がトークン化されます。ファイル名は文字 '-' で始まってはいけません。
アニメーション GIF ファイルは、examples/ にある gif2webp ユーティリティを使用してアニメーション WebP ファイルに変換できます。変換後のファイルは vwebp で表示できます。
使用法: gif2webp [options] gif_file -o webp_file オプション: -h / -help ............. このヘルプ -lossy ................. 損失あり圧縮を使用して画像をエンコード -mixed ................. 画像の各フレームに対して、損失ありまたは損失なし圧縮をヒューリスティックに選択 -q ............. 品質係数 (0:小さい..100:大きい) -m ............... 圧縮メソッド (0=高速, 6=低速) -min_size .............. 出力サイズを最小化 (デフォルト: off) デフォルトでは損失なし圧縮; -q, -m, -lossy または -mixed オプションと組み合わせ可能 -kmin ............ キーフレーム間の最小距離 -kmax ............ キーフレーム間の最大距離 -f ............... フィルタ強度 (0=off..100) -metadata ..... 入力から出力にコピーするメタデータのカンマ区切りリスト(存在する場合) 有効な値: all, none, icc, xmp (デフォルト) -loop_compatibility .... M62以前のChromeとの互換モードを使用(M62を含む) -mt .................... マルチスレッドが利用可能な場合に使用
-version ............... バージョン番号を表示して終了 -v ..................... 詳細 -quiet ................. 何も表示しない
libgif 開発ファイルがインストールされていれば、gif2webp は makefile.unix を使用してビルドできます: $ make -f makefile.unix examples/gif2webp
または autoconf を使用: $ ./configure --enable-everything $ make
examples/ の下にあるテストユーティリティ anim_diff を使用して、2つのアニメーション画像(それぞれ GIF または WebP にできます)を比較できます。使い方: anim_diff [オプション]
オプション: -dump_frames デコードしたフレームをPAM形式でダンプ -min_psnr ... フレームごとの最小PSNR -raw_comparison ..... このフラグを使用しない場合、比較の前にRGBを 事前乗算します -max_diff ..... 後続のフレームの対応するピクセル間における チャンネルごとの最大許容差 -h .................. このヘルプ -version ............ バージョン番号を表示して終了
libgifの開発ファイルとC++コンパイラがインストールされていれば、anim_diffはmakefile.unixを使ってビルドできます: $ make -f makefile.unix examples/anim_diff
またはautoconfを使う場合: $ ./configure --enable-everything $ make
主要なエンコード関数はヘッダファイル src/webp/encode.h で利用可能です。 すぐに使えるものは以下の通りです: size_t WebPEncodeRGB(const uint8_t* rgb, int width, int height, int stride, float quality_factor, uint8_t** output); size_t WebPEncodeBGR(const uint8_t* bgr, int width, int height, int stride, float quality_factor, uint8_t** output); size_t WebPEncodeRGBA(const uint8_t* rgba, int width, int height, int stride, float quality_factor, uint8_t** output); size_t WebPEncodeBGRA(const uint8_t* bgra, int width, int height, int stride, float quality_factor, uint8_t** output);
これらは生のRGBサンプルをWebPデータに変換します。提供される制御は品質係数のみです。
ロスレス形式を使用するためのいくつかの変種もあります:
size_t WebPEncodeLosslessRGB(const uint8_t* rgb, int width, int height, int stride, uint8_t** output); size_t WebPEncodeLosslessBGR(const uint8_t* bgr, int width, int height, int stride, uint8_t** output); size_t WebPEncodeLosslessRGBA(const uint8_t* rgba, int width, int height, int stride, uint8_t** output); size_t WebPEncodeLosslessBGRA(const uint8_t* bgra, int width, int height, int stride, uint8_t** output);
もちろんこの場合、入力値の損失なく圧縮が行われるため品質係数は不要ですが、その代わり出力サイズが大きくなります。
より高度なAPIは、WebPConfigおよびWebPPicture構造体に基づいています。
WebPConfigはエンコード設定を含み、特定の画像に結びつきません。 WebPPictureは入力データを含み、その画像に対して何らかのWebPConfigが圧縮に使用されます。 エンコードの流れは次のようになります:
-------------------------------------- 疑似例 開始
#include <webp/encode.h>
// プリセットから設定を作成し、追加パラメータを調整する WebPConfig config; if (!WebPConfigPreset(&config, WEBP_PRESET_PHOTO, quality_factor)) return 0; // バージョンエラー } // ... 追加の調整 config.sns_strength = 90; config.filter_sharpness = 6; config_error = WebPValidateConfig(&config); // 必須ではないが有用
// 入力データのセットアップ WebPPicture pic; if (!WebPPictureInit(&pic)) { return 0; // バージョンエラー } pic.width = width; pic.height = height; // width x height の画像を割り当てる if (!WebPPictureAllocate(&pic)) { return 0; // メモリエラー } // この時点で 'pic' はコンテナとして初期化されており、 // Y/U/V サンプルを受け取ることができる。 // または、WebPPictureImportRGB() のような既製のインポート関数を使うこともできる。 // その場合はメモリ割り当てが自動で行われる。 // いずれにせよ、この後はメモリ解放のために WebPPictureFree(&pic) を呼び出す必要がある。
// バイト出力の書き込みメソッドを設定する。例: WebPMemoryWriter WebPMemoryWriter wrt; WebPMemoryWriterInit(&wrt); // 'wrt' を初期化
pic.writer = MyFileWriter; pic.custom_ptr = my_opaque_structure_to_make_MyFileWriter_work;
// 圧縮! int ok = WebPEncode(&config, &pic); // ok = 0 => エラー発生! WebPPictureFree(&pic); // 'ok' の結果に関係なく必ず呼び出す。
// この時点で、出力データは writer によって処理されているはず。 // -> 圧縮データは wrt.mem / wrt.size で表されるメモリバッファ
// 圧縮データに使われたメモリを解放 WebPMemoryWriterClear(&wrt);
-------------------------------------- 疑似例 終了
基本的には、以下の1つの関数を呼び出すだけです:
#include "webp/decode.h" uint8_t* WebPDecodeRGB(const uint8_t* data, size_t data_size, int* width, int* height);
詳細は src/webp/decode.h ファイルを参照してください。 BGR/RGBA/ARGB/BGRA の順序でのデコードや、生の Y'CbCr サンプルへのデコードのための変種があります。また、事前に割り当てられたバッファに直接画像をデコードすることもできます。
WebPファイルを検出し、画像の寸法を取得するための関数: int WebPGetInfo(const uint8_t* data, size_t data_size, int* width, int* height); が用意されています。これを使用してもデコードは行われません。
データが徐々に転送される場合でも、もう少し複雑なAPIを使用して画像をインクリメンタルにデコードできます。デコーダの状態は WebPIDecoder オブジェクトのインスタンスに保存されます。このオブジェクトは、RGB または Y'CbCr サンプルのいずれかをデコードする目的で作成できます。例えば:
WebPDecBuffer buffer; WebPInitDecBuffer(&buffer); buffer.colorspace = MODE_BGR; ... WebPIDecoder* idec = WebPINewDecoder(&buffer);
データが徐々に利用可能になるにつれて、このインクリメンタルデコーダオブジェクトを使用して画像をさらにデコードできます。新しく到着したデータを渡す方法には2つ(相互排他的)あります:
新鮮なバイトを追加する方法:
WebPIAppend(idec, fresh_data, size_of_fresh_data);
または、転送されたデータの新しいサイズだけを指定する方法:
WebPIUpdate(idec, buffer, size_of_transmitted_buffer);
'buffer' は WebPIUpdate の呼び出しの間に変更できることに注意してください。特に、より大きなデータに対応するためにバッファのサイズが変更された場合です。
これらの関数はデコードステータスを返します: デコードがまだ完了していない場合は VP8_STATUS_SUSPENDED、デコードが完了した場合は VP8_STATUS_OK。その他のステータスはエラー状態です。
'idec' オブジェクトは(エラー状態でも)必ず WebPDelete(idec) を呼び出して解放する必要があります。
部分的にデコードされた画像サンプルを取得するには、対応するメソッド WebPIDecGetRGB または WebPIDecGetYUVA を使用します。最後に表示可能なピクセル行が返されます。
最後に、デコードは事前に割り当てられたピクセルバッファに対しても実行できます。このバッファは WebPIDecoder を作成する際に、WebPINewRGB() または WebPINewYUVA() を呼び出して渡す必要があります。
詳細については src/webp/decode.h ヘッダを参照してください。
WebPデコードは、オンザフライでのクロッピングとリサイズをサポートする高度なAPIを提供します。これは、モバイルフォンのようなメモリ制約のある環境で非常に有用です。基本的に、大きすぎる画像の簡単なプレビューや拡大部分のみが必要な場合、メモリ使用量は入力のサイズではなく出力のサイズに比例します。また、結果的にCPUも節約できます。
-------------------------------------- 疑似例 開始 // A) 設定オブジェクトを初期化 WebPDecoderConfig config; CHECK(WebPInitDecoderConfig(&config));
// B) オプション: ビットストリームの特徴を取得
CHECK(WebPGetFeatures(data, data_size, &config.input) == VP8_STATUS_OK);
// C) 必要に応じて 'config' オプションを調整
config.options.no_fancy_upsampling = 1;
config.options.use_scaling = 1;
config.options.scaled_width = scaledWidth();
config.options.scaled_height = scaledHeight();
// など
// D) 出力色空間を指定するために 'config' の出力オプションを設定
// オプションで外部画像デコードバッファも指定可能
config.output.colorspace = MODE_BGRA;
// オプションで、config.output を外部バッファにポイントしてデコードすることも可能
// この外部から提供されるメモリバッファは、デコードされた画像を格納するのに十分な大きさが必要
config.output.u.RGBA.rgba = (uint8_t*) memory_buffer;
config.output.u.RGBA.stride = scanline_stride;
config.output.u.RGBA.size = total_size_of_the_memory_buffer;
config.output.is_external_memory = 1;
// E) WebP画像をデコード。画像のデコード方法に関して2つのバリエーションがある
// 1つ目 (E.1) は完全な画像をデコードし、2つ目 (E.2) は小さな入力バッファを使って
// 画像をインクリメンタルにデコードするために使用される
// これらの手順のいずれかを使用してWebP画像をデコードできる
// E.1) 完全な画像をデコード
CHECK(WebPDecode(data, data_size, &config) == VP8_STATUS_OK);
// E.2) 画像をインクリメンタルにデコード
WebPIDecoder* const idec = WebPIDecode(NULL, NULL, &config);
CHECK(idec != NULL);
while (bytes_remaining > 0) {
VP8StatusCode status = WebPIAppend(idec, input, bytes_read);
if (status == VP8_STATUS_OK || status == VP8_STATUS_SUSPENDED) {
bytes_remaining -= bytes_read;
} else {
break;
}
}
WebPIDelete(idec);
// F) デコードされた画像は config.output (および config.output.u.RGBA) にある
// 保存、表示、またはその他の処理が可能
// G) configのオブジェクトで割り当てられたメモリを解放
// メモリが外部で、WebPDecode() によって割り当てられていなくても、
// この関数を呼び出しても安全
WebPFreeDecBuffer(&config.output);
-------------------------------------- 疑似例 終了
すべてのバグはイシュートラッカーに報告してください: https://bugs.chromium.org/p/webp パッチ歓迎! 開始するにはこのページを参照: http://www.webmproject.org/code/contribute/submitting-patches/
メール: [email protected] Web: http://groups.google.com/a/webmproject.org/group/webp-discuss