本文整理汇总了C++中SkColorTable::unref方法的典型用法代码示例。如果您正苦于以下问题:C++ SkColorTable::unref方法的具体用法?C++ SkColorTable::unref怎么用?C++ SkColorTable::unref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkColorTable
的用法示例。
在下文中一共展示了SkColorTable::unref方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: alps
static void convert_to_index666(const SkBitmap& src, SkBitmap* dst) {
SkPMColor storage[216];
SkPMColor* colors = storage;
// rrr ggg bbb
for (int r = 0; r < 6; r++) {
int rr = conv_6_to_byte(r);
for (int g = 0; g < 6; g++) {
int gg = conv_6_to_byte(g);
for (int b = 0; b < 6; b++) {
int bb = conv_6_to_byte(b);
*colors++ = SkPreMultiplyARGB(0xFF, rr, gg, bb);
}
}
}
SkColorTable* ctable = new SkColorTable(storage, 216);
dst->allocPixels(SkImageInfo::Make(src.width(), src.height(),
kIndex_8_SkColorType, kOpaque_SkAlphaType),
NULL, ctable);
ctable->unref();
SkAutoLockPixels alps(src);
SkAutoLockPixels alpd(*dst);
for (int y = 0; y < src.height(); y++) {
const SkPMColor* srcP = src.getAddr32(0, y);
uint8_t* dstP = dst->getAddr8(0, y);
for (int x = src.width() - 1; x >= 0; --x) {
*dstP++ = compute_666_index(*srcP++);
}
}
}
示例2: make_bitmap
static SkBitmap make_bitmap()
{
SkBitmap bm;
SkColorTable* ctable = new SkColorTable(256);
SkPMColor* c = ctable->lockColors();
for (int i = 0; i < 256; i++)
{
c[i] = SkPackARGB32(0xFF, i, 0, 0);
}
ctable->unlockColors(true);
bm.setConfig(SkBitmap::kIndex8_Config, 256, 32);
bm.allocPixels(ctable);
ctable->unref();
bm.lockPixels();
for (int y = 0; y < bm.height(); y++)
{
uint8_t* p = bm.getAddr8(0, y);
for (int x = 0; x < 256; x++)
{
p[x] = x;
}
}
bm.unlockPixels();
return bm;
}
示例3: alps
static void convertToIndex666(const SkBitmap& src, SkBitmap* dst) {
SkColorTable* ctable = new SkColorTable(216);
SkPMColor* colors = ctable->lockColors();
// rrr ggg bbb
for (int r = 0; r < 6; r++) {
int rr = conv6ToByte(r);
for (int g = 0; g < 6; g++) {
int gg = conv6ToByte(g);
for (int b = 0; b < 6; b++) {
int bb = conv6ToByte(b);
*colors++ = SkPreMultiplyARGB(0xFF, rr, gg, bb);
}
}
}
ctable->unlockColors(true);
dst->setConfig(SkBitmap::kIndex8_Config, src.width(), src.height());
dst->allocPixels(ctable);
ctable->unref();
SkAutoLockPixels alps(src);
SkAutoLockPixels alpd(*dst);
for (int y = 0; y < src.height(); y++) {
const SkPMColor* srcP = src.getAddr32(0, y);
uint8_t* dstP = dst->getAddr8(0, y);
for (int x = src.width() - 1; x >= 0; --x) {
*dstP++ = compute666Index(*srcP++);
}
}
}
示例4: make_bitmap
static SkBitmap make_bitmap() {
SkBitmap bm;
SkColorTable* ctable = new SkColorTable(256);
SkPMColor* c = ctable->lockColors();
for (int i = 0; i < 256; i++) {
c[i] = SkPackARGB32(255 - i, 0, 0, 0);
}
ctable->unlockColors(true);
bm.setConfig(SkBitmap::kIndex8_Config, 256, 256);
bm.allocPixels(ctable);
ctable->unref();
bm.lockPixels();
const float cx = bm.width() * 0.5f;
const float cy = bm.height() * 0.5f;
for (int y = 0; y < bm.height(); y++) {
float dy = y - cy;
dy *= dy;
uint8_t* p = bm.getAddr8(0, y);
for (int x = 0; x < 256; x++) {
float dx = x - cx;
dx *= dx;
float d = (dx + dy) / (cx/2);
int id = (int)d;
if (id > 255) {
id = 255;
}
p[x] = id;
}
}
bm.unlockPixels();
return bm;
}
示例5: make_bitmap
static SkBitmap make_bitmap() {
SkPMColor c[256];
for (int i = 0; i < 256; i++) {
c[i] = SkPackARGB32(255 - i, 0, 0, 0);
}
SkBitmap bm;
SkColorTable* ctable = new SkColorTable(c, 256);
bm.allocPixels(SkImageInfo::Make(256, 256, kIndex_8_SkColorType,
kPremul_SkAlphaType),
nullptr, ctable);
ctable->unref();
bm.lockPixels();
const float cx = bm.width() * 0.5f;
const float cy = bm.height() * 0.5f;
for (int y = 0; y < bm.height(); y++) {
float dy = y - cy;
dy *= dy;
uint8_t* p = bm.getAddr8(0, y);
for (int x = 0; x < 256; x++) {
float dx = x - cx;
dx *= dx;
float d = (dx + dy) / (cx/2);
int id = (int)d;
if (id > 255) {
id = 255;
}
p[x] = id;
}
}
bm.unlockPixels();
return bm;
}
示例6: make_image
static void make_image(SkBitmap* bm, SkColorType ct, int configIndex) {
const int width = 98;
const int height = 100;
const SkImageInfo info = SkImageInfo::Make(width, height, ct, kPremul_SkAlphaType);
SkBitmap device;
device.allocN32Pixels(width, height);
SkCanvas canvas(device);
SkPaint paint;
paint.setAntiAlias(true);
canvas.drawColor(SK_ColorRED);
paint.setColor(SK_ColorBLUE);
canvas.drawCircle(SkIntToScalar(width)/2, SkIntToScalar(height)/2,
SkIntToScalar(width)/2, paint);
switch (ct) {
case kPMColor_SkColorType:
bm->swap(device);
break;
case kRGB_565_SkColorType: {
bm->allocPixels(info);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
*bm->getAddr16(x, y) = SkPixel32ToPixel16(*device.getAddr32(x, y));
}
}
break;
}
case kIndex_8_SkColorType: {
SkPMColor colors[256];
for (int i = 0; i < 256; i++) {
if (configIndex & 1) {
colors[i] = SkPackARGB32(255-i, 0, 0, 255-i);
} else {
colors[i] = SkPackARGB32(0xFF, i, 0, 255-i);
}
}
SkColorTable* ctable = new SkColorTable(colors, 256);
bm->allocPixels(info, NULL, ctable);
ctable->unref();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
*bm->getAddr8(x, y) = SkGetPackedR32(*device.getAddr32(x, y));
}
}
break;
}
default:
SkASSERT(0);
}
}
示例7: make_bm
static void make_bm(SkBitmap* bm) {
const SkColor colors[] = {
SK_ColorRED, SK_ColorGREEN,
SK_ColorBLUE, SK_ColorWHITE
};
SkColorTable* ctable = new SkColorTable(colors, 4);
bm->setConfig(SkBitmap::kIndex8_Config, 2, 2);
bm->allocPixels(ctable);
ctable->unref();
*bm->getAddr8(0, 0) = 0;
*bm->getAddr8(1, 0) = 1;
*bm->getAddr8(0, 1) = 2;
*bm->getAddr8(1, 1) = 3;
}
示例8: make_bitmap
static SkBitmap make_bitmap() {
const SkPMColor c[] = { SkPackARGB32(0x80, 0x80, 0, 0) };
SkColorTable* ctable = new SkColorTable(c, SK_ARRAY_COUNT(c));
SkBitmap bm;
bm.allocPixels(SkImageInfo::Make(1, 1, kIndex_8_SkColorType,
kPremul_SkAlphaType),
NULL, ctable);
ctable->unref();
bm.lockPixels();
*bm.getAddr8(0, 0) = 0;
bm.unlockPixels();
return bm;
}
示例9: make_bm
static void make_bm(SkBitmap* bm) {
const SkPMColor colors[] = {
SkPreMultiplyColor(SK_ColorRED), SkPreMultiplyColor(SK_ColorGREEN),
SkPreMultiplyColor(SK_ColorBLUE), SkPreMultiplyColor(SK_ColorWHITE)
};
SkColorTable* ctable = new SkColorTable(colors, 4);
bm->allocPixels(SkImageInfo::Make(2, 2, kIndex_8_SkColorType,
kOpaque_SkAlphaType),
nullptr, ctable);
ctable->unref();
*bm->getAddr8(0, 0) = 0;
*bm->getAddr8(1, 0) = 1;
*bm->getAddr8(0, 1) = 2;
*bm->getAddr8(1, 1) = 3;
}
示例10: make_bitmap
static SkBitmap make_bitmap() {
SkBitmap bm;
SkColorTable* ctable = new SkColorTable(1);
SkPMColor* c = ctable->lockColors();
c[0] = SkPackARGB32(0x80, 0x80, 0, 0);
ctable->unlockColors(true);
bm.setConfig(SkBitmap::kIndex8_Config, 1, 1);
bm.allocPixels(ctable);
ctable->unref();
bm.lockPixels();
*bm.getAddr8(0, 0) = 0;
bm.unlockPixels();
return bm;
}
示例11: make_bm
static void make_bm(SkBitmap* bm) {
const SkColor colors[4] = {
SK_ColorRED, SK_ColorGREEN,
SK_ColorBLUE, SK_ColorWHITE
};
SkPMColor colorsPM[4];
for (size_t i = 0; i < SK_ARRAY_COUNT(colors); ++i) {
colorsPM[i] = SkPreMultiplyColor(colors[i]);
}
SkColorTable* ctable = new SkColorTable(colorsPM, 4);
bm->setConfig(SkBitmap::kIndex8_Config, 2, 2);
bm->allocPixels(ctable);
ctable->unref();
*bm->getAddr8(0, 0) = 0;
*bm->getAddr8(1, 0) = 1;
*bm->getAddr8(0, 1) = 2;
*bm->getAddr8(1, 1) = 3;
}
示例12: make_bm
static void make_bm(SkBitmap* bm) {
const SkColor colors[4] = {
SK_ColorRED, SK_ColorGREEN,
SK_ColorBLUE, SK_ColorWHITE
};
SkPMColor colorsPM[4];
for (size_t i = 0; i < SK_ARRAY_COUNT(colors); ++i) {
colorsPM[i] = SkPreMultiplyColor(colors[i]);
}
SkColorTable* ctable = new SkColorTable(colorsPM, 4);
bm->allocPixels(SkImageInfo::Make(2, 2, kIndex_8_SkColorType,
kPremul_SkAlphaType),
NULL, ctable);
ctable->unref();
*bm->getAddr8(0, 0) = 0;
*bm->getAddr8(1, 0) = 1;
*bm->getAddr8(0, 1) = 2;
*bm->getAddr8(1, 1) = 3;
}
示例13: make_bitmap
static SkBitmap make_bitmap() {
SkPMColor c[256];
for (int i = 0; i < 256; i++) {
c[i] = SkPackARGB32(0xFF, i, 0, 0);
}
SkColorTable* ctable = new SkColorTable(c, 256);
SkBitmap bm;
bm.allocPixels(SkImageInfo::Make(256, 32, kIndex_8_SkColorType, kPremul_SkAlphaType),
nullptr, ctable);
ctable->unref();
bm.lockPixels();
for (int y = 0; y < bm.height(); y++) {
uint8_t* p = bm.getAddr8(0, y);
for (int x = 0; x < 256; x++) {
p[x] = x;
}
}
bm.unlockPixels();
return bm;
}
示例14: make_bm
/*
SampleFilter = 滤镜样子 : 滤镜的作用与效果 见 百度百科
流程 : FilterView() -> make_bm() ->
onDrawContent() -> draw_row() -> draw_set() -> draw_bm()
*/
static void make_bm(SkBitmap* bm) {
const SkColor colors[] = {
SK_ColorRED, SK_ColorGREEN,
SK_ColorBLUE, SK_ColorWHITE
};
//颜色表 存储4个颜色
SkColorTable* ctable = new SkColorTable(colors, 4);
//bitmap设置格式 为一个像素8位, 共2*2个像素
bm->setConfig(SkBitmap::kIndex8_Config, 2, 2);
//bitmap分配实际内存, 按照以上格式
bm->allocPixels(ctable);
//颜色表的引用值-1 :见到0时释放,
ctable->unref();
/*获取kIndex8_Config的bitmap的 (0,0)像素内存位置, 赋值0, 为索引0的颜色..
依次将红, 绿, 蓝, 白赋值给4个像素 : 见结果图样式. */
*bm->getAddr8(0, 0) = 0;
*bm->getAddr8(1, 0) = 1;
*bm->getAddr8(0, 1) = 2;
*bm->getAddr8(1, 1) = 3;
}
示例15: make_bitmap
static SkBitmap make_bitmap() {
const int N = 1;
SkPMColor c[N];
for (int i = 0; i < N; i++) {
c[i] = SkPackARGB32(0x80, 0x80, 0, 0);
}
SkColorTable* ctable = new SkColorTable(c, N);
SkBitmap bm;
bm.setConfig(SkBitmap::kIndex8_Config, 1, 1);
bm.allocPixels(ctable);
ctable->unref();
bm.lockPixels();
for (int y = 0; y < bm.height(); y++) {
uint8_t* p = bm.getAddr8(0, y);
for (int x = 0; x < bm.width(); x++) {
p[x] = 0;
}
}
bm.unlockPixels();
return bm;
}