aboutsummaryrefslogtreecommitdiffhomepage
path: root/docs/SkPixmap_Reference.bmh
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@skia.org>2018-03-16 11:34:15 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-16 18:11:35 +0000
commit681287eb67f13e12fbcca96e956dea77c2661583 (patch)
tree6722e6e7174d0eadbc49dddf6a6c022c25c6dc56 /docs/SkPixmap_Reference.bmh
parenta3c68df565ebeb1607cc5c5561b1cb416f36c2ad (diff)
more imageinfo text and warnings and cleanup
more imageinfo text rewrote many examples to fix newly exposed compiler warnings marked a couple of YUV method bodies as deprecated also cleaned up line endings to use the linux style R=bsalomon@google.com TBR=caryclark@google.com Docs-Preview: https://skia.org/?cl=112302 Bug: skia:6898 Change-Id: I89626a27353aa84526f9b9475d927bd0e9d8f0d5 Reviewed-on: https://skia-review.googlesource.com/112302 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Cary Clark <caryclark@google.com>
Diffstat (limited to 'docs/SkPixmap_Reference.bmh')
-rw-r--r--docs/SkPixmap_Reference.bmh42
1 files changed, 21 insertions, 21 deletions
diff --git a/docs/SkPixmap_Reference.bmh b/docs/SkPixmap_Reference.bmh
index 86d89e53d1..9ad87f0acc 100644
--- a/docs/SkPixmap_Reference.bmh
+++ b/docs/SkPixmap_Reference.bmh
@@ -467,8 +467,7 @@ color type: kAlpha_8_SkColorType
#In Image_Info_Access
#Line # returns Image_Info Alpha_Type ##
-Returns Alpha_Type, one of: kUnknown_SkAlphaType, kOpaque_SkAlphaType,
-kPremul_SkAlphaType, kUnpremul_SkAlphaType.
+Returns Alpha_Type, one of: #list_of_alpha_types#.
#Return Alpha_Type in Image_Info ##
@@ -491,11 +490,11 @@ alpha type: kPremul_SkAlphaType
#In Image_Info_Access
#Line # returns Image_Info Color_Space ##
-Returns Color_Space associated with Image_Info. The
+Returns Color_Space, the range of colors, associated with Image_Info. The
reference count of Color_Space is unchanged. The returned Color_Space is
immutable.
-#Return Color_Space, the range of colors, in Image_Info ##
+#Return Color_Space in Image_Info, or nullptr ##
#Example
#Description
@@ -1546,29 +1545,30 @@ pixels are treated as if they are linear, regardless of how they are encoded.
#Return true if pixels are copied to dstPixels ##
#Example
-#ToDo example doesn't do anything interesting since info colorSpace is nullptr ##
+#ToDo example doesn't do anything interesting since image doesn't have alpha ##
#Image 3
void draw(SkCanvas* canvas) {
- SkImageInfo info = SkImageInfo::MakeN32Premul(image->width(), image->height(),
- canvas->imageInfo().colorSpace() ? SkColorSpace::MakeSRGB() : nullptr);
+ SkImageInfo srgb = SkImageInfo::MakeS32(image->width(), image->height(),
+ kPremul_SkAlphaType);
+ SkImageInfo linear = srgb.makeColorSpace(srgb.colorSpace()->makeLinearGamma());
std::vector<int32_t> srcPixels;
- srcPixels.resize(image->height() * image->width() * 4);
- SkPixmap pixmap(info, (const void*) &srcPixels.front(), image->width() * 4);
+ size_t rowBytes = image->width() * 4;
+ srcPixels.resize(image->height() * rowBytes);
+ SkPixmap pixmap(srgb, (const void*) &srcPixels.front(), rowBytes);
image->readPixels(pixmap, 0, 0);
- SkTransferFunctionBehavior behavior = canvas->imageInfo().colorSpace() ?
- SkTransferFunctionBehavior::kRespect : SkTransferFunctionBehavior::kIgnore;
+ int offset = -64;
std::vector<int32_t> dstPixels;
- dstPixels.resize(image->height() * image->width() * 4);
- int offset = 0;
- for (auto behavior : { SkTransferFunctionBehavior::kRespect,
- SkTransferFunctionBehavior::kIgnore} ) {
- pixmap.readPixels(info, &dstPixels.front(), image->width() * 4, offset, 0, behavior);
- offset += 128;
+ dstPixels.resize(image->height() * rowBytes);
+ for (const auto& info : { srgb, linear } ) {
+ for (auto behavior : { SkTransferFunctionBehavior::kRespect,
+ SkTransferFunctionBehavior::kIgnore} ) {
+ pixmap.readPixels(info, &dstPixels.front(), rowBytes, 0, 0, behavior);
+ SkBitmap bitmap;
+ SkPixmap dstmap(info, &dstPixels.front(), rowBytes);
+ bitmap.installPixels(dstmap);
+ canvas->drawBitmap(bitmap, 0, offset += 64);
+ }
}
- SkBitmap bitmap;
- SkPixmap dstmap(info, &dstPixels.front(), image->width() * 4);
- bitmap.installPixels(dstmap);
- canvas->drawBitmap(bitmap, 0, 0);
}
##