当前位置: 首页>>代码示例>>C++>>正文


C++ SkBitmap::copyTo方法代码示例

本文整理汇总了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);
    }
开发者ID:03050903,项目名称:skia,代码行数:8,代码来源:SampleFilter.cpp

示例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);
    }
开发者ID:ACSOP,项目名称:android_external_skia,代码行数:8,代码来源:SampleFilter.cpp

示例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);
    }
开发者ID:jetlive,项目名称:skiaming,代码行数:11,代码来源:1-SampleFilter-注释-follow.cpp

示例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(&copy, 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;
            }
        }
    }
}
开发者ID:AOSP-JF-MM,项目名称:platform_external_skia,代码行数:34,代码来源:gmmain.cpp

示例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;
}
开发者ID:Jar-win,项目名称:Waterfox,代码行数:30,代码来源:SourceSurfaceSkia.cpp

示例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;
}
开发者ID:lalalaring,项目名称:shade,代码行数:25,代码来源:SkBitmapDevice.cpp

示例7: write_bitmap

bool write_bitmap(const SkString& path, const SkBitmap& bitmap) {
    SkBitmap copy;
    bitmap.copyTo(&copy, kN32_SkColorType);
    force_all_opaque(copy);
    return SkImageEncoder::EncodeFile(path.c_str(), copy,
                                      SkImageEncoder::kPNG_Type, 100);
}
开发者ID:aseprite,项目名称:skia,代码行数:7,代码来源:skdiff_utils.cpp

示例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
}
开发者ID:JCROM-FxOS,项目名称:b2jc_gecko,代码行数:35,代码来源:Scale.cpp

示例9:

	DitherBitmapView() {
        test_pathregion();
        fBM8 = make_bitmap();
        fBM8.copyTo(&fBM32, SkBitmap::kARGB_8888_Config);
        
        this->setBGColor(0xFFDDDDDD);
    }
开发者ID:ghub,项目名称:NVprSDK,代码行数:7,代码来源:SampleDitherBitmap.cpp

示例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;
}
开发者ID:ferhung,项目名称:p201-mediatek,代码行数:31,代码来源:MTKDebug.cpp

示例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;
}
开发者ID:Geek-in-Training,项目名称:mozilla-central,代码行数:28,代码来源:SourceSurfaceSkia.cpp

示例12: DitherBitmapView

    DitherBitmapView() {
        fResult = test_pathregion();
        fBM8 = make_bitmap();
        fBM8.copyTo(&fBM32, kN32_SkColorType);

        this->setBGColor(0xFFDDDDDD);
    }
开发者ID:Crawping,项目名称:chromium_extract,代码行数:7,代码来源:SampleDitherBitmap.cpp

示例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();
}
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:7,代码来源:ImageSkia.cpp

示例14: deepSkBitmapCopy

static SkBitmap deepSkBitmapCopy(const SkBitmap& bitmap)
{
    SkBitmap tmp;
    if (!bitmap.deepCopyTo(&tmp, bitmap.config()))
        bitmap.copyTo(&tmp, bitmap.config());

    return tmp;
}
开发者ID:halton,项目名称:blink-crosswalk,代码行数:8,代码来源:ImageBuffer.cpp

示例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));
}
开发者ID:sysrqb,项目名称:chromium-src,代码行数:9,代码来源:ImageSkia.cpp


注:本文中的SkBitmap::copyTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。