本文整理汇总了C++中SkBitmap::copyTo方法的典型用法代码示例。如果您正苦于以下问题:C++ SkBitmap::copyTo方法的具体用法?C++ SkBitmap::copyTo怎么用?C++ SkBitmap::copyTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkBitmap
的用法示例。
在下文中一共展示了SkBitmap::copyTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FilterView
FilterView() {
make_bm(&fBM8);
fBM8.copyTo(&fBM4444, kARGB_4444_SkColorType);
fBM8.copyTo(&fBM16, kRGB_565_SkColorType);
fBM8.copyTo(&fBM32, kN32_SkColorType);
this->setBGColor(0xFFDDDDDD);
}
示例2:
FilterView() {
make_bm(&fBM8);
fBM8.copyTo(&fBM4444, SkBitmap::kARGB_4444_Config);
fBM8.copyTo(&fBM16, SkBitmap::kRGB_565_Config);
fBM8.copyTo(&fBM32, SkBitmap::kARGB_8888_Config);
this->setBGColor(0xFFDDDDDD);
}
示例3:
FilterView() {
/*做一张bitmap, kIndex8_Config格式的2行2列
依次转换成 其他3种格式的bitmap : 见结果图, 对应4行.*/
make_bm(&fBM8);
fBM8.copyTo(&fBM4444, SkBitmap::kARGB_4444_Config);
fBM8.copyTo(&fBM16, SkBitmap::kRGB_565_Config);
fBM8.copyTo(&fBM32, SkBitmap::kARGB_8888_Config);
//设置背景色 为 灰色 : 见结果图
this->setBGColor(0xFFDDDDDD);
}
示例4: compare
static void compare(const SkBitmap& target, const SkBitmap& base,
const SkString& name) {
SkBitmap copy;
const SkBitmap* bm = ⌖
if (target.config() != SkBitmap::kARGB_8888_Config) {
target.copyTo(©, SkBitmap::kARGB_8888_Config);
bm = ©
}
force_all_opaque(*bm);
const int w = bm->width();
const int h = bm->height();
if (w != base.width() || h != base.height()) {
SkDebugf("---- dimensions mismatch for %s base [%d %d] current [%d %d]\n",
name.c_str(), base.width(), base.height(), w, h);
return;
}
SkAutoLockPixels bmLock(*bm);
SkAutoLockPixels baseLock(base);
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
SkPMColor c0 = *base.getAddr32(x, y);
SkPMColor c1 = *bm->getAddr32(x, y);
if (c0 != c1) {
SkDebugf("----- pixel mismatch for %s at [%d %d] base 0x%08X current 0x%08X\n",
name.c_str(), x, y, c0, c1);
return;
}
}
}
}
示例5: GfxFormatToSkiaColorType
bool
SourceSurfaceSkia::InitFromData(unsigned char* aData,
const IntSize &aSize,
int32_t aStride,
SurfaceFormat aFormat)
{
SkBitmap temp;
SkAlphaType alphaType = (aFormat == SurfaceFormat::B8G8R8X8) ?
kOpaque_SkAlphaType : kPremul_SkAlphaType;
SkImageInfo info = SkImageInfo::Make(aSize.width,
aSize.height,
GfxFormatToSkiaColorType(aFormat),
alphaType);
temp.setInfo(info, aStride);
temp.setPixels(aData);
if (!temp.copyTo(&mBitmap, GfxFormatToSkiaColorType(aFormat))) {
return false;
}
if (aFormat == SurfaceFormat::B8G8R8X8) {
mBitmap.setAlphaType(kIgnore_SkAlphaType);
}
mSize = aSize;
mFormat = aFormat;
mStride = mBitmap.rowBytes();
return true;
}
示例6: onReadPixels
bool SkBitmapDevice::onReadPixels(const SkBitmap& bitmap,
int x, int y,
SkCanvas::Config8888 config8888) {
SkASSERT(SkBitmap::kARGB_8888_Config == bitmap.config());
SkASSERT(!bitmap.isNull());
SkASSERT(SkIRect::MakeWH(this->width(), this->height()).contains(SkIRect::MakeXYWH(x, y,
bitmap.width(),
bitmap.height())));
SkIRect srcRect = SkIRect::MakeXYWH(x, y, bitmap.width(), bitmap.height());
const SkBitmap& src = this->accessBitmap(false);
SkBitmap subset;
if (!src.extractSubset(&subset, srcRect)) {
return false;
}
if (kPMColor_SkColorType != subset.colorType()) {
// It'd be preferable to do this directly to bitmap.
subset.copyTo(&subset, kPMColor_SkColorType);
}
SkAutoLockPixels alp(bitmap);
uint32_t* bmpPixels = reinterpret_cast<uint32_t*>(bitmap.getPixels());
SkCopyBitmapToConfig8888(bmpPixels, bitmap.rowBytes(), config8888, subset);
return true;
}
示例7: write_bitmap
bool write_bitmap(const SkString& path, const SkBitmap& bitmap) {
SkBitmap copy;
bitmap.copyTo(©, kN32_SkColorType);
force_all_opaque(copy);
return SkImageEncoder::EncodeFile(path.c_str(), copy,
SkImageEncoder::kPNG_Type, 100);
}
示例8: Scale
bool Scale(uint8_t* srcData, int32_t srcWidth, int32_t srcHeight, int32_t srcStride,
uint8_t* dstData, int32_t dstWidth, int32_t dstHeight, int32_t dstStride,
SurfaceFormat format)
{
#ifdef USE_SKIA
SkAlphaType alphaType;
if (format == SurfaceFormat::B8G8R8A8) {
alphaType = kPremul_SkAlphaType;
} else {
alphaType = kOpaque_SkAlphaType;
}
SkBitmap::Config config = GfxFormatToSkiaConfig(format);
SkBitmap imgSrc;
imgSrc.setConfig(config, srcWidth, srcHeight, srcStride, alphaType);
imgSrc.setPixels(srcData);
// Rescaler is compatible with 32 bpp only. Convert to RGB32 if needed.
if (config != SkBitmap::kARGB_8888_Config) {
imgSrc.copyTo(&imgSrc, SkBitmap::kARGB_8888_Config);
}
// This returns an SkBitmap backed by dstData; since it also wrote to dstData,
// we don't need to look at that SkBitmap.
SkBitmap result = skia::ImageOperations::Resize(imgSrc,
skia::ImageOperations::RESIZE_BEST,
dstWidth, dstHeight,
dstData);
return !result.isNull();
#else
return false;
#endif
}
示例9:
DitherBitmapView() {
test_pathregion();
fBM8 = make_bitmap();
fBM8.copyTo(&fBM32, SkBitmap::kARGB_8888_Config);
this->setBGColor(0xFFDDDDDD);
}
示例10: dumpAlphaTexture
bool dumpAlphaTexture(int width, int height, uint8_t *data, const char *prefix, SkBitmap::Config format)
{
static int count = 0;
char procName[256];
char file[512];
SkBitmap bitmap;
SkBitmap bitmapCopy;
if (!getProcessName(procName, sizeof(procName)))
return false;
sprintf(file, "/data/data/%s/%s_%04d.png", procName, prefix, count++);
XLOGI("%s: %dx%d %s\n", __FUNCTION__, width, height, file);
bitmap.setConfig(format, width, height);
bitmap.setPixels(data, NULL);
if (!bitmap.copyTo(&bitmapCopy, SkBitmap::kARGB_8888_Config))
{
XLOGD("%s: Failed to copy data", __FUNCTION__);
return false;
}
if (!SkImageEncoder::EncodeFile(file, bitmapCopy, SkImageEncoder::kPNG_Type, 100))
{
XLOGE("%s: Failed to encode image %s\n", __FUNCTION__, file);
return false;
}
return true;
}
示例11: ConvertBGRXToBGRA
bool
SourceSurfaceSkia::InitFromData(unsigned char* aData,
const IntSize &aSize,
int32_t aStride,
SurfaceFormat aFormat)
{
SkBitmap temp;
temp.setConfig(GfxFormatToSkiaConfig(aFormat), aSize.width, aSize.height, aStride);
temp.setPixels(aData);
if (!temp.copyTo(&mBitmap, GfxFormatToSkiaConfig(aFormat))) {
return false;
}
if (aFormat == FORMAT_B8G8R8X8) {
mBitmap.lockPixels();
// We have to manually set the A channel to be 255 as Skia doesn't understand BGRX
ConvertBGRXToBGRA(reinterpret_cast<unsigned char*>(mBitmap.getPixels()), aSize, aStride);
mBitmap.unlockPixels();
mBitmap.notifyPixelsChanged();
mBitmap.setIsOpaque(true);
}
mSize = aSize;
mFormat = aFormat;
mStride = aStride;
return true;
}
示例12: DitherBitmapView
DitherBitmapView() {
fResult = test_pathregion();
fBM8 = make_bitmap();
fBM8.copyTo(&fBM32, kN32_SkColorType);
this->setBGColor(0xFFDDDDDD);
}
示例13: image
PassRefPtr<BitmapImageSingleFrameSkia> BitmapImageSingleFrameSkia::create(const SkBitmap& bitmap)
{
RefPtr<BitmapImageSingleFrameSkia> image(adoptRef(new BitmapImageSingleFrameSkia()));
if (!bitmap.copyTo(&image->m_nativeImage, bitmap.config()))
return 0;
return image.release();
}
示例14: deepSkBitmapCopy
static SkBitmap deepSkBitmapCopy(const SkBitmap& bitmap)
{
SkBitmap tmp;
if (!bitmap.deepCopyTo(&tmp, bitmap.config()))
bitmap.copyTo(&tmp, bitmap.config());
return tmp;
}
示例15: adoptRef
PassRefPtr<BitmapImageSingleFrameSkia> BitmapImageSingleFrameSkia::create(const SkBitmap& bitmap, bool copyPixels)
{
if (copyPixels) {
SkBitmap temp;
bitmap.copyTo(&temp, bitmap.config());
return adoptRef(new BitmapImageSingleFrameSkia(temp));
}
return adoptRef(new BitmapImageSingleFrameSkia(bitmap));
}