本文整理汇总了C++中SkColorGetB函数的典型用法代码示例。如果您正苦于以下问题:C++ SkColorGetB函数的具体用法?C++ SkColorGetB怎么用?C++ SkColorGetB使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SkColorGetB函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SkNEW
SkColorFilter* SkColorFilter::CreateLightingFilter(SkColor mul, SkColor add) {
mul &= 0x00FFFFFF;
add &= 0x00FFFFFF;
if (0xFFFFFF == mul) {
if (0 == add) {
return SkNEW(SkSimpleColorFilter); // no change to the colors
} else {
return SkNEW_ARGS(SkLightingColorFilter_JustAdd, (mul, add));
}
}
if (0 == add) {
if (SkColorGetR(mul) == SkColorGetG(mul) &&
SkColorGetR(mul) == SkColorGetB(mul)) {
return SkNEW_ARGS(SkLightingColorFilter_SingleMul, (mul, add));
} else {
return SkNEW_ARGS(SkLightingColorFilter_JustMul, (mul, add));
}
}
if (SkColorGetR(mul) + SkColorGetR(add) <= 255 &&
SkColorGetG(mul) + SkColorGetG(add) <= 255 &&
SkColorGetB(mul) + SkColorGetB(add) <= 255) {
return SkNEW_ARGS(SkLightingColorFilter_NoPin, (mul, add));
}
return SkNEW_ARGS(SkLightingColorFilter, (mul, add));
}
示例2: setupShapePaint
void setupShapePaint(SkCanvas* canvas, GrColor color, SkXfermode::Mode mode, SkPaint* paint) {
paint->setColor(color);
if (mode == SkXfermode::kPlus_Mode) {
// Check for overflow, otherwise we might get confusing AA artifacts.
int maxSum = SkTMax(SkTMax(SkColorGetA(kBGColor) + SkColorGetA(color),
SkColorGetR(kBGColor) + SkColorGetR(color)),
SkTMax(SkColorGetG(kBGColor) + SkColorGetG(color),
SkColorGetB(kBGColor) + SkColorGetB(color)));
if (maxSum > 255) {
SkPaint dimPaint;
dimPaint.setAntiAlias(false);
dimPaint.setXfermode(SkXfermode::Create(SkXfermode::kDstIn_Mode));
if (255 != paint->getAlpha()) {
// Dim the src and dst colors.
dimPaint.setARGB(255 * 255 / maxSum, 0, 0, 0);
paint->setAlpha(255 * paint->getAlpha() / maxSum);
} else {
// Just clear the dst, we need to preserve the paint's opacity.
dimPaint.setARGB(0, 0, 0, 0);
}
canvas->drawRectCoords(-kShapeSpacing/2, -kShapeSpacing/2,
kShapeSpacing/2 + 3 * kShapeTypeSpacing,
kShapeSpacing/2, dimPaint);
}
}
}
示例3: GetColor
static SkColor GetColor(SkRandom* random, int i, int nextColor) {
static SkColor colors[] = { SK_ColorRED,
sk_tool_utils::color_to_565(0xFFFF7F00), // Orange
SK_ColorYELLOW,
SK_ColorGREEN,
SK_ColorBLUE,
sk_tool_utils::color_to_565(0xFF4B0082), // indigo
sk_tool_utils::color_to_565(0xFF7F00FF) }; // violet
SkColor color;
int index = nextColor % SK_ARRAY_COUNT(colors);
switch (i) {
case 0:
color = SK_ColorTRANSPARENT;
break;
case 1:
color = SkColorSetARGB(0xff,
SkColorGetR(colors[index]),
SkColorGetG(colors[index]),
SkColorGetB(colors[index]));
break;
default:
uint8_t alpha = 0x80;
color = SkColorSetARGB(alpha,
SkColorGetR(colors[index]),
SkColorGetG(colors[index]),
SkColorGetB(colors[index]));
break;
}
return color;
}
示例4: SkLightingColorFilter_SingleMul
SkLightingColorFilter_SingleMul(SkColor mul, SkColor add)
: INHERITED(mul, add) {
SkASSERT(SkColorGetR(add) == 0);
SkASSERT(SkColorGetG(add) == 0);
SkASSERT(SkColorGetB(add) == 0);
SkASSERT(SkColorGetR(mul) == SkColorGetG(mul));
SkASSERT(SkColorGetR(mul) == SkColorGetB(mul));
}
示例5: draw_shadow
void draw_shadow(SkCanvas* canvas, const SkPath& path, SkScalar height, SkColor color,
SkPoint3 lightPos, SkScalar lightR, bool isAmbient, uint32_t flags) {
SkScalar ambientAlpha = isAmbient ? .5f : 0.f;
SkScalar spotAlpha = isAmbient ? 0.f : .5f;
SkColor ambientColor = SkColorSetARGB(ambientAlpha*SkColorGetA(color), SkColorGetR(color),
SkColorGetG(color), SkColorGetB(color));
SkColor spotColor = SkColorSetARGB(spotAlpha*SkColorGetA(color), SkColorGetR(color),
SkColorGetG(color), SkColorGetB(color));
SkShadowUtils::DrawShadow(canvas, path, SkPoint3{ 0, 0, height}, lightPos, lightR,
ambientColor, spotColor, flags);
}
示例6: byte_to_scale
SkColorFilter* SkColorFilter::CreateLightingFilter(SkColor mul, SkColor add) {
SkColorMatrix matrix;
matrix.setScale(byte_to_scale(SkColorGetR(mul)),
byte_to_scale(SkColorGetG(mul)),
byte_to_scale(SkColorGetB(mul)),
1);
matrix.postTranslate(SkIntToScalar(SkColorGetR(add)),
SkIntToScalar(SkColorGetG(add)),
SkIntToScalar(SkColorGetB(add)),
0);
return SkColorMatrixFilter::Create(matrix);
}
示例7: DEF_TEST
DEF_TEST(SkColorSpace_New_TransferFnStages, r) {
// We'll create a little SkRasterPipelineBlitter-like scenario,
// blending the same src color over the same dst color, but with
// three different transfer functions, for simplicity the same for src and dst.
SkColor src = 0x7f7f0000;
SkColor dsts[3];
for (SkColor& dst : dsts) {
dst = 0xff007f00;
}
auto gamut = SkMatrix44::I();
auto blending = SkColorSpace_New::Blending::Linear;
SkColorSpace_New linear{SkColorSpace_New::TransferFn::MakeLinear(), gamut, blending},
srgb{SkColorSpace_New::TransferFn::MakeSRGB(), gamut, blending},
gamma{SkColorSpace_New::TransferFn::MakeGamma(3), gamut, blending};
SkColor* dst = dsts;
for (const SkColorSpace_New* cs : {&linear, &srgb, &gamma}) {
SkJumper_MemoryCtx src_ctx = { &src, 0 },
dst_ctx = { dst++, 0 };
SkRasterPipeline_<256> p;
p.append(SkRasterPipeline::load_8888, &src_ctx);
cs->transferFn().linearizeSrc(&p);
p.append(SkRasterPipeline::premul);
p.append(SkRasterPipeline::load_8888_dst, &dst_ctx);
cs->transferFn().linearizeDst(&p);
p.append(SkRasterPipeline::premul_dst);
p.append(SkRasterPipeline::srcover);
p.append(SkRasterPipeline::unpremul);
cs->transferFn().encodeSrc(&p);
p.append(SkRasterPipeline::store_8888, &dst_ctx);
p.run(0,0,1,1);
}
// Double check the uninteresting channels: alpha's opaque, no blue.
REPORTER_ASSERT(r, SkColorGetA(dsts[0]) == 0xff && SkColorGetB(dsts[0]) == 0x00);
REPORTER_ASSERT(r, SkColorGetA(dsts[1]) == 0xff && SkColorGetB(dsts[1]) == 0x00);
REPORTER_ASSERT(r, SkColorGetA(dsts[2]) == 0xff && SkColorGetB(dsts[2]) == 0x00);
// Because we're doing linear blending, a more-exponential transfer function will
// brighten the encoded values more when linearizing. So we expect to see that
// linear is darker than sRGB, and sRGB in turn is darker than gamma 3.
REPORTER_ASSERT(r, SkColorGetR(dsts[0]) < SkColorGetR(dsts[1]));
REPORTER_ASSERT(r, SkColorGetR(dsts[1]) < SkColorGetR(dsts[2]));
REPORTER_ASSERT(r, SkColorGetG(dsts[0]) < SkColorGetG(dsts[1]));
REPORTER_ASSERT(r, SkColorGetG(dsts[1]) < SkColorGetG(dsts[2]));
}
示例8: write_bitmap
static bool write_bitmap(const char outName[], const SkBitmap& bm) {
SkISize size = opaqueSize(bm);
SkBitmap dst;
setup_bitmap(&dst, size.width(), size.height());
for (int y = 0 ; y < dst.height(); y++) {
for (int x = 0 ; x < dst.width(); x++) {
SkColor color = bm.getColor(x, y);
if (SkColorGetA(color) != 0xff) {
int a = SkColorGetA(color);
int r = SkColorGetR(color);
int g = SkColorGetG(color);
int b = SkColorGetB(color);
if (a == 0) {
r = g = b = 0;
} else {
r = (r * a) / 255;
g = (g * a) / 255;
b = (b * a) / 255;
a = 255;
}
color = SkColorSetARGB((U8CPU)a, (U8CPU)r, (U8CPU)g, (U8CPU)b);
}
*dst.getAddr32(x, y) = color;
}
}
return SkImageEncoder::EncodeFile(outName, dst, SkImageEncoder::kPNG_Type, 100);
}
示例9: remove_alpha_argb8888
/**
* Removes the alpha component of an ARGB color (including unpremultiply) while
* keeping the output in the same format as the input.
*/
static uint32_t remove_alpha_argb8888(uint32_t pmColor) {
SkColor color = SkUnPreMultiply::PMColorToColor(pmColor);
return SkPackARGB32NoCheck(SK_AlphaOPAQUE,
SkColorGetR(color),
SkColorGetG(color),
SkColorGetB(color));
}
示例10: setBitmapDash
// Set a bitmap shader that mimics dashing by width-on, width-off.
// Returns false if it could not succeed (e.g. there was an existing shader)
static bool setBitmapDash(SkPaint* paint, int width) {
if (width <= 0 || paint->getShader())
return false;
SkColor c = paint->getColor();
SkBitmap bm;
bm.setConfig(SkBitmap::kARGB_8888_Config, 2, 1);
bm.allocPixels();
bm.lockPixels();
// set the ON pixel
*bm.getAddr32(0, 0) = SkPreMultiplyARGB(0xFF, SkColorGetR(c),
SkColorGetG(c), SkColorGetB(c));
// set the OFF pixel
*bm.getAddr32(1, 0) = 0;
bm.unlockPixels();
SkMatrix matrix;
matrix.setScale(SkIntToScalar(width), SK_Scalar1);
SkShader* s = SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode,
SkShader::kClamp_TileMode);
s->setLocalMatrix(matrix);
paint->setShader(s)->unref();
return true;
}
示例11: INHERITED
SkColorShader::ColorShaderContext::ColorShaderContext(const SkColorShader& shader,
const ContextRec& rec)
: INHERITED(shader, rec)
{
SkColor color = shader.fColor;
unsigned a = SkAlphaMul(SkColorGetA(color), SkAlpha255To256(rec.fPaint->getAlpha()));
unsigned r = SkColorGetR(color);
unsigned g = SkColorGetG(color);
unsigned b = SkColorGetB(color);
// we want this before we apply any alpha
fColor16 = SkPack888ToRGB16(r, g, b);
if (a != 255) {
r = SkMulDiv255Round(r, a);
g = SkMulDiv255Round(g, a);
b = SkMulDiv255Round(b, a);
}
fPMColor = SkPackARGB32(a, r, g, b);
fFlags = kConstInY32_Flag;
if (255 == a) {
fFlags |= kOpaqueAlpha_Flag;
if (rec.fPaint->isDither() == false) {
fFlags |= kHasSpan16_Flag;
}
}
}
示例12: INHERITED
SkARGB4444_Blitter::SkARGB4444_Blitter(const SkBitmap& device,
const SkPaint& paint) : INHERITED(device) {
// cache premultiplied versions in 4444
SkPMColor c = SkPreMultiplyColor(paint.getColor());
fPMColor16 = SkPixel32ToPixel4444(c);
if (paint.isDither()) {
fPMColor16Other = SkDitherPixel32To4444(c);
} else {
fPMColor16Other = fPMColor16;
}
// cache raw versions in 4444
fRawColor16 = SkPackARGB4444(0xFF >> 4, SkColorGetR(c) >> 4,
SkColorGetG(c) >> 4, SkColorGetB(c) >> 4);
if (paint.isDither()) {
fRawColor16Other = SkDitherARGB32To4444(0xFF, SkColorGetR(c),
SkColorGetG(c), SkColorGetB(c));
} else {
fRawColor16Other = fRawColor16;
}
fScale16 = SkAlpha15To16(SkGetPackedA4444(fPMColor16Other));
if (16 == fScale16) {
// force the original to also be opaque
fPMColor16 |= (0xF << SK_A4444_SHIFT);
}
}
示例13: ASSERT
void ImageBuffer::transformColorSpace(ColorSpace srcColorSpace, ColorSpace dstColorSpace)
{
const uint8_t* lookUpTable = ColorSpaceUtilities::getConversionLUT(dstColorSpace, srcColorSpace);
if (!lookUpTable)
return;
// FIXME: Disable color space conversions on accelerated canvases (for now).
if (context()->isAccelerated() || !isSurfaceValid())
return;
const SkBitmap& bitmap = m_surface->bitmap();
if (bitmap.isNull())
return;
ASSERT(bitmap.colorType() == kN32_SkColorType);
IntSize size = m_surface->size();
SkAutoLockPixels bitmapLock(bitmap);
for (int y = 0; y < size.height(); ++y) {
uint32_t* srcRow = bitmap.getAddr32(0, y);
for (int x = 0; x < size.width(); ++x) {
SkColor color = SkPMColorToColor(srcRow[x]);
srcRow[x] = SkPreMultiplyARGB(
SkColorGetA(color),
lookUpTable[SkColorGetR(color)],
lookUpTable[SkColorGetG(color)],
lookUpTable[SkColorGetB(color)]);
}
}
}
示例14: SkColorGetA
bool SkColorShader::setContext(const SkBitmap& device, const SkPaint& paint,
const SkMatrix& matrix) {
if (!this->INHERITED::setContext(device, paint, matrix)) {
return false;
}
SkColor c;
unsigned a;
if (fInheritColor) {
c = paint.getColor();
a = SkColorGetA(c);
} else {
c = fColor;
a = SkAlphaMul(SkColorGetA(c), SkAlpha255To256(paint.getAlpha()));
}
unsigned r = SkColorGetR(c);
unsigned g = SkColorGetG(c);
unsigned b = SkColorGetB(c);
// we want this before we apply any alpha
fColor16 = SkPack888ToRGB16(r, g, b);
if (a != 255) {
a = SkAlpha255To256(a);
r = SkAlphaMul(r, a);
g = SkAlphaMul(g, a);
b = SkAlphaMul(b, a);
}
fPMColor = SkPackARGB32(a, r, g, b);
return true;
}
示例15: RGB_to_HSV
static SkScalar RGB_to_HSV(SkColor color, HSV_Choice choice) {
SkScalar red = SkIntToScalar(SkColorGetR(color));
SkScalar green = SkIntToScalar(SkColorGetG(color));
SkScalar blue = SkIntToScalar(SkColorGetB(color));
SkScalar min = SkMinScalar(SkMinScalar(red, green), blue);
SkScalar value = SkMaxScalar(SkMaxScalar(red, green), blue);
if (choice == kGetValue)
return value/255;
SkScalar delta = value - min;
SkScalar saturation = value == 0 ? 0 : SkScalarDiv(delta, value);
if (choice == kGetSaturation)
return saturation;
SkScalar hue;
if (saturation == 0)
hue = 0;
else {
SkScalar part60 = SkScalarDiv(60 * SK_Scalar1, delta);
if (red == value) {
hue = SkScalarMul(green - blue, part60);
if (hue < 0)
hue += 360 * SK_Scalar1;
}
else if (green == value)
hue = 120 * SK_Scalar1 + SkScalarMul(blue - red, part60);
else // blue == value
hue = 240 * SK_Scalar1 + SkScalarMul(red - green, part60);
}
SkASSERT(choice == kGetHue);
return hue;
}