本文整理汇总了C++中SkGetPackedG32函数的典型用法代码示例。如果您正苦于以下问题:C++ SkGetPackedG32函数的具体用法?C++ SkGetPackedG32怎么用?C++ SkGetPackedG32使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SkGetPackedG32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ARGB_8888_To_RGB
static void ARGB_8888_To_RGB(const uint8_t* in, uint8_t* rgb, int width,
const SkPMColor*) {
const uint32_t* SK_RESTRICT src = (const uint32_t*)in;
for (int i = 0; i < width; ++i) {
const uint32_t c = *src++;
rgb[0] = SkGetPackedR32(c);
rgb[1] = SkGetPackedG32(c);
rgb[2] = SkGetPackedB32(c);
rgb += 3;
}
}
示例2: preMultipliedBGRAtoRGBA
static void preMultipliedBGRAtoRGBA(const void* pixels, int pixelCount, unsigned char* output)
{
static const SkUnPreMultiply::Scale* scale = SkUnPreMultiply::GetScaleTable();
const SkPMColor* input = static_cast<const SkPMColor*>(pixels);
for (; pixelCount-- > 0; ++input) {
const unsigned alpha = SkGetPackedA32(*input);
if ((alpha != 0) && (alpha != 255)) {
*output++ = SkUnPreMultiply::ApplyScale(scale[alpha], SkGetPackedR32(*input));
*output++ = SkUnPreMultiply::ApplyScale(scale[alpha], SkGetPackedG32(*input));
*output++ = SkUnPreMultiply::ApplyScale(scale[alpha], SkGetPackedB32(*input));
*output++ = alpha;
} else {
*output++ = SkGetPackedR32(*input);
*output++ = SkGetPackedG32(*input);
*output++ = SkGetPackedB32(*input);
*output++ = alpha;
}
}
}
示例3: ToColor_SI8_Opaque
static void ToColor_SI8_Opaque(SkColor dst[], const void* src, int width,
SkColorTable* ctable) {
SkASSERT(width > 0);
const uint8_t* s = (const uint8_t*)src;
const SkPMColor* colors = ctable->lockColors();
do {
SkPMColor c = colors[*s++];
*dst++ = SkColorSetRGB(SkGetPackedR32(c), SkGetPackedG32(c),
SkGetPackedB32(c));
} while (--width != 0);
ctable->unlockColors(false);
}
示例4: color_dist32
// returns 0..255
static unsigned color_dist32(SkPMColor c, U8CPU r, U8CPU g, U8CPU b)
{
SkASSERT(r <= 0xFF);
SkASSERT(g <= 0xFF);
SkASSERT(b <= 0xFF);
unsigned dr = SkAbs32(SkGetPackedR32(c) - r);
unsigned dg = SkAbs32(SkGetPackedG32(c) - g);
unsigned db = SkAbs32(SkGetPackedB32(c) - b);
return SkMax32(dr, SkMax32(dg, db));
}
示例5: SkGetPackedR32
void SkPowerMode::xfer16(uint16_t dst[], const SkPMColor src[], int count,
const SkAlpha aa[]) {
for (int i = 0; i < count; i++) {
SkPMColor c = src[i];
int r = SkGetPackedR32(c);
int g = SkGetPackedG32(c);
int b = SkGetPackedB32(c);
r = fTable[r];
g = fTable[g];
b = fTable[b];
dst[i] = SkPack888ToRGB16(r, g, b);
}
}
示例6: rgb2yuv_32
static void rgb2yuv_32(uint8_t dst[], SkPMColor c) {
int r = SkGetPackedR32(c);
int g = SkGetPackedG32(c);
int b = SkGetPackedB32(c);
int y = ( CYR*r + CYG*g + CYB*b ) >> CSHIFT;
int u = ( CUR*r + CUG*g + CUB*b ) >> CSHIFT;
int v = ( CVR*r + CVG*g + CVB*b ) >> CSHIFT;
dst[0] = SkToU8(y);
dst[1] = SkToU8(u + 128);
dst[2] = SkToU8(v + 128);
}
示例7: unpremul_pm
static SkPMColor unpremul_pm(SkPMColor c) {
const U8CPU a = SkGetPackedA32(c);
if (0 == a) {
return 0;
} else if (0xFF == a) {
return c;
}
const unsigned scale = SkUnPreMultiply::GetScale(a);
return SkPackARGB32NoCheck(a,
SkUnPreMultiply::ApplyScale(scale, SkGetPackedR32(c)),
SkUnPreMultiply::ApplyScale(scale, SkGetPackedG32(c)),
SkUnPreMultiply::ApplyScale(scale, SkGetPackedB32(c)));
}
示例8: apply_gamma
static void apply_gamma(const SkBitmap& bm) {
return; // below is our experiment for sRGB correction
bm.lockPixels();
for (int y = 0; y < bm.height(); ++y) {
for (int x = 0; x < bm.width(); ++x) {
SkPMColor c = *bm.getAddr32(x, y);
unsigned r = gamma(SkGetPackedR32(c));
unsigned g = gamma(SkGetPackedG32(c));
unsigned b = gamma(SkGetPackedB32(c));
*bm.getAddr32(x, y) = SkPackARGB32(0xFF, r, g, b);
}
}
}
示例9: blit_lcd16_opaque
static void blit_lcd16_opaque(SkPMColor dst[], const uint16_t src[],
SkPMColor color, int width) {
int srcR = SkGetPackedR32(color);
int srcG = SkGetPackedG32(color);
int srcB = SkGetPackedB32(color);
for (int i = 0; i < width; i++) {
uint16_t mask = src[i];
if (0 == mask) {
continue;
}
SkPMColor d = dst[i];
/* We want all of these in 5bits, hence the shifts in case one of them
* (green) is 6bits.
*/
int maskR = SkGetPackedR16(mask) >> (SK_R16_BITS - 5);
int maskG = SkGetPackedG16(mask) >> (SK_G16_BITS - 5);
int maskB = SkGetPackedB16(mask) >> (SK_B16_BITS - 5);
// Now upscale them to 0..256, so we can use SkAlphaBlend
maskR = upscale31To32(maskR);
maskG = upscale31To32(maskG);
maskB = upscale31To32(maskB);
int maskA = SkMax32(SkMax32(maskR, maskG), maskB);
int dstA = SkGetPackedA32(d);
int dstR = SkGetPackedR32(d);
int dstG = SkGetPackedG32(d);
int dstB = SkGetPackedB32(d);
dst[i] = SkPackARGB32(blend32(0xFF, dstA, maskA),
blend32(srcR, dstR, maskR),
blend32(srcG, dstG, maskG),
blend32(srcB, dstB, maskB));
}
}
示例10: S32A_D565_Blend_1
static inline bool S32A_D565_Blend_1(SkPMColor sc, uint16_t dc, U8CPU alpha) {
unsigned dst_scale = 255 - SkMulDiv255Round(SkGetPackedA32(sc), alpha);
unsigned dr = (SkMulS16(SkGetPackedR32(sc), alpha) >> 3) + SkMulS16(SkGetPackedR16(dc), dst_scale);
unsigned dg = (SkMulS16(SkGetPackedG32(sc), alpha) >> 2) + SkMulS16(SkGetPackedG16(dc), dst_scale);
unsigned rr = SkDiv255Round(dr);
unsigned rg = SkDiv255Round(dg);
if (rr <= 31 && rg <= 63) {
return true;
}
return false;
}
示例11: similarBits
static int similarBits(const SkBitmap& gr, const SkBitmap& sk) {
const int kRowCount = 3;
const int kThreshold = 3;
int width = SkTMin(gr.width(), sk.width());
if (width < kRowCount) {
return true;
}
int height = SkTMin(gr.height(), sk.height());
if (height < kRowCount) {
return true;
}
int errorTotal = 0;
SkTArray<char, true> errorRows;
errorRows.push_back_n(width * kRowCount);
SkAutoLockPixels autoGr(gr);
SkAutoLockPixels autoSk(sk);
char* base = &errorRows[0];
for (int y = 0; y < height; ++y) {
SkPMColor* grRow = gr.getAddr32(0, y);
SkPMColor* skRow = sk.getAddr32(0, y);
char* cOut = &errorRows[(y % kRowCount) * width];
for (int x = 0; x < width; ++x) {
SkPMColor grColor = grRow[x];
SkPMColor skColor = skRow[x];
int dr = SkGetPackedR32(grColor) - SkGetPackedR32(skColor);
int dg = SkGetPackedG32(grColor) - SkGetPackedG32(skColor);
int db = SkGetPackedB32(grColor) - SkGetPackedB32(skColor);
int error = SkTMax(SkAbs32(dr), SkTMax(SkAbs32(dg), SkAbs32(db)));
if ((cOut[x] = error >= kThreshold) && x >= 2
&& base[x - 2] && base[width + x - 2] && base[width * 2 + x - 2]
&& base[x - 1] && base[width + x - 1] && base[width * 2 + x - 1]
&& base[x - 0] && base[width + x - 0] && base[width * 2 + x - 0]) {
errorTotal += error;
}
}
}
return errorTotal;
}
示例12: SkGetPackedA32
bool Image::ConvertToRGBA(Image *nimg,
unsigned char *rgba,
bool flipY,
bool premultiply)
{
int length;
int k;
const unsigned char *pixels;
int width;
nimg->m_Image->lockPixels();
if ((pixels
= static_cast<const unsigned char *>(nimg->m_Image->getPixels()))
== NULL) {
nimg->m_Image->unlockPixels();
return false;
}
width = nimg->getWidth();
length = width * nimg->getHeight() * 4;
width *= 4;
k = flipY ? length - width : 0;
for (int i = 0; i < length; i += 4) {
const uint32_t pixel = *reinterpret_cast<const uint32_t *>(&pixels[i]);
int alpha = SkGetPackedA32(pixel);
if (alpha != 0 && alpha != 255 && !premultiply) {
SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel);
rgba[k + 0] = SkColorGetR(unmultiplied);
rgba[k + 1] = SkColorGetG(unmultiplied);
rgba[k + 2] = SkColorGetB(unmultiplied);
rgba[k + 3] = alpha;
} else {
rgba[k + 0] = SkGetPackedR32(pixel);
rgba[k + 1] = SkGetPackedG32(pixel);
rgba[k + 2] = SkGetPackedB32(pixel);
rgba[k + 3] = alpha;
}
if (flipY && (i + 4) % width == 0) {
k = length - (i + 4) - width;
} else {
k += 4;
}
}
return true;
}
示例13: blit_lcd32_opaque
static void blit_lcd32_opaque(SkPMColor dst[], const uint32_t src[],
SkPMColor color, int width) {
int srcR = SkGetPackedR32(color);
int srcG = SkGetPackedG32(color);
int srcB = SkGetPackedB32(color);
for (int i = 0; i < width; i++) {
uint32_t mask = src[i];
if (0 == mask) {
continue;
}
SkPMColor d = dst[i];
int maskR = SkGetPackedR32(mask);
int maskG = SkGetPackedG32(mask);
int maskB = SkGetPackedB32(mask);
// Now upscale them to 0..256, so we can use SkAlphaBlend
maskR = SkAlpha255To256(maskR);
maskG = SkAlpha255To256(maskG);
maskB = SkAlpha255To256(maskB);
int maskA = SkMax32(SkMax32(maskR, maskG), maskB);
int dstA = SkGetPackedA32(d);
int dstR = SkGetPackedR32(d);
int dstG = SkGetPackedG32(d);
int dstB = SkGetPackedB32(d);
dst[i] = SkPackARGB32(SkAlphaBlend(0xFF, dstA, maskA),
SkAlphaBlend(srcR, dstR, maskR),
SkAlphaBlend(srcG, dstG, maskG),
SkAlphaBlend(srcB, dstB, maskB));
}
}
示例14: SkTMin
void SkNormalMapSourceImpl::Provider::fillScanLine(int x, int y, SkPoint3 output[],
int count) const {
SkPMColor tmpNormalColors[BUFFER_MAX];
do {
int n = SkTMin(count, BUFFER_MAX);
fMapContext->shadeSpan(x, y, tmpNormalColors, n);
for (int i = 0; i < n; i++) {
SkPoint3 tempNorm;
tempNorm.set(SkIntToScalar(SkGetPackedR32(tmpNormalColors[i])) - 127.0f,
SkIntToScalar(SkGetPackedG32(tmpNormalColors[i])) - 127.0f,
SkIntToScalar(SkGetPackedB32(tmpNormalColors[i])) - 127.0f);
tempNorm.normalize();
if (!SkScalarNearlyEqual(SkScalarAbs(tempNorm.fZ), 1.0f)) {
SkVector transformed = fSource.fInvCTM.mapVector(tempNorm.fX, tempNorm.fY);
// Normalizing the transformed X and Y, while keeping constant both Z and the
// vector's angle in the XY plane. This maintains the "slope" for the surface while
// appropriately rotating the normal for any anisotropic scaling that occurs.
// Here, we call scaling factor the number that must divide the transformed X and Y
// so that the normal's length remains equal to 1.
SkScalar scalingFactorSquared =
(SkScalarSquare(transformed.fX) + SkScalarSquare(transformed.fY))
/ (1.0f - SkScalarSquare(tempNorm.fZ));
SkScalar invScalingFactor = SkScalarInvert(SkScalarSqrt(scalingFactorSquared));
output[i].fX = transformed.fX * invScalingFactor;
output[i].fY = transformed.fY * invScalingFactor;
output[i].fZ = tempNorm.fZ;
} else {
output[i] = {0.0f, 0.0f, tempNorm.fZ};
output[i].normalize();
}
SkASSERT(SkScalarNearlyEqual(output[i].length(), 1.0f));
}
output += n;
x += n;
count -= n;
} while (count > 0);
}
示例15: S32A_D565_Blend_02
static inline bool S32A_D565_Blend_02(SkPMColor sc, uint16_t dc, U8CPU alpha) {
unsigned dst_scale = 255 - SkMulDiv255Round(SkGetPackedA32(sc), alpha);
unsigned dr = SkMulS16(SkGetPackedR32(sc), alpha) + SkMulS16(GetPackedR16As32(dc), dst_scale);
unsigned dg = SkMulS16(SkGetPackedG32(sc), alpha) + SkMulS16(GetPackedG16As32(dc), dst_scale);
unsigned db = SkMulS16(SkGetPackedB32(sc), alpha) + SkMulS16(GetPackedB16As32(dc), dst_scale);
int rc = SkPack888ToRGB16(SkDiv255Round(dr),
SkDiv255Round(dg),
SkDiv255Round(db));
unsigned rr = SkGetPackedR16(rc);
unsigned rg = SkGetPackedG16(rc);
if (rr <= 31 && rg <= 63) {
return true;
}
return false;
}