/* * Copyright 2023 Google LLC * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * * This file contains implementations of SkPixmap methods which require the CPU backend.
*/
bool SkPixmap::scalePixels(const SkPixmap& actualDst, const SkSamplingOptions& sampling) const { // We may need to tweak how we interpret these just a little below, so we make copies.
SkPixmap src = *this,
dst = actualDst;
// Can't do anthing with empty src or dst if (src.width() <= 0 || src.height() <= 0 ||
dst.width() <= 0 || dst.height() <= 0) { returnfalse;
}
// no scaling involved? if (src.width() == dst.width() && src.height() == dst.height()) { return src.readPixels(dst);
}
// If src and dst are both unpremul, we'll fake the source out to appear as if premul, // and mark the destination as opaque. This odd combination allows us to scale unpremul // pixels without ever premultiplying them (perhaps losing information in the color channels). // This is an idiosyncratic feature of scalePixels(), and is tested by scalepixels_unpremul GM. bool clampAsIfUnpremul = false; if (src.alphaType() == kUnpremul_SkAlphaType &&
dst.alphaType() == kUnpremul_SkAlphaType) {
src.reset(src.info().makeAlphaType(kPremul_SkAlphaType), src.addr(), src.rowBytes());
dst.reset(dst.info().makeAlphaType(kOpaque_SkAlphaType), dst.addr(), dst.rowBytes());
// We'll need to tell the image shader to clamp to [0,1] instead of the // usual [0,a] when using a bicubic scaling (kHigh_SkFilterQuality).
clampAsIfUnpremul = true;
}
SkBitmap bitmap; if (!bitmap.installPixels(src)) { returnfalse;
}
bitmap.setImmutable(); // Don't copy when we create an image.
¤ 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.0.25Bemerkung:
(vorverarbeitet am 2026-04-28)
¤
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.