/* * Copyright 2010 The Android Open Source Project * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file.
*/
extern"C" { // If moving libwebp out of skia source tree, path for webp headers must be // updated accordingly. Here, we enforce using local copy in webp sub-directory. #include"webp/encode.h"// NO_G3_REWRITE #include"webp/mux.h"// NO_G3_REWRITE #include"webp/mux_types.h"// NO_G3_REWRITE
}
if (SkColorTypeIsAlphaOnly(pixmap.colorType())) { // Maintain the existing behavior of not supporting encoding alpha-only images. // TODO: Support encoding alpha only to an image with alpha but no color? returnfalse;
}
// Set compression, method, and pixel format. // libwebp recommends using BGRA for lossless and YUV for lossy. // The choices of |webp_config.method| currently just match Chrome's defaults. We // could potentially expose this decision to the client. if (SkWebpEncoder::Compression::kLossy == opts.fCompression) {
webp_config->lossless = 0; #ifndef SK_WEBP_ENCODER_USE_DEFAULT_METHOD
webp_config->method = 3; #endif
pic->use_argb = 0;
} else {
webp_config->lossless = 1;
webp_config->method = 0;
pic->use_argb = 1;
}
WebPConfig webp_config; if (!WebPConfigPreset(&webp_config, WEBP_PRESET_DEFAULT, opts.fQuality)) { returnfalse;
}
WebPPicture pic; if (!WebPPictureInit(&pic)) { returnfalse;
}
SkAutoTCallVProc<WebPPicture, WebPPictureFree> autoPic(&pic);
if (!preprocess_webp_picture(&pic, &webp_config, pixmap, opts)) { returnfalse;
}
// If there is no need to embed an ICC profile, we write directly to the input stream. // Otherwise, we will first encode to |tmp| and use a mux to add the ICC chunk. libwebp // forces us to have an encoded image before we can add a profile.
sk_sp<SkData> icc =
icc_from_color_space(pixmap.info(), opts.fICCProfile, opts.fICCProfileDescription);
SkDynamicMemoryWStream tmp;
pic.custom_ptr = icc ? (void*)&tmp : (void*)stream;
pic.writer = stream_writer;
if (!WebPEncode(&webp_config, &pic)) { returnfalse;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.