2017-09-14 15:25:39 +00:00
|
|
|
#Topic Pixmap
|
2018-05-30 13:21:49 +00:00
|
|
|
#Alias Pixmap_Reference ##
|
2017-09-15 06:56:12 +00:00
|
|
|
|
2017-09-14 15:25:39 +00:00
|
|
|
#Class SkPixmap
|
|
|
|
|
2018-10-08 18:57:48 +00:00
|
|
|
#Code
|
|
|
|
#Populate
|
|
|
|
##
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
Pixmap provides a utility to pair SkImageInfo with pixels and row bytes.
|
2017-09-14 15:25:39 +00:00
|
|
|
Pixmap is a low level class which provides convenience functions to access
|
|
|
|
raster destinations. Canvas can not draw Pixmap, nor does Pixmap provide
|
|
|
|
a direct drawing destination.
|
|
|
|
|
|
|
|
Use Bitmap to draw pixels referenced by Pixmap; use Surface to draw into
|
|
|
|
pixels referenced by Pixmap.
|
|
|
|
|
2017-10-04 18:31:33 +00:00
|
|
|
Pixmap does not try to manage the lifetime of the pixel memory. Use Pixel_Ref
|
|
|
|
to manage pixel memory; Pixel_Ref is safe across threads.
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
#Subtopic Initialization
|
2018-02-01 14:37:32 +00:00
|
|
|
#Line # sets fields for use ##
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method SkPixmap()
|
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Initialization
|
|
|
|
#Line # constructs with default values ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
void draw(SkCanvas* canvas) {
|
|
|
|
const char* alphas[] = {"Unknown", "Opaque", "Premul", "Unpremul"};
|
2018-01-30 15:08:57 +00:00
|
|
|
const char* colors[] = {"Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x",
|
|
|
|
"BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16"};
|
2017-09-21 16:31:06 +00:00
|
|
|
SkPixmap pixmap;
|
|
|
|
for (int i = 0; i < 2; ++i) {
|
|
|
|
SkDebugf("width: %2d height: %2d", pixmap.width(), pixmap.height());
|
|
|
|
SkDebugf(" color: k%s_SkColorType", colors[pixmap.colorType()]);
|
|
|
|
SkDebugf(" alpha: k%s_SkAlphaType\n", alphas[pixmap.alphaType()]);
|
|
|
|
pixmap.reset(SkImageInfo::Make(25, 35, kRGBA_8888_SkColorType, kOpaque_SkAlphaType),
|
|
|
|
nullptr, 0);
|
|
|
|
}
|
2017-09-14 15:25:39 +00:00
|
|
|
}
|
|
|
|
#StdOut
|
2017-09-21 16:31:06 +00:00
|
|
|
width: 0 height: 0 color: kUnknown_SkColorType alpha: kUnknown_SkAlphaType
|
2017-09-14 15:25:39 +00:00
|
|
|
width: 25 height: 35 color: kRGBA_8888_SkColorType alpha: kOpaque_SkAlphaType
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso SkPixmap(const SkImageInfo& info, const void* addr, size_t rowBytes) reset() SkAlphaType SkColorType
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method SkPixmap(const SkImageInfo& info, const void* addr, size_t rowBytes)
|
2018-05-16 11:07:07 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Initialization
|
|
|
|
#Line # constructs from Image_Info, pixels ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Image 3
|
|
|
|
#Description
|
2018-05-16 11:07:07 +00:00
|
|
|
SkImage::MakeRasterCopy takes const SkPixmap& as an argument. The example
|
2017-09-14 15:25:39 +00:00
|
|
|
constructs a SkPixmap from the brace-delimited parameters.
|
|
|
|
##
|
2017-09-21 16:31:06 +00:00
|
|
|
SkDebugf("image alpha only = %s\n", image->isAlphaOnly() ? "true" : "false");
|
|
|
|
SkPMColor pmColors = 0;
|
|
|
|
sk_sp<SkImage> copy = SkImage::MakeRasterCopy({SkImageInfo::MakeA8(1, 1),
|
|
|
|
(uint8_t*)&pmColors,
|
|
|
|
1});
|
2017-09-14 15:25:39 +00:00
|
|
|
SkDebugf("copy alpha only = %s\n", copy->isAlphaOnly() ? "true" : "false");
|
|
|
|
#StdOut
|
2017-09-21 16:31:06 +00:00
|
|
|
image alpha only = false
|
2017-09-14 15:25:39 +00:00
|
|
|
copy alpha only = true
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso SkPixmap() reset() SkAlphaType SkColorType
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method void reset()
|
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Initialization
|
|
|
|
#Line # reuses existing Pixmap with replacement values ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
void draw(SkCanvas* canvas) {
|
|
|
|
const char* alphas[] = {"Unknown", "Opaque", "Premul", "Unpremul"};
|
2018-01-30 15:08:57 +00:00
|
|
|
const char* colors[] = {"Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x",
|
|
|
|
"BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16"};
|
2017-09-21 16:31:06 +00:00
|
|
|
SkPixmap pixmap(SkImageInfo::Make(25, 35, kRGBA_8888_SkColorType, kOpaque_SkAlphaType),
|
|
|
|
nullptr, 0);
|
|
|
|
for (int i = 0; i < 2; ++i) {
|
|
|
|
SkDebugf("width: %2d height: %2d", pixmap.width(), pixmap.height());
|
|
|
|
SkDebugf(" color: k%s_SkColorType", colors[pixmap.colorType()]);
|
|
|
|
SkDebugf(" alpha: k%s_SkAlphaType\n", alphas[pixmap.alphaType()]);
|
|
|
|
pixmap.reset();
|
|
|
|
}
|
|
|
|
}
|
2017-09-14 15:25:39 +00:00
|
|
|
#StdOut
|
|
|
|
width: 25 height: 35 color: kRGBA_8888_SkColorType alpha: kOpaque_SkAlphaType
|
2017-09-21 16:31:06 +00:00
|
|
|
width: 0 height: 0 color: kUnknown_SkColorType alpha: kUnknown_SkAlphaType
|
2017-09-14 15:25:39 +00:00
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso SkPixmap() SkAlphaType SkColorType
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method void reset(const SkImageInfo& info, const void* addr, size_t rowBytes)
|
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Initialization
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Image 4
|
2017-11-02 21:49:34 +00:00
|
|
|
#Height 64
|
2017-09-21 16:31:06 +00:00
|
|
|
void draw(SkCanvas* canvas) {
|
|
|
|
std::vector<int32_t> pixels;
|
|
|
|
pixels.resize(image->height() * image->width() * 4);
|
|
|
|
SkPixmap pixmap(SkImageInfo::Make(image->width(), image->height(), kN32_SkColorType,
|
|
|
|
image->alphaType()), (const void*) &pixels.front(), image->width() * 4);
|
|
|
|
image->readPixels(pixmap, 0, 0);
|
|
|
|
int x = 0;
|
|
|
|
for (auto colorType : { kRGBA_8888_SkColorType, kBGRA_8888_SkColorType } ) {
|
2018-05-16 11:07:07 +00:00
|
|
|
pixmap.reset(SkImageInfo::Make(image->width(), image->height(), colorType,
|
2017-09-21 16:31:06 +00:00
|
|
|
image->alphaType()), (const void*) &pixels.front(), image->width() * 4);
|
|
|
|
SkBitmap bitmap;
|
|
|
|
bitmap.installPixels(pixmap);
|
|
|
|
canvas->drawBitmap(bitmap, x, 0);
|
|
|
|
x += 128;
|
|
|
|
}
|
2017-09-14 15:25:39 +00:00
|
|
|
}
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso SkPixmap(const SkImageInfo& info, const void* addr, size_t rowBytes) reset() SkAlphaType SkColorType
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method void setColorSpace(sk_sp<SkColorSpace> colorSpace)
|
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Initialization
|
|
|
|
#Line # sets Image_Info Color_Space ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
void draw(SkCanvas* canvas) {
|
|
|
|
SkPixmap pixmap;
|
|
|
|
sk_sp<SkColorSpace> colorSpace1 = SkColorSpace::MakeRGB(SkColorSpace::kLinear_RenderTargetGamma,
|
|
|
|
SkColorSpace::kRec2020_Gamut);
|
2018-05-16 11:07:07 +00:00
|
|
|
SkDebugf("is %sunique\n", colorSpace1->unique() ? "" : "not ");
|
2017-09-21 16:31:06 +00:00
|
|
|
pixmap.setColorSpace(colorSpace1);
|
2018-05-16 11:07:07 +00:00
|
|
|
SkDebugf("is %sunique\n", colorSpace1->unique() ? "" : "not ");
|
2017-09-14 15:25:39 +00:00
|
|
|
}
|
|
|
|
#StdOut
|
|
|
|
is unique
|
|
|
|
is not unique
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso Color_Space SkImageInfo::makeColorSpace
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-10-08 18:57:48 +00:00
|
|
|
#Method bool reset(const SkMask& mask)
|
2018-02-06 14:41:53 +00:00
|
|
|
#Deprecated soon
|
2017-09-14 15:25:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-10-08 18:57:48 +00:00
|
|
|
#Method bool extractSubset(SkPixmap* subset, const SkIRect& area) const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Initialization
|
|
|
|
#Line # sets pointer to portion of original ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Image 3
|
|
|
|
#Height 128
|
2017-09-21 16:31:06 +00:00
|
|
|
void draw(SkCanvas* canvas) {
|
|
|
|
std::vector<int32_t> pixels;
|
|
|
|
pixels.resize(image->height() * image->width() * 4);
|
|
|
|
SkPixmap pixmap(SkImageInfo::Make(image->width(), image->height(), kN32_SkColorType,
|
|
|
|
image->alphaType()), (const void*) &pixels.front(), image->width() * 4);
|
|
|
|
image->readPixels(pixmap, 0, 0);
|
|
|
|
SkPixmap inset;
|
|
|
|
if (pixmap.extractSubset(&inset, {128, 128, 512, 512})) {
|
|
|
|
SkBitmap bitmap;
|
|
|
|
bitmap.installPixels(inset);
|
|
|
|
canvas->drawBitmap(bitmap, 0, 0);
|
|
|
|
}
|
2017-09-14 15:25:39 +00:00
|
|
|
}
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso reset() SkIRect::intersect
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
#Subtopic Initialization ##
|
|
|
|
|
|
|
|
#Subtopic Image_Info_Access
|
2018-02-01 14:37:32 +00:00
|
|
|
#Line # returns all or part of Image_Info ##
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method const SkImageInfo& info() const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Image_Info_Access
|
|
|
|
#Line # returns Image_Info ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Image 3
|
2017-09-21 16:31:06 +00:00
|
|
|
std::vector<int32_t> pixels;
|
|
|
|
pixels.resize(image->height() * image->width() * 4);
|
|
|
|
SkPixmap pixmap(SkImageInfo::Make(image->width(), image->height(), kN32_SkColorType,
|
|
|
|
image->alphaType()), (const void*) &pixels.front(), image->width() * 4);
|
|
|
|
image->readPixels(pixmap, 0, 0);
|
|
|
|
SkPixmap inset;
|
|
|
|
if (pixmap.extractSubset(&inset, {128, 128, 512, 512})) {
|
|
|
|
const SkImageInfo& info = inset.info();
|
|
|
|
const char* alphas[] = {"Unknown", "Opaque", "Premul", "Unpremul"};
|
2018-01-30 15:08:57 +00:00
|
|
|
const char* colors[] = {"Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888",
|
|
|
|
"RGB_888x", "BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16"};
|
2017-09-21 16:31:06 +00:00
|
|
|
SkDebugf("width: %d height: %d color: %s alpha: %s\n", info.width(), info.height(),
|
|
|
|
colors[info.colorType()], alphas[info.alphaType()]);
|
|
|
|
}
|
|
|
|
#StdOut
|
|
|
|
width: 384 height: 384 color: BGRA_8888 alpha: Opaque
|
|
|
|
##
|
2017-09-14 15:25:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso Image_Info
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method size_t rowBytes() const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Image_Info_Access
|
|
|
|
#Line # returns interval between rows in bytes ##
|
2017-09-14 15:25:39 +00:00
|
|
|
Returns row bytes, the interval from one pixel row to the next. Row bytes
|
Condense embedded formulas.
Bookmaker delimits formulas and equations to allow
representing variables and symbols without tripping
up reference lookup, spell checking, and comment
generation.
Before, formulas were represented with:
some text
#Formula
(x + y, 0)
##
, and more text
This made it difficult to know when spacing should
be preserved before and after the formula. Now,
formulas are represented with:
some text #Formula # (x + y, 0) ##, and more text
The presence or absence of a space between ## and ,
is now significant (before it was not).
Also, formulas are bracketed by <code> in markdown
generation, so that variables stand out better.
See:
https://skia.org/user/api/SkBlendMode_Reference?cl=152781#Dst_Out
for an example.
Also fixed 100 column offenders and added a code
check to identify them. For the moment, 100 column
offenders are outed with SkDebugf but their presence
does not cause bookmaker to fail.
TBR=caryclark@google.com
Docs-Preview: https://skia.org/?cl=152781
Bug: skia:6898
Change-Id: If92a65a234f5d616bf4485984a8d219a6f04821a
Reviewed-on: https://skia-review.googlesource.com/152781
Commit-Queue: Cary Clark <caryclark@skia.org>
Auto-Submit: Cary Clark <caryclark@skia.org>
Reviewed-by: Cary Clark <caryclark@skia.org>
2018-09-13 16:04:30 +00:00
|
|
|
is at least as large as: #Formula # width() * info().bytesPerPixel() ##.
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2017-10-04 18:31:33 +00:00
|
|
|
Returns zero if colorType is kUnknown_SkColorType.
|
|
|
|
It is up to the Bitmap creator to ensure that row bytes is a useful value.
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Return byte length of pixel row ##
|
|
|
|
|
|
|
|
#Example
|
|
|
|
SkPixmap badPixmap = {SkImageInfo::MakeA8(4, 4), nullptr, 2};
|
|
|
|
SkPixmap okPixmap = {SkImageInfo::MakeA8(4, 4), nullptr, 8};
|
|
|
|
for (auto& pixmap : { badPixmap, okPixmap } ) {
|
2018-05-16 11:07:07 +00:00
|
|
|
SkDebugf("rowBytes: %d minRowBytes: %d\n", pixmap.rowBytes(),
|
2017-09-14 15:25:39 +00:00
|
|
|
pixmap.info().minRowBytes());
|
|
|
|
}
|
|
|
|
#StdOut
|
2017-09-21 16:31:06 +00:00
|
|
|
rowBytes: 2 minRowBytes: 4
|
2017-09-14 15:25:39 +00:00
|
|
|
rowBytes: 8 minRowBytes: 4
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso addr() info() SkImageInfo::minRowBytes
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method const void* addr() const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Image_Info_Access
|
|
|
|
#Line # returns readable pixel address as void pointer ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Image 3
|
2017-09-21 16:31:06 +00:00
|
|
|
std::vector<int32_t> pixels;
|
|
|
|
pixels.resize(image->height() * image->width() * 4);
|
|
|
|
SkPixmap pixmap(SkImageInfo::Make(image->width(), image->height(), kN32_SkColorType,
|
|
|
|
image->alphaType()), (const void*) &pixels.front(), image->width() * 4);
|
|
|
|
image->readPixels(pixmap, 0, 0);
|
|
|
|
SkDebugf("pixels address: 0x%llx\n", pixmap.addr());
|
|
|
|
SkPixmap inset;
|
|
|
|
if (pixmap.extractSubset(&inset, {128, 128, 512, 512})) {
|
|
|
|
SkDebugf("inset address: 0x%llx\n", inset.addr());
|
|
|
|
}
|
|
|
|
#StdOut
|
|
|
|
#Volatile
|
|
|
|
pixels address: 0x7f2a440bb010
|
|
|
|
inset address: 0x7f2a440fb210
|
|
|
|
##
|
2017-09-14 15:25:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso addr(int x, int y) addr8 addr16 addr32 addr64 info() rowBytes()
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method int width() const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Image_Info_Access
|
|
|
|
#Line # returns pixel column count ##
|
2017-09-14 15:25:39 +00:00
|
|
|
Returns pixel count in each pixel row. Should be equal or less than:
|
2017-10-26 11:58:48 +00:00
|
|
|
|
Condense embedded formulas.
Bookmaker delimits formulas and equations to allow
representing variables and symbols without tripping
up reference lookup, spell checking, and comment
generation.
Before, formulas were represented with:
some text
#Formula
(x + y, 0)
##
, and more text
This made it difficult to know when spacing should
be preserved before and after the formula. Now,
formulas are represented with:
some text #Formula # (x + y, 0) ##, and more text
The presence or absence of a space between ## and ,
is now significant (before it was not).
Also, formulas are bracketed by <code> in markdown
generation, so that variables stand out better.
See:
https://skia.org/user/api/SkBlendMode_Reference?cl=152781#Dst_Out
for an example.
Also fixed 100 column offenders and added a code
check to identify them. For the moment, 100 column
offenders are outed with SkDebugf but their presence
does not cause bookmaker to fail.
TBR=caryclark@google.com
Docs-Preview: https://skia.org/?cl=152781
Bug: skia:6898
Change-Id: If92a65a234f5d616bf4485984a8d219a6f04821a
Reviewed-on: https://skia-review.googlesource.com/152781
Commit-Queue: Cary Clark <caryclark@skia.org>
Auto-Submit: Cary Clark <caryclark@skia.org>
Reviewed-by: Cary Clark <caryclark@skia.org>
2018-09-13 16:04:30 +00:00
|
|
|
#Formula # rowBytes() / info().bytesPerPixel() ##.
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Return pixel width in Image_Info ##
|
|
|
|
|
|
|
|
#Example
|
|
|
|
SkImageInfo info = SkImageInfo::MakeA8(16, 32);
|
2017-09-21 16:31:06 +00:00
|
|
|
SkPixmap pixmap(info, nullptr, 64);
|
|
|
|
SkDebugf("pixmap width: %d info width: %d\n", pixmap.width(), info.width());
|
|
|
|
#StdOut
|
|
|
|
pixmap width: 16 info width: 16
|
|
|
|
##
|
2017-09-14 15:25:39 +00:00
|
|
|
##
|
|
|
|
|
2017-10-04 18:31:33 +00:00
|
|
|
#SeeAlso height() SkImageInfo::width()
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method int height() const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Image_Info_Access
|
|
|
|
#Line # returns pixel row count ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-10-04 18:31:33 +00:00
|
|
|
SkPixmap pixmap(SkImageInfo::MakeA8(16, 32), nullptr, 64);
|
|
|
|
SkDebugf("pixmap height: %d info height: %d\n", pixmap.height(), pixmap.info().height());
|
2017-09-21 16:31:06 +00:00
|
|
|
#StdOut
|
|
|
|
pixmap height: 32 info height: 32
|
|
|
|
##
|
2017-09-14 15:25:39 +00:00
|
|
|
##
|
|
|
|
|
2017-10-04 18:31:33 +00:00
|
|
|
#SeeAlso width() ImageInfo::height()
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method SkColorType colorType() const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Image_Info_Access
|
|
|
|
#Line # returns Image_Info Color_Type ##
|
2018-03-05 18:26:16 +00:00
|
|
|
Returns Color_Type, one of: #list_of_color_types#.
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Return Color_Type in Image_Info ##
|
|
|
|
|
|
|
|
#Example
|
2018-01-30 15:08:57 +00:00
|
|
|
const char* colors[] = {"Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x",
|
|
|
|
"BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16"};
|
2017-09-21 16:31:06 +00:00
|
|
|
SkPixmap pixmap(SkImageInfo::MakeA8(16, 32), nullptr, 64);
|
|
|
|
SkDebugf("color type: k" "%s" "_SkColorType\n", colors[pixmap.colorType()]);
|
|
|
|
#StdOut
|
2018-01-30 15:08:57 +00:00
|
|
|
color type: kAlpha_8_SkColorType
|
2017-09-21 16:31:06 +00:00
|
|
|
##
|
2017-09-14 15:25:39 +00:00
|
|
|
##
|
|
|
|
|
2017-10-04 18:31:33 +00:00
|
|
|
#SeeAlso alphaType() SkImageInfo::colorType
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method SkAlphaType alphaType() const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Image_Info_Access
|
|
|
|
#Line # returns Image_Info Alpha_Type ##
|
2018-03-16 15:34:15 +00:00
|
|
|
Returns Alpha_Type, one of: #list_of_alpha_types#.
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Return Alpha_Type in Image_Info ##
|
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
const char* alphas[] = {"Unknown", "Opaque", "Premul", "Unpremul"};
|
|
|
|
SkPixmap pixmap(SkImageInfo::MakeA8(16, 32), nullptr, 64);
|
|
|
|
SkDebugf("alpha type: k" "%s" "_SkAlphaType\n", alphas[pixmap.alphaType()]);
|
2017-09-14 15:25:39 +00:00
|
|
|
#StdOut
|
|
|
|
alpha type: kPremul_SkAlphaType
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
2017-10-04 18:31:33 +00:00
|
|
|
#SeeAlso colorType() SkImageInfo::alphaType
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method SkColorSpace* colorSpace() const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Image_Info_Access
|
|
|
|
#Line # returns Image_Info Color_Space ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Description
|
|
|
|
SkColorSpace::MakeSRGBLinear creates Color_Space with linear gamma
|
|
|
|
and an sRGB gamut. This Color_Space gamma is not close to sRGB gamma.
|
|
|
|
##
|
2018-05-16 11:07:07 +00:00
|
|
|
SkPixmap pixmap(SkImageInfo::MakeN32(16, 32, kPremul_SkAlphaType,
|
2017-09-21 16:31:06 +00:00
|
|
|
SkColorSpace::MakeSRGBLinear()), nullptr, 64);
|
|
|
|
SkColorSpace* colorSpace = pixmap.colorSpace();
|
|
|
|
SkDebugf("gammaCloseToSRGB: %s gammaIsLinear: %s isSRGB: %s\n",
|
|
|
|
colorSpace->gammaCloseToSRGB() ? "true" : "false",
|
|
|
|
colorSpace->gammaIsLinear() ? "true" : "false",
|
|
|
|
colorSpace->isSRGB() ? "true" : "false");
|
|
|
|
#StdOut
|
|
|
|
gammaCloseToSRGB: false gammaIsLinear: true isSRGB: false
|
|
|
|
##
|
2017-09-14 15:25:39 +00:00
|
|
|
##
|
|
|
|
|
2017-10-04 18:31:33 +00:00
|
|
|
#SeeAlso Color_Space SkImageInfo::colorSpace
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method bool isOpaque() const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Image_Info_Access
|
|
|
|
#Line # returns true if Image_Info describes opaque pixels ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Description
|
|
|
|
isOpaque ignores whether all pixels are opaque or not.
|
|
|
|
##
|
2017-09-21 16:31:06 +00:00
|
|
|
std::vector<uint32_t> pixels;
|
|
|
|
const int height = 2;
|
|
|
|
const int width = 2;
|
|
|
|
pixels.resize(height * width * 4);
|
|
|
|
SkPixmap pixmap(SkImageInfo::Make(width, height, kN32_SkColorType,
|
|
|
|
kPremul_SkAlphaType), (const void*) &pixels.front(), width * 4);
|
|
|
|
for (int index = 0; index < 2; ++index) {
|
|
|
|
pixmap.erase(0x00000000);
|
|
|
|
SkDebugf("isOpaque: %s\n", pixmap.isOpaque() ? "true" : "false");
|
|
|
|
pixmap.erase(0xFFFFFFFF);
|
|
|
|
SkDebugf("isOpaque: %s\n", pixmap.isOpaque() ? "true" : "false");
|
|
|
|
pixmap.reset(pixmap.info().makeAlphaType(kOpaque_SkAlphaType),
|
|
|
|
(const void*) &pixels.front(), width * 4);
|
|
|
|
}
|
2017-09-14 15:25:39 +00:00
|
|
|
#StdOut
|
2017-09-21 16:31:06 +00:00
|
|
|
isOpaque: false
|
|
|
|
isOpaque: false
|
|
|
|
isOpaque: true
|
2017-09-14 15:25:39 +00:00
|
|
|
isOpaque: true
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso computeIsOpaque SkImageInfo::isOpaque
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method SkIRect bounds() const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Image_Info_Access
|
|
|
|
#Line # returns width and height as Rectangle ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
for (int width : { 0, 2 } ) {
|
|
|
|
for (int height : { 0, 2 } ) {
|
2017-09-21 16:31:06 +00:00
|
|
|
SkPixmap pixmap(SkImageInfo::MakeA8(width, height), nullptr, width);
|
2017-09-14 15:25:39 +00:00
|
|
|
SkDebugf("width: %d height: %d empty: %s\n", width, height,
|
|
|
|
pixmap.bounds().isEmpty() ? "true" : "false");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#StdOut
|
2017-09-21 16:31:06 +00:00
|
|
|
width: 0 height: 0 empty: true
|
|
|
|
width: 0 height: 2 empty: true
|
|
|
|
width: 2 height: 0 empty: true
|
2017-09-14 15:25:39 +00:00
|
|
|
width: 2 height: 2 empty: false
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#SeeAlso height() width() IRect
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method int rowBytesAsPixels() const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Image_Info_Access
|
|
|
|
#Line # returns interval between rows in pixels ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
for (int rowBytes : { 4, 5, 6, 7, 8} ) {
|
|
|
|
SkPixmap pixmap(SkImageInfo::MakeN32(1, 1, kPremul_SkAlphaType), nullptr, rowBytes);
|
|
|
|
SkDebugf("rowBytes: %d rowBytesAsPixels: %d\n", rowBytes, pixmap.rowBytesAsPixels());
|
|
|
|
}
|
2017-09-14 15:25:39 +00:00
|
|
|
#StdOut
|
2017-09-21 16:31:06 +00:00
|
|
|
rowBytes: 4 rowBytesAsPixels: 1
|
|
|
|
rowBytes: 5 rowBytesAsPixels: 1
|
|
|
|
rowBytes: 6 rowBytesAsPixels: 1
|
|
|
|
rowBytes: 7 rowBytesAsPixels: 1
|
2017-09-14 15:25:39 +00:00
|
|
|
rowBytes: 8 rowBytesAsPixels: 2
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso rowBytes shiftPerPixel width SkImageInfo::bytesPerPixel
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method int shiftPerPixel() const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Image_Info_Access
|
|
|
|
#Line # returns bit shift from pixels to bytes ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2018-01-30 15:08:57 +00:00
|
|
|
const char* colors[] = {"Unknown", "Alpha_8", "RGB_565", "ARGB_4444", "RGBA_8888", "RGB_888x",
|
|
|
|
"BGRA_8888", "RGBA_1010102", "RGB_101010x", "Gray_8", "RGBA_F16"};
|
2017-09-21 16:31:06 +00:00
|
|
|
SkImageInfo info = SkImageInfo::MakeA8(1, 1);
|
|
|
|
for (SkColorType colorType : { kUnknown_SkColorType, kAlpha_8_SkColorType,
|
2018-05-16 11:07:07 +00:00
|
|
|
kRGB_565_SkColorType, kARGB_4444_SkColorType,
|
2017-09-21 16:31:06 +00:00
|
|
|
kRGBA_8888_SkColorType, kBGRA_8888_SkColorType,
|
|
|
|
kGray_8_SkColorType, kRGBA_F16_SkColorType } ) {
|
|
|
|
SkPixmap pixmap(info.makeColorType(colorType), nullptr, 4);
|
|
|
|
SkDebugf("color: k" "%s" "_SkColorType" "%*s" "bytesPerPixel: %d shiftPerPixel: %d\n",
|
|
|
|
colors[colorType], 10 - strlen(colors[colorType]), " ",
|
|
|
|
pixmap.info().bytesPerPixel(), pixmap.shiftPerPixel());
|
|
|
|
}
|
2017-09-14 15:25:39 +00:00
|
|
|
#StdOut
|
2017-09-21 16:31:06 +00:00
|
|
|
color: kUnknown_SkColorType bytesPerPixel: 0 shiftPerPixel: 0
|
2018-01-30 15:08:57 +00:00
|
|
|
color: kAlpha_8_SkColorType bytesPerPixel: 1 shiftPerPixel: 0
|
2017-09-21 16:31:06 +00:00
|
|
|
color: kRGB_565_SkColorType bytesPerPixel: 2 shiftPerPixel: 1
|
|
|
|
color: kARGB_4444_SkColorType bytesPerPixel: 2 shiftPerPixel: 1
|
|
|
|
color: kRGBA_8888_SkColorType bytesPerPixel: 4 shiftPerPixel: 2
|
|
|
|
color: kBGRA_8888_SkColorType bytesPerPixel: 4 shiftPerPixel: 2
|
|
|
|
color: kGray_8_SkColorType bytesPerPixel: 1 shiftPerPixel: 0
|
2017-09-14 15:25:39 +00:00
|
|
|
color: kRGBA_F16_SkColorType bytesPerPixel: 8 shiftPerPixel: 3
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso rowBytes rowBytesAsPixels width SkImageInfo::bytesPerPixel
|
|
|
|
|
|
|
|
##
|
|
|
|
|
2017-10-04 18:31:33 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method size_t computeByteSize() const
|
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Image_Info_Access
|
|
|
|
#Line # returns size required for pixels ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-10-04 18:31:33 +00:00
|
|
|
|
2017-09-14 15:25:39 +00:00
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
SkPixmap pixmap;
|
|
|
|
for (int width : { 1, 1000, 1000000 } ) {
|
|
|
|
for (int height: { 1, 1000, 1000000 } ) {
|
|
|
|
SkImageInfo imageInfo = SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType);
|
2017-10-04 18:31:33 +00:00
|
|
|
pixmap.reset(imageInfo, nullptr, width * 5);
|
|
|
|
SkDebugf("width: %7d height: %7d computeByteSize: %13lld\n", width, height,
|
|
|
|
pixmap.computeByteSize());
|
2017-09-21 16:31:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#StdOut
|
2017-10-09 18:43:00 +00:00
|
|
|
width: 1 height: 1 computeByteSize: 4
|
|
|
|
width: 1 height: 1000 computeByteSize: 4999
|
|
|
|
width: 1 height: 1000000 computeByteSize: 4999999
|
|
|
|
width: 1000 height: 1 computeByteSize: 4000
|
|
|
|
width: 1000 height: 1000 computeByteSize: 4999000
|
|
|
|
width: 1000 height: 1000000 computeByteSize: 4999999000
|
|
|
|
width: 1000000 height: 1 computeByteSize: 4000000
|
|
|
|
width: 1000000 height: 1000 computeByteSize: 4999000000
|
2017-10-04 18:31:33 +00:00
|
|
|
width: 1000000 height: 1000000 computeByteSize: 4999999000000
|
2017-09-14 15:25:39 +00:00
|
|
|
##
|
|
|
|
##
|
|
|
|
|
2017-10-04 18:31:33 +00:00
|
|
|
#SeeAlso SkImageInfo::computeByteSize
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
#Subtopic Image_Info_Access ##
|
|
|
|
|
|
|
|
#Subtopic Reader
|
2018-02-01 14:37:32 +00:00
|
|
|
#Line # examine pixel value ##
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method bool computeIsOpaque() const
|
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Reader
|
|
|
|
#Line # returns true if all pixels are opaque ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
std::vector<uint32_t> pixels;
|
|
|
|
const int height = 2;
|
|
|
|
const int width = 2;
|
|
|
|
pixels.resize(height * width * 4);
|
|
|
|
SkPixmap pixmap(SkImageInfo::Make(width, height, kN32_SkColorType,
|
|
|
|
kPremul_SkAlphaType), (const void*) &pixels.front(), width * 4);
|
|
|
|
for (int index = 0; index < 2; ++index) {
|
|
|
|
pixmap.erase(0x00000000);
|
|
|
|
SkDebugf("computeIsOpaque: %s\n", pixmap.computeIsOpaque() ? "true" : "false");
|
|
|
|
pixmap.erase(0xFFFFFFFF);
|
|
|
|
SkDebugf("computeIsOpaque: %s\n", pixmap.computeIsOpaque() ? "true" : "false");
|
|
|
|
pixmap.reset(pixmap.info().makeAlphaType(kOpaque_SkAlphaType),
|
|
|
|
(const void*) &pixels.front(), width * 4);
|
2017-09-14 15:25:39 +00:00
|
|
|
}
|
|
|
|
#StdOut
|
2017-09-21 16:31:06 +00:00
|
|
|
computeIsOpaque: false
|
|
|
|
computeIsOpaque: true
|
|
|
|
computeIsOpaque: false
|
2017-09-14 15:25:39 +00:00
|
|
|
computeIsOpaque: true
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso isOpaque Color_Type Alpha
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method SkColor getColor(int x, int y) const
|
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Reader
|
|
|
|
#Line # returns one pixel as Unpremultiplied Color ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
const int w = 4;
|
|
|
|
const int h = 4;
|
|
|
|
std::vector<SkPMColor> storage;
|
|
|
|
storage.resize(w * h);
|
|
|
|
SkDebugf("Premultiplied:\n");
|
|
|
|
for (int y = 0; y < h; ++y) {
|
|
|
|
SkDebugf("(0, %d) ", y);
|
|
|
|
for (int x = 0; x < w; ++x) {
|
|
|
|
int a = 0xFF * (x + y) / (w - 1 + h - 1);
|
|
|
|
storage[x + y * w] = SkPackARGB32(a, a * x / (w - 1), a * y / (h - 1), a);
|
|
|
|
SkDebugf("0x%08x%c", storage[x + y * w], x == w - 1 ? '\n' : ' ');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SkPixmap pixmap(SkImageInfo::MakeN32(w, h, kPremul_SkAlphaType), &storage.front(), w * 4);
|
|
|
|
SkDebugf("Unpremultiplied:\n");
|
|
|
|
for (int y = 0; y < h; ++y) {
|
|
|
|
SkDebugf("(0, %d) ", y);
|
|
|
|
for (int x = 0; x < w; ++x) {
|
|
|
|
SkDebugf("0x%08x%c", pixmap.getColor(x, y), x == w - 1 ? '\n' : ' ');
|
|
|
|
}
|
|
|
|
}
|
2017-09-14 15:25:39 +00:00
|
|
|
#StdOut
|
2017-09-21 16:31:06 +00:00
|
|
|
Premultiplied:
|
2018-05-16 11:07:07 +00:00
|
|
|
(0, 0) 0x00000000 0x2a0e002a 0x55380055 0x7f7f007f
|
|
|
|
(0, 1) 0x2a000e2a 0x551c1c55 0x7f542a7f 0xaaaa38aa
|
|
|
|
(0, 2) 0x55003855 0x7f2a547f 0xaa7171aa 0xd4d48dd4
|
|
|
|
(0, 3) 0x7f007f7f 0xaa38aaaa 0xd48dd4d4 0xffffffff
|
2017-09-21 16:31:06 +00:00
|
|
|
Unpremultiplied:
|
2018-05-16 11:07:07 +00:00
|
|
|
(0, 0) 0x00000000 0x2a5500ff 0x55a800ff 0x7fff00ff
|
|
|
|
(0, 1) 0x2a0055ff 0x555454ff 0x7fa954ff 0xaaff54ff
|
|
|
|
(0, 2) 0x5500a8ff 0x7f54a9ff 0xaaaaaaff 0xd4ffaaff
|
|
|
|
(0, 3) 0x7f00ffff 0xaa54ffff 0xd4aaffff 0xffffffff
|
2017-09-14 15:25:39 +00:00
|
|
|
##
|
|
|
|
##
|
|
|
|
|
2018-09-20 21:31:43 +00:00
|
|
|
#SeeAlso getAlphaf addr() readPixels
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
#Method float getAlphaf(int x, int y) const
|
|
|
|
#In Property
|
|
|
|
#Line # returns Alpha normalized from zero to one ##
|
|
|
|
|
|
|
|
Looks up the pixel at (x,y) and return its alpha component, normalized to [0..1].
|
|
|
|
This is roughly equivalent to #Formula # SkGetColorA(getColor()) ##, but can be more efficent
|
|
|
|
(and more precise if the pixels store more than 8 bits per component).
|
|
|
|
|
|
|
|
#Param x column index, zero or greater, and less than width() ##
|
|
|
|
#Param y row index, zero or greater, and less than height() ##
|
|
|
|
|
|
|
|
#Return alpha converted to normalized float ##
|
|
|
|
|
|
|
|
#NoExample
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso getColor
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
#Subtopic Reader ##
|
|
|
|
|
|
|
|
#Subtopic Readable_Address
|
2018-02-01 14:37:32 +00:00
|
|
|
#Line # returns read only pixels ##
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method const void* addr(int x, int y) const
|
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Readable_Address
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
const int w = 4;
|
|
|
|
const int h = 4;
|
|
|
|
std::vector<SkPMColor> storage;
|
|
|
|
storage.resize(w * h);
|
|
|
|
SkPixmap pixmap(SkImageInfo::MakeN32(w, h, kPremul_SkAlphaType), &storage.front(), w * 4);
|
2017-09-14 15:25:39 +00:00
|
|
|
SkDebugf("pixmap.addr(1, 2) %c= &storage[1 + 2 * w]\n",
|
|
|
|
pixmap.addr(1, 2) == &storage[1 + 2 * w] ? '=' : '!');
|
|
|
|
#StdOut
|
|
|
|
pixmap.addr(1, 2) == &storage[1 + 2 * w]
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
2017-10-04 18:31:33 +00:00
|
|
|
#SeeAlso addr8 addr16 addr32 addr64 addrF16 getColor writable_addr SkBitmap::getAddr
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method const uint8_t* addr8() const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Readable_Address
|
|
|
|
#Line # returns readable pixel address as 8-bit pointer ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
const int w = 4;
|
|
|
|
const int h = 4;
|
|
|
|
uint8_t storage[w * h];
|
|
|
|
SkPixmap pixmap(SkImageInfo::Make(w, h, kGray_8_SkColorType, kPremul_SkAlphaType),
|
|
|
|
storage, w * sizeof(storage[0]));
|
2017-09-14 15:25:39 +00:00
|
|
|
SkDebugf("pixmap.addr8() %c= storage\n",
|
|
|
|
pixmap.addr8() == storage ? '=' : '!');
|
|
|
|
#StdOut
|
|
|
|
pixmap.addr8() == storage
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso addr() addr16 addr32 addr64 addrF16 getColor writable_addr writable_addr8
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method const uint16_t* addr16() const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Readable_Address
|
|
|
|
#Line # returns readable pixel address as 16-bit pointer ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
const int w = 4;
|
|
|
|
const int h = 4;
|
|
|
|
uint16_t storage[w * h];
|
|
|
|
SkPixmap pixmap(SkImageInfo::Make(w, h, kARGB_4444_SkColorType, kPremul_SkAlphaType),
|
|
|
|
storage, w * sizeof(storage[0]));
|
2017-09-14 15:25:39 +00:00
|
|
|
SkDebugf("pixmap.addr16() %c= storage\n",
|
|
|
|
pixmap.addr16() == storage ? '=' : '!');
|
|
|
|
#StdOut
|
|
|
|
pixmap.addr16() == storage
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso addr() addr8 addr32 addr64 addrF16 getColor writable_addr writable_addr16
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method const uint32_t* addr32() const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Readable_Address
|
|
|
|
#Line # returns readable pixel address as 32-bit pointer ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
const int w = 4;
|
|
|
|
const int h = 4;
|
|
|
|
uint32_t storage[w * h];
|
|
|
|
SkPixmap pixmap(SkImageInfo::MakeN32(w, h, kPremul_SkAlphaType),
|
|
|
|
storage, w * sizeof(storage[0]));
|
2017-09-14 15:25:39 +00:00
|
|
|
SkDebugf("pixmap.addr32() %c= storage\n",
|
|
|
|
pixmap.addr32() == storage ? '=' : '!');
|
|
|
|
#StdOut
|
|
|
|
pixmap.addr32() == storage
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso addr() addr8 addr16 addr64 addrF16 getColor writable_addr writable_addr32
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method const uint64_t* addr64() const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Readable_Address
|
|
|
|
#Line # returns readable pixel address as 64-bit pointer ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
const int w = 4;
|
|
|
|
const int h = 4;
|
|
|
|
uint64_t storage[w * h];
|
|
|
|
SkPixmap pixmap(SkImageInfo::Make(w, h, kRGBA_F16_SkColorType, kPremul_SkAlphaType),
|
|
|
|
storage, w * sizeof(storage[0]));
|
2017-09-14 15:25:39 +00:00
|
|
|
SkDebugf("pixmap.addr64() %c= storage\n",
|
|
|
|
pixmap.addr64() == storage ? '=' : '!');
|
|
|
|
#StdOut
|
|
|
|
pixmap.addr64() == storage
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso addr() addr8 addr16 addr32 addrF16 getColor writable_addr writable_addr64
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method const uint16_t* addrF16() const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Readable_Address
|
|
|
|
#Line # returns readable pixel component address as 16-bit pointer ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
const int w = 4;
|
|
|
|
const int h = 4;
|
|
|
|
uint16_t storage[w * h * 4];
|
|
|
|
SkPixmap pixmap(SkImageInfo::Make(w, h, kRGBA_F16_SkColorType, kPremul_SkAlphaType),
|
|
|
|
storage, w * 4 * sizeof(storage[0]));
|
2017-09-14 15:25:39 +00:00
|
|
|
SkDebugf("pixmap.addrF16() %c= storage\n",
|
|
|
|
pixmap.addrF16() == storage ? '=' : '!');
|
|
|
|
#StdOut
|
|
|
|
pixmap.addrF16() == storage
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso addr() addr8 addr16 addr32 addr64 getColor writable_addr writable_addrF16
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method const uint8_t* addr8(int x, int y) const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Readable_Address
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
const int w = 4;
|
|
|
|
const int h = 4;
|
|
|
|
uint8_t storage[w * h];
|
|
|
|
SkPixmap pixmap(SkImageInfo::Make(w, h, kGray_8_SkColorType, kPremul_SkAlphaType),
|
|
|
|
storage, w * sizeof(storage[0]));
|
|
|
|
SkDebugf("pixmap.addr8(1, 2) %c= &storage[1 + 2 * w]\n",
|
|
|
|
pixmap.addr8(1, 2) == &storage[1 + 2 * w] ? '=' : '!');
|
2017-09-14 15:25:39 +00:00
|
|
|
#StdOut
|
|
|
|
pixmap.addr8(1, 2) == &storage[1 + 2 * w]
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso addr() addr16 addr32 addr64 addrF16 getColor writable_addr writable_addr8
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method const uint16_t* addr16(int x, int y) const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Readable_Address
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
const int w = 4;
|
|
|
|
const int h = 4;
|
|
|
|
uint16_t storage[w * h];
|
|
|
|
SkPixmap pixmap(SkImageInfo::Make(w, h, kARGB_4444_SkColorType, kPremul_SkAlphaType),
|
|
|
|
storage, w * sizeof(storage[0]));
|
2017-09-14 15:25:39 +00:00
|
|
|
SkDebugf("pixmap.addr16(1, 2) %c= &storage[1 + 2 * w]\n",
|
|
|
|
pixmap.addr16(1, 2) == &storage[1 + 2 * w] ? '=' : '!');
|
|
|
|
#StdOut
|
|
|
|
pixmap.addr16(1, 2) == &storage[1 + 2 * w]
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso addr() addr8 addr32 addr64 addrF16 getColor writable_addr writable_addr16
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method const uint32_t* addr32(int x, int y) const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Readable_Address
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
const int w = 4;
|
|
|
|
const int h = 4;
|
|
|
|
uint32_t storage[w * h];
|
|
|
|
SkPixmap pixmap(SkImageInfo::Make(w, h, kRGBA_8888_SkColorType, kPremul_SkAlphaType),
|
|
|
|
storage, w * sizeof(storage[0]));
|
2017-09-14 15:25:39 +00:00
|
|
|
SkDebugf("pixmap.addr32(1, 2) %c= &storage[1 + 2 * w]\n",
|
|
|
|
pixmap.addr32(1, 2) == &storage[1 + 2 * w] ? '=' : '!');
|
|
|
|
#StdOut
|
|
|
|
pixmap.addr32(1, 2) == &storage[1 + 2 * w]
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
2017-11-02 21:49:34 +00:00
|
|
|
#SeeAlso addr() addr8 addr16 addr64 addrF16 getColor writable_addr writable_addr64
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method const uint64_t* addr64(int x, int y) const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Readable_Address
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
const int w = 4;
|
|
|
|
const int h = 4;
|
|
|
|
uint64_t storage[w * h];
|
|
|
|
SkPixmap pixmap(SkImageInfo::Make(w, h, kRGBA_F16_SkColorType, kPremul_SkAlphaType),
|
|
|
|
storage, w * sizeof(storage[0]));
|
2017-09-14 15:25:39 +00:00
|
|
|
SkDebugf("pixmap.addr64(1, 2) %c= &storage[1 + 2 * w]\n",
|
|
|
|
pixmap.addr64(1, 2) == &storage[1 + 2 * w] ? '=' : '!');
|
|
|
|
#StdOut
|
|
|
|
pixmap.addr64(1, 2) == &storage[1 + 2 * w]
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso addr() addr8 addr16 addr32 addrF16 getColor writable_addr writable_addr64
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method const uint16_t* addrF16(int x, int y) const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Readable_Address
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
const int w = 4;
|
|
|
|
const int h = 4;
|
|
|
|
const int wordsPerPixel = 4;
|
|
|
|
const int rowWords = w * wordsPerPixel;
|
|
|
|
uint16_t storage[rowWords * h];
|
|
|
|
SkPixmap pixmap(SkImageInfo::Make(w, h, kRGBA_F16_SkColorType, kPremul_SkAlphaType),
|
|
|
|
storage, rowWords * sizeof(storage[0]));
|
|
|
|
SkDebugf("pixmap.addrF16(1, 2) %c= &storage[1 * wordsPerPixel + 2 * rowWords]\n",
|
|
|
|
pixmap.addrF16(1, 2) == &storage[1 * wordsPerPixel + 2 * rowWords] ? '=' : '!');
|
2017-09-14 15:25:39 +00:00
|
|
|
#StdOut
|
|
|
|
pixmap.addrF16(1, 2) == &storage[1 * wordsPerPixel + 2 * rowWords]
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso addr() addr8 addr16 addr32 addr64 getColor writable_addr writable_addrF16
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
#Subtopic Readable_Address ##
|
|
|
|
|
|
|
|
#Subtopic Writable_Address
|
2018-02-01 14:37:32 +00:00
|
|
|
#Line # returns writable pixels ##
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method void* writable_addr() const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Writable_Address
|
|
|
|
#Line # returns writable pixel address as void pointer ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
const int w = 4;
|
|
|
|
const int h = 4;
|
|
|
|
SkPMColor storage[w * h * 4];
|
|
|
|
SkPixmap pixmap(SkImageInfo::MakeN32(w, h, kPremul_SkAlphaType), storage, w * 4);
|
|
|
|
SkDebugf("pixmap.writable_addr() %c= (void *)storage\n",
|
|
|
|
pixmap.writable_addr() == (void *)storage ? '=' : '!');
|
|
|
|
pixmap.erase(0x00000000);
|
|
|
|
*(SkPMColor*)pixmap.writable_addr() = 0xFFFFFFFF;
|
|
|
|
SkDebugf("pixmap.getColor(0, 1) %c= 0x00000000\n",
|
|
|
|
pixmap.getColor(0, 1) == 0x00000000 ? '=' : '!');
|
|
|
|
SkDebugf("pixmap.getColor(0, 0) %c= 0xFFFFFFFF\n",
|
2017-09-14 15:25:39 +00:00
|
|
|
pixmap.getColor(0, 0) == 0xFFFFFFFF ? '=' : '!');
|
|
|
|
#StdOut
|
2017-09-21 16:31:06 +00:00
|
|
|
pixmap.writable_addr() == (void *)storage
|
|
|
|
pixmap.getColor(0, 1) == 0x00000000
|
2017-09-14 15:25:39 +00:00
|
|
|
pixmap.getColor(0, 0) == 0xFFFFFFFF
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso writable_addr8 writable_addr16 writable_addr32 writable_addr64 writable_addrF16 addr()
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method void* writable_addr(int x, int y) const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Writable_Address
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-09-21 16:31:06 +00:00
|
|
|
const int w = 4;
|
|
|
|
const int h = 4;
|
|
|
|
SkPMColor storage[w * h * 4];
|
|
|
|
SkPixmap pixmap(SkImageInfo::MakeN32(w, h, kPremul_SkAlphaType), storage, w * 4);
|
|
|
|
SkDebugf("pixmap.writable_addr() %c= (void *)storage\n",
|
|
|
|
pixmap.writable_addr() == (void *)storage ? '=' : '!');
|
|
|
|
pixmap.erase(0x00000000);
|
|
|
|
*(SkPMColor*)pixmap.writable_addr(1, 2) = 0xFFFFFFFF;
|
|
|
|
SkDebugf("pixmap.getColor(0, 0) %c= 0x00000000\n",
|
|
|
|
pixmap.getColor(0, 0) == 0x00000000 ? '=' : '!');
|
|
|
|
SkDebugf("pixmap.getColor(1, 2) %c= 0xFFFFFFFF\n",
|
2017-09-14 15:25:39 +00:00
|
|
|
pixmap.getColor(1, 2) == 0xFFFFFFFF ? '=' : '!');
|
|
|
|
#StdOut
|
2017-09-21 16:31:06 +00:00
|
|
|
pixmap.writable_addr() == (void *)storage
|
|
|
|
pixmap.getColor(0, 0) == 0x00000000
|
2017-09-14 15:25:39 +00:00
|
|
|
pixmap.getColor(1, 2) == 0xFFFFFFFF
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso writable_addr8 writable_addr16 writable_addr32 writable_addr64 writable_addrF16 addr()
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method uint8_t* writable_addr8(int x, int y) const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Writable_Address
|
|
|
|
#Line # returns writable pixel address as 8-bit pointer ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Height 64
|
|
|
|
#Description
|
|
|
|
Altering pixels after drawing Bitmap is not guaranteed to affect subsequent
|
|
|
|
drawing on all platforms. Adding a second SkBitmap::installPixels after editing
|
|
|
|
pixel memory is safer.
|
|
|
|
##
|
2017-09-21 16:31:06 +00:00
|
|
|
void draw(SkCanvas* canvas) {
|
|
|
|
uint8_t storage[][5] = {{ 0, 0, 64, 0, 0},
|
|
|
|
{ 0, 128, 255, 128, 0},
|
|
|
|
{64, 255, 255, 255, 64},
|
|
|
|
{ 0, 128, 255, 128, 0},
|
|
|
|
{ 0, 0, 64, 0, 0}};
|
|
|
|
SkImageInfo imageInfo = SkImageInfo::Make(5, 5, kGray_8_SkColorType, kPremul_SkAlphaType);
|
|
|
|
SkPixmap pixmap(imageInfo, storage[0], 5);
|
|
|
|
SkBitmap bitmap;
|
|
|
|
bitmap.installPixels(pixmap);
|
|
|
|
canvas->scale(10, 10);
|
|
|
|
canvas->drawBitmap(bitmap, 0, 0);
|
|
|
|
*pixmap.writable_addr8(2, 2) = 0;
|
|
|
|
// bitmap.installPixels(pixmap); // uncomment to fix on GPU
|
|
|
|
canvas->drawBitmap(bitmap, 10, 0);
|
2017-09-14 15:25:39 +00:00
|
|
|
}
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso writable_addr writable_addr16 writable_addr32 writable_addr64 writable_addrF16 addr() addr8
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method uint16_t* writable_addr16(int x, int y) const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Writable_Address
|
|
|
|
#Line # returns writable pixel address as 16-bit pointer ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Description
|
|
|
|
Draw a five by five bitmap, and draw it again with a center black pixel.
|
|
|
|
The low nibble of the 16-bit word is Alpha.
|
|
|
|
##
|
|
|
|
#Height 64
|
2017-09-21 16:31:06 +00:00
|
|
|
uint16_t storage[][5] = {{ 0xCABF, 0xDABE, 0xCA9D, 0xC96C, 0xA39B },
|
|
|
|
{ 0xACEE, 0xA87C, 0x893A, 0x4779, 0x8708 },
|
|
|
|
{ 0x4B7C, 0x255B, 0x2559, 0x2557, 0x4656 },
|
|
|
|
{ 0x9099, 0x8128, 0x2557, 0x4124, 0x3323 },
|
|
|
|
{ 0x7547, 0x5505, 0x4434, 0x2012, 0x0000 }};
|
|
|
|
SkImageInfo imageInfo = SkImageInfo::Make(5, 5, kARGB_4444_SkColorType, kPremul_SkAlphaType);
|
|
|
|
SkPixmap pixmap(imageInfo, storage[0], sizeof(storage) / 5);
|
|
|
|
SkBitmap bitmap;
|
|
|
|
bitmap.installPixels(pixmap);
|
|
|
|
canvas->scale(10, 10);
|
|
|
|
canvas->drawBitmap(bitmap, 0, 0);
|
|
|
|
*pixmap.writable_addr16(2, 2) = 0x000F;
|
|
|
|
bitmap.installPixels(pixmap);
|
2017-09-14 15:25:39 +00:00
|
|
|
canvas->drawBitmap(bitmap, 10, 0);
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso writable_addr writable_addr8 writable_addr32 writable_addr64 writable_addrF16 addr() addr16
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method uint32_t* writable_addr32(int x, int y) const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Writable_Address
|
|
|
|
#Line # returns writable pixel address as 32-bit pointer ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Image 4
|
|
|
|
#Height 72
|
2017-09-21 16:31:06 +00:00
|
|
|
std::vector<int32_t> pixels;
|
|
|
|
pixels.resize(image->height() * image->width() * 4);
|
|
|
|
SkPixmap pixmap(SkImageInfo::Make(image->width(), image->height(), kN32_SkColorType,
|
|
|
|
image->alphaType()), (const void*) &pixels.front(), image->width() * 4);
|
|
|
|
image->readPixels(pixmap, 0, 0);
|
|
|
|
for (int y = 0; y < pixmap.height() / 2; ++y) {
|
|
|
|
for (int x = 0; x < pixmap.width(); ++x) {
|
|
|
|
if ((x & 4) == (y & 4)) {
|
2018-06-19 16:57:43 +00:00
|
|
|
*pixmap.writable_addr32(x, y) =
|
|
|
|
*pixmap.writable_addr32(pixmap.width() - x, pixmap.height() - y);
|
2017-09-21 16:31:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SkBitmap bitmap;
|
|
|
|
bitmap.installPixels(pixmap);
|
2017-09-14 15:25:39 +00:00
|
|
|
canvas->drawBitmap(bitmap, 0, 0);
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso writable_addr writable_addr8 writable_addr16 writable_addr64 writable_addrF16 addr() addr32
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method uint64_t* writable_addr64(int x, int y) const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Writable_Address
|
|
|
|
#Line # returns writable pixel address as 64-bit pointer ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-11-02 21:49:34 +00:00
|
|
|
#Height 40
|
2017-09-21 16:31:06 +00:00
|
|
|
SkImageInfo info = SkImageInfo::Make(3, 3, kRGBA_F16_SkColorType, kPremul_SkAlphaType);
|
|
|
|
uint64_t storage[9];
|
|
|
|
SkPixmap pixmap(info, storage, 3 * sizeof(uint64_t));
|
|
|
|
SkColor4f c4 { 1, 0.45f, 0.25f, 0.65f };
|
|
|
|
pixmap.erase(c4);
|
|
|
|
SkBitmap bitmap;
|
|
|
|
canvas->scale(10, 10);
|
|
|
|
bitmap.installPixels(pixmap);
|
|
|
|
canvas->drawBitmap(bitmap, 0, 0);
|
|
|
|
*pixmap.writable_addr64(1, 1) |= 0x00ff000000000000LL;
|
|
|
|
bitmap.installPixels(pixmap);
|
2017-09-14 15:25:39 +00:00
|
|
|
canvas->drawBitmap(bitmap, 10, 0);
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso writable_addr writable_addr8 writable_addr16 writable_addr32 writable_addrF16 addr() addr64
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method uint16_t* writable_addrF16(int x, int y) const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
2018-01-30 15:08:57 +00:00
|
|
|
#In Writable_Address
|
|
|
|
#Line # returns writable pixel component address as 16-bit pointer ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Height 64
|
|
|
|
#Description
|
|
|
|
Left bitmap is drawn with two pixels defined in half float format. Right bitmap
|
2018-05-16 11:07:07 +00:00
|
|
|
is drawn after overwriting bottom half float color with top half float color.
|
2017-09-14 15:25:39 +00:00
|
|
|
##
|
2017-09-21 16:31:06 +00:00
|
|
|
SkImageInfo info = SkImageInfo::Make(1, 2, kRGBA_F16_SkColorType, kPremul_SkAlphaType);
|
|
|
|
uint16_t storage[2][4];
|
|
|
|
SkPixmap pixmap(info, storage[0], sizeof(uint64_t));
|
|
|
|
SkIRect topPixelBounds = {0, 0, 1, 1};
|
|
|
|
pixmap.erase({ 0.65f, 0.45f, 0.25f, 1 }, &topPixelBounds);
|
|
|
|
SkIRect bottomPixelBounds = {0, 1, 1, 2};
|
|
|
|
pixmap.erase({ 0.25f, 0.65f, 0.45f, 1 }, &bottomPixelBounds);
|
|
|
|
SkBitmap bitmap;
|
|
|
|
canvas->scale(20, 20);
|
|
|
|
bitmap.installPixels(pixmap);
|
|
|
|
canvas->drawBitmap(bitmap, 0, 0);
|
|
|
|
uint16_t* pixel2 = pixmap.writable_addrF16(0, 1);
|
|
|
|
for (int i = 0; i < 4; ++i) {
|
|
|
|
pixel2[i] = storage[0][i];
|
|
|
|
}
|
|
|
|
bitmap.installPixels(pixmap);
|
|
|
|
canvas->drawBitmap(bitmap, 4, 0);
|
2017-09-14 15:25:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso writable_addr writable_addr8 writable_addr16 writable_addr32 writable_addr64 addr() addrF16
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
#Subtopic Writable_Address ##
|
|
|
|
|
2018-02-07 12:27:09 +00:00
|
|
|
#Subtopic Pixels
|
|
|
|
#Line # read and write pixel values ##
|
|
|
|
##
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-07-17 17:19:56 +00:00
|
|
|
#Method bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes) const
|
2018-02-07 12:27:09 +00:00
|
|
|
#In Pixels
|
2018-01-30 15:08:57 +00:00
|
|
|
#Line # copies and converts pixels ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Height 128
|
|
|
|
#Description
|
|
|
|
Transferring the gradient from 8 bits per component to 4 bits per component
|
|
|
|
creates visible banding.
|
|
|
|
##
|
2017-09-21 16:31:06 +00:00
|
|
|
std::vector<int32_t> pixels;
|
|
|
|
const int width = 256;
|
|
|
|
const int height = 64;
|
|
|
|
pixels.resize(height * width * 4);
|
|
|
|
SkImageInfo srcInfo = SkImageInfo::MakeN32Premul(width, height);
|
|
|
|
SkPixmap srcPixmap(srcInfo, (const void*) &pixels.front(), width * 4);
|
|
|
|
SkColor gradColors[] = { 0xFFAA3300, 0x7F881122 };
|
|
|
|
SkPoint gradPoints[] = { { 0, 0 }, { 256, 0 } };
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setShader(SkGradientShader::MakeLinear(gradPoints, gradColors, nullptr,
|
|
|
|
SK_ARRAY_COUNT(gradColors), SkShader::kClamp_TileMode));
|
|
|
|
SkBitmap bitmap;
|
|
|
|
bitmap.installPixels(srcPixmap);
|
|
|
|
SkCanvas srcCanvas(bitmap);
|
|
|
|
srcCanvas.drawRect(SkRect::MakeWH(width, height), paint);
|
|
|
|
canvas->drawBitmap(bitmap, 0, 0);
|
|
|
|
std::vector<int32_t> dstPixels;
|
|
|
|
dstPixels.resize(height * width * 2);
|
|
|
|
SkImageInfo dstInfo = srcInfo.makeColorType(kARGB_4444_SkColorType);
|
|
|
|
srcPixmap.readPixels(dstInfo, &dstPixels.front(), width * 2);
|
|
|
|
SkPixmap dstPixmap(dstInfo, &dstPixels.front(), width * 2);
|
|
|
|
bitmap.installPixels(dstPixmap);
|
2017-09-14 15:25:39 +00:00
|
|
|
canvas->drawBitmap(bitmap, 0, 128);
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso erase SkBitmap::readPixels SkCanvas::drawBitmap SkCanvas::readPixels SkImage::readPixels SkSurface::readPixels
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes, int srcX,
|
2018-05-16 11:07:07 +00:00
|
|
|
int srcY) const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
Copies a Rect of pixels to dstPixels. Copy starts at (srcX, srcY), and does not
|
2018-01-11 15:35:44 +00:00
|
|
|
exceed Pixmap (width(), height()).
|
2017-09-21 16:31:06 +00:00
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
dstInfo specifies width, height, Color_Type, Alpha_Type, and
|
2017-09-14 15:25:39 +00:00
|
|
|
Color_Space of destination. dstRowBytes specifics the gap from one destination
|
|
|
|
row to the next. Returns true if pixels are copied. Returns false if
|
|
|
|
dstInfo.addr() equals nullptr, or dstRowBytes is less than dstInfo.minRowBytes.
|
|
|
|
|
2018-01-11 15:35:44 +00:00
|
|
|
Pixels are copied only if pixel conversion is possible. If Pixmap colorType is
|
2017-09-14 15:25:39 +00:00
|
|
|
kGray_8_SkColorType, or kAlpha_8_SkColorType; dstInfo.colorType must match.
|
2018-01-11 15:35:44 +00:00
|
|
|
If Pixmap colorType is kGray_8_SkColorType, dstInfo.colorSpace must match.
|
|
|
|
If Pixmap alphaType is kOpaque_SkAlphaType, dstInfo.alphaType must
|
|
|
|
match. If Pixmap colorSpace is nullptr, dstInfo.colorSpace must match. Returns
|
2017-09-14 15:25:39 +00:00
|
|
|
false if pixel conversion is not possible.
|
2018-05-16 11:07:07 +00:00
|
|
|
|
2017-09-14 15:25:39 +00:00
|
|
|
srcX and srcY may be negative to copy only top or left of source. Returns
|
2018-01-11 15:35:44 +00:00
|
|
|
false if Pixmap width() or height() is zero or negative. Returns false if:
|
2017-10-26 11:58:48 +00:00
|
|
|
|
Condense embedded formulas.
Bookmaker delimits formulas and equations to allow
representing variables and symbols without tripping
up reference lookup, spell checking, and comment
generation.
Before, formulas were represented with:
some text
#Formula
(x + y, 0)
##
, and more text
This made it difficult to know when spacing should
be preserved before and after the formula. Now,
formulas are represented with:
some text #Formula # (x + y, 0) ##, and more text
The presence or absence of a space between ## and ,
is now significant (before it was not).
Also, formulas are bracketed by <code> in markdown
generation, so that variables stand out better.
See:
https://skia.org/user/api/SkBlendMode_Reference?cl=152781#Dst_Out
for an example.
Also fixed 100 column offenders and added a code
check to identify them. For the moment, 100 column
offenders are outed with SkDebugf but their presence
does not cause bookmaker to fail.
TBR=caryclark@google.com
Docs-Preview: https://skia.org/?cl=152781
Bug: skia:6898
Change-Id: If92a65a234f5d616bf4485984a8d219a6f04821a
Reviewed-on: https://skia-review.googlesource.com/152781
Commit-Queue: Cary Clark <caryclark@skia.org>
Auto-Submit: Cary Clark <caryclark@skia.org>
Reviewed-by: Cary Clark <caryclark@skia.org>
2018-09-13 16:04:30 +00:00
|
|
|
#Formula # abs(srcX) >= Pixmap width() ##, or if #Formula # abs(srcY) >= Pixmap height() ##.
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Param dstInfo destination width, height, Color_Type, Alpha_Type, Color_Space ##
|
|
|
|
#Param dstPixels destination pixel storage ##
|
|
|
|
#Param dstRowBytes destination row length ##
|
|
|
|
#Param srcX column index whose absolute value is less than width() ##
|
|
|
|
#Param srcY row index whose absolute value is less than height() ##
|
|
|
|
|
|
|
|
#Return true if pixels are copied to dstPixels ##
|
|
|
|
|
|
|
|
#Example
|
|
|
|
#Image 3
|
2017-09-21 16:31:06 +00:00
|
|
|
void draw(SkCanvas* canvas) {
|
|
|
|
SkImageInfo info = SkImageInfo::MakeN32Premul(image->width(), image->height());
|
|
|
|
std::vector<int32_t> srcPixels;
|
|
|
|
const int rowBytes = image->width() * 4;
|
|
|
|
srcPixels.resize(image->height() * rowBytes);
|
|
|
|
SkPixmap pixmap(info, (const void*) &srcPixels.front(), rowBytes);
|
|
|
|
image->readPixels(pixmap, 0, 0);
|
|
|
|
for (int offset : { 32, 64, 96 } ) {
|
|
|
|
std::vector<int32_t> dstPixels;
|
|
|
|
dstPixels.resize(image->height() * rowBytes);
|
|
|
|
pixmap.readPixels(info, &dstPixels.front(), rowBytes, offset, 0);
|
|
|
|
SkBitmap bitmap;
|
|
|
|
SkPixmap dstmap(info, &dstPixels.front(), rowBytes);
|
|
|
|
bitmap.installPixels(dstmap);
|
|
|
|
canvas->translate(32, 32);
|
|
|
|
canvas->drawBitmap(bitmap, 0, 0);
|
|
|
|
}
|
2017-09-14 15:25:39 +00:00
|
|
|
}
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso erase SkBitmap::readPixels SkCanvas::drawBitmap SkCanvas::readPixels SkImage::readPixels SkSurface::readPixels
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method bool readPixels(const SkPixmap& dst, int srcX, int srcY) const
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
Copies a Rect of pixels to dst. Copy starts at (srcX, srcY), and does not
|
2018-01-11 15:35:44 +00:00
|
|
|
exceed Pixmap (width(), height()). dst specifies width, height, Color_Type,
|
2017-09-14 15:25:39 +00:00
|
|
|
Alpha_Type, and Color_Space of destination. Returns true if pixels are copied.
|
|
|
|
Returns false if dst.addr() equals nullptr, or dst.rowBytes is less than
|
|
|
|
dst SkImageInfo::minRowBytes.
|
|
|
|
|
2018-01-11 15:35:44 +00:00
|
|
|
Pixels are copied only if pixel conversion is possible. If Pixmap colorType is
|
2017-09-14 15:25:39 +00:00
|
|
|
kGray_8_SkColorType, or kAlpha_8_SkColorType; dst.info().colorType must match.
|
2018-01-11 15:35:44 +00:00
|
|
|
If Pixmap colorType is kGray_8_SkColorType, dst.info().colorSpace must match.
|
|
|
|
If Pixmap alphaType is kOpaque_SkAlphaType, dst.info().alphaType must
|
|
|
|
match. If Pixmap colorSpace is nullptr, dst.info().colorSpace must match. Returns
|
2017-09-14 15:25:39 +00:00
|
|
|
false if pixel conversion is not possible.
|
2018-05-16 11:07:07 +00:00
|
|
|
|
2017-09-14 15:25:39 +00:00
|
|
|
srcX and srcY may be negative to copy only top or left of source. Returns
|
2018-01-11 15:35:44 +00:00
|
|
|
false Pixmap width() or height() is zero or negative. Returns false if:
|
2017-10-26 11:58:48 +00:00
|
|
|
|
Condense embedded formulas.
Bookmaker delimits formulas and equations to allow
representing variables and symbols without tripping
up reference lookup, spell checking, and comment
generation.
Before, formulas were represented with:
some text
#Formula
(x + y, 0)
##
, and more text
This made it difficult to know when spacing should
be preserved before and after the formula. Now,
formulas are represented with:
some text #Formula # (x + y, 0) ##, and more text
The presence or absence of a space between ## and ,
is now significant (before it was not).
Also, formulas are bracketed by <code> in markdown
generation, so that variables stand out better.
See:
https://skia.org/user/api/SkBlendMode_Reference?cl=152781#Dst_Out
for an example.
Also fixed 100 column offenders and added a code
check to identify them. For the moment, 100 column
offenders are outed with SkDebugf but their presence
does not cause bookmaker to fail.
TBR=caryclark@google.com
Docs-Preview: https://skia.org/?cl=152781
Bug: skia:6898
Change-Id: If92a65a234f5d616bf4485984a8d219a6f04821a
Reviewed-on: https://skia-review.googlesource.com/152781
Commit-Queue: Cary Clark <caryclark@skia.org>
Auto-Submit: Cary Clark <caryclark@skia.org>
Reviewed-by: Cary Clark <caryclark@skia.org>
2018-09-13 16:04:30 +00:00
|
|
|
#Formula # abs(srcX) >= Pixmap width() ##, or if #Formula # abs(srcY) >= Pixmap height() ##.
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Param dst Image_Info and pixel address to write to ##
|
|
|
|
#Param srcX column index whose absolute value is less than width() ##
|
|
|
|
#Param srcY row index whose absolute value is less than height() ##
|
|
|
|
|
|
|
|
#Return true if pixels are copied to dst ##
|
|
|
|
|
|
|
|
#Example
|
|
|
|
#Image 3
|
2017-09-21 16:31:06 +00:00
|
|
|
void draw(SkCanvas* canvas) {
|
|
|
|
SkImageInfo info = SkImageInfo::MakeN32Premul(image->width(), image->height());
|
|
|
|
std::vector<int32_t> srcPixels;
|
|
|
|
const int rowBytes = image->width() * 4;
|
|
|
|
srcPixels.resize(image->height() * rowBytes);
|
|
|
|
SkPixmap pixmap(info, (const void*) &srcPixels.front(), rowBytes);
|
|
|
|
image->readPixels(pixmap, 0, 0);
|
|
|
|
for (int offset : { 32, 64, 96 } ) {
|
|
|
|
std::vector<int32_t> dstPixels;
|
|
|
|
dstPixels.resize(image->height() * rowBytes);
|
|
|
|
SkPixmap dstmap(info, &dstPixels.front(), rowBytes);
|
|
|
|
pixmap.readPixels(dstmap, offset, 0);
|
|
|
|
SkBitmap bitmap;
|
|
|
|
bitmap.installPixels(dstmap);
|
|
|
|
canvas->translate(32, 32);
|
|
|
|
canvas->drawBitmap(bitmap, 0, 0);
|
|
|
|
}
|
2017-09-14 15:25:39 +00:00
|
|
|
}
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso erase SkBitmap::readPixels SkCanvas::drawBitmap SkCanvas::readPixels SkImage::readPixels SkSurface::readPixels
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method bool readPixels(const SkPixmap& dst) const
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Image 3
|
2017-09-21 16:31:06 +00:00
|
|
|
void draw(SkCanvas* canvas) {
|
|
|
|
SkImageInfo info = SkImageInfo::MakeN32Premul(image->width(), image->height());
|
|
|
|
std::vector<int32_t> srcPixels;
|
|
|
|
const int rowBytes = image->width() * 4;
|
|
|
|
srcPixels.resize(image->height() * rowBytes);
|
|
|
|
SkPixmap pixmap(info, (const void*) &srcPixels.front(), rowBytes);
|
|
|
|
image->readPixels(pixmap, 0, 0);
|
|
|
|
for (int index = 0; index < 3; ++index ) {
|
|
|
|
std::vector<int32_t> dstPixels;
|
|
|
|
dstPixels.resize(image->height() * rowBytes);
|
|
|
|
SkPixmap dstmap(info, &dstPixels.front(), rowBytes);
|
|
|
|
pixmap.readPixels(dstmap);
|
|
|
|
SkBitmap bitmap;
|
|
|
|
bitmap.installPixels(dstmap);
|
|
|
|
canvas->translate(32, 32);
|
|
|
|
canvas->drawBitmap(bitmap, 0, 0);
|
|
|
|
}
|
2017-09-14 15:25:39 +00:00
|
|
|
}
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso erase SkBitmap::readPixels SkCanvas::drawBitmap SkCanvas::readPixels SkImage::readPixels SkSurface::readPixels
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method bool scalePixels(const SkPixmap& dst, SkFilterQuality filterQuality) const
|
|
|
|
|
2018-02-07 12:27:09 +00:00
|
|
|
#In Pixels
|
2018-01-30 15:08:57 +00:00
|
|
|
#Line # scales and converts pixels ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Image 3
|
2017-09-21 16:31:06 +00:00
|
|
|
void draw(SkCanvas* canvas) {
|
|
|
|
SkImageInfo info = SkImageInfo::MakeN32Premul(image->width(), image->height());
|
|
|
|
std::vector<int32_t> srcPixels;
|
|
|
|
int rowBytes = image->width() * 4;
|
|
|
|
srcPixels.resize(image->height() * rowBytes);
|
|
|
|
SkPixmap pixmap(info, (const void*) &srcPixels.front(), rowBytes);
|
|
|
|
image->readPixels(pixmap, 0, 0);
|
|
|
|
for (int offset : { 32, 64, 96 } ) {
|
|
|
|
info = SkImageInfo::MakeN32Premul(image->width() + offset, image->height());
|
|
|
|
rowBytes = info.width() * 4;
|
|
|
|
std::vector<int32_t> dstPixels;
|
|
|
|
dstPixels.resize(image->height() * rowBytes);
|
|
|
|
SkPixmap dstmap(info, &dstPixels.front(), rowBytes);
|
|
|
|
pixmap.scalePixels(dstmap, kMedium_SkFilterQuality);
|
|
|
|
SkBitmap bitmap;
|
|
|
|
bitmap.installPixels(dstmap);
|
|
|
|
canvas->translate(32, 32);
|
|
|
|
canvas->drawBitmap(bitmap, 0, 0);
|
|
|
|
}
|
2017-09-14 15:25:39 +00:00
|
|
|
}
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso SkCanvas::drawBitmap SkImage::scalePixels
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method bool erase(SkColor color, const SkIRect& subset) const
|
|
|
|
|
2018-02-07 12:27:09 +00:00
|
|
|
#In Pixels
|
2018-01-30 15:08:57 +00:00
|
|
|
#Line # writes Color to pixels ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-11-02 21:49:34 +00:00
|
|
|
#Height 50
|
2017-09-21 16:31:06 +00:00
|
|
|
uint32_t storage[2];
|
|
|
|
SkImageInfo info = SkImageInfo::MakeN32Premul(1, 2);
|
|
|
|
SkPixmap pixmap(info, storage, info.minRowBytes());
|
|
|
|
pixmap.erase(SK_ColorBLUE, {0, 0, 1, 1});
|
|
|
|
pixmap.erase(SK_ColorRED, {0, 1, 1, 2});
|
|
|
|
SkBitmap bitmap;
|
|
|
|
canvas->scale(20, 20);
|
|
|
|
bitmap.installPixels(pixmap);
|
|
|
|
canvas->drawBitmap(bitmap, 0, 0);
|
2017-09-14 15:25:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso SkBitmap::erase SkCanvas::clear SkCanvas::drawColor
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-05-16 11:07:07 +00:00
|
|
|
#Method bool erase(SkColor color) const
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-11-02 21:49:34 +00:00
|
|
|
#Height 50
|
2017-09-21 16:31:06 +00:00
|
|
|
uint32_t storage[2];
|
|
|
|
SkImageInfo info = SkImageInfo::MakeN32Premul(1, 2);
|
|
|
|
SkPixmap pixmap(info, storage, info.minRowBytes());
|
|
|
|
pixmap.erase(SK_ColorBLUE);
|
|
|
|
SkBitmap bitmap;
|
|
|
|
canvas->scale(20, 20);
|
|
|
|
bitmap.installPixels(pixmap);
|
|
|
|
canvas->drawBitmap(bitmap, 0, 0);
|
2017-09-14 15:25:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso SkBitmap::erase SkCanvas::clear SkCanvas::drawColor
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method bool erase(const SkColor4f& color, const SkIRect* subset = nullptr) const
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2017-09-14 15:25:39 +00:00
|
|
|
|
|
|
|
#Example
|
2017-11-02 21:49:34 +00:00
|
|
|
#Height 50
|
2017-09-21 16:31:06 +00:00
|
|
|
uint32_t storage[2];
|
|
|
|
SkImageInfo info = SkImageInfo::MakeN32Premul(1, 2);
|
|
|
|
SkPixmap pixmap(info, storage, info.minRowBytes());
|
|
|
|
SkIRect topPixelBounds = {0, 0, 1, 1};
|
|
|
|
pixmap.erase({ 0.65f, 0.45f, 0.25f, 1 }, &topPixelBounds);
|
|
|
|
SkIRect bottomPixelBounds = {0, 1, 1, 2};
|
|
|
|
pixmap.erase({ 0.25f, 0.65f, 0.45f, 1 }, &bottomPixelBounds);
|
|
|
|
SkBitmap bitmap;
|
|
|
|
canvas->scale(20, 20);
|
|
|
|
bitmap.installPixels(pixmap);
|
|
|
|
canvas->drawBitmap(bitmap, 0, 0);
|
2017-09-14 15:25:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso SkBitmap::erase SkCanvas::clear SkCanvas::drawColor
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
#Class SkPixmap ##
|
|
|
|
|
|
|
|
#Topic Pixmap ##
|