本文整理汇总了C++中SkBitmap::copyPixelsTo方法的典型用法代码示例。如果您正苦于以下问题:C++ SkBitmap::copyPixelsTo方法的具体用法?C++ SkBitmap::copyPixelsTo怎么用?C++ SkBitmap::copyPixelsTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkBitmap
的用法示例。
在下文中一共展示了SkBitmap::copyPixelsTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: decodeAndScale
bool ImageFrameGenerator::decodeAndScale(size_t index, const SkImageInfo& info, void* pixels, size_t rowBytes)
{
// Prevent concurrent decode or scale operations on the same image data.
MutexLocker lock(m_decodeMutex);
if (m_decodeFailed)
return false;
TRACE_EVENT1("blink", "ImageFrameGenerator::decodeAndScale", "frame index", static_cast<int>(index));
m_externalAllocator = adoptPtr(new ExternalMemoryAllocator(info, pixels, rowBytes));
// This implementation does not support scaling so check the requested size.
SkISize scaledSize = SkISize::Make(info.width(), info.height());
ASSERT(m_fullSize == scaledSize);
SkBitmap bitmap = tryToResumeDecode(index, scaledSize);
if (bitmap.isNull())
return false;
// Don't keep the allocator because it contains a pointer to memory
// that we do not own.
m_externalAllocator.clear();
// Check to see if the decoder has written directly to the pixel memory
// provided. If not, make a copy.
ASSERT(bitmap.width() == scaledSize.width());
ASSERT(bitmap.height() == scaledSize.height());
SkAutoLockPixels bitmapLock(bitmap);
if (bitmap.getPixels() != pixels)
return bitmap.copyPixelsTo(pixels, rowBytes * info.height(), rowBytes);
return true;
}
示例2: createBitmapWithSpace
static SkBitmap createBitmapWithSpace(const SkBitmap& bitmap, int spaceWidth, int spaceHeight)
{
SkImageInfo info = bitmap.info();
info = SkImageInfo::Make(info.width() + spaceWidth, info.height() + spaceHeight, info.colorType(), kPremul_SkAlphaType);
SkBitmap result;
result.allocPixels(info);
result.eraseColor(SK_ColorTRANSPARENT);
bitmap.copyPixelsTo(reinterpret_cast<uint8_t*>(result.getPixels()), result.rowBytes() * result.height(), result.rowBytes());
return result;
}
示例3: createBitmapWithSpace
static SkBitmap createBitmapWithSpace(const SkBitmap& bitmap, int spaceWidth, int spaceHeight)
{
SkBitmap result;
result.setConfig(bitmap.config(),
bitmap.width() + spaceWidth,
bitmap.height() + spaceHeight);
result.allocPixels();
result.eraseColor(SK_ColorTRANSPARENT);
bitmap.copyPixelsTo(reinterpret_cast<uint8_t*>(result.getPixels()), result.rowBytes() * result.height(), result.rowBytes());
return result;
}
示例4: decodeAndScale
bool ImageFrameGenerator::decodeAndScale(const SkImageInfo& info, size_t index, void* pixels, size_t rowBytes)
{
// This method is called to populate a discardable memory owned by Skia.
// Prevents concurrent decode or scale operations on the same image data.
MutexLocker lock(m_decodeMutex);
// This implementation does not support scaling so check the requested size.
SkISize scaledSize = SkISize::Make(info.width(), info.height());
ASSERT(m_fullSize == scaledSize);
if (m_decodeFailedAndEmpty)
return false;
TRACE_EVENT2("blink", "ImageFrameGenerator::decodeAndScale", "generator", this, "decodeCount", m_decodeCount);
m_externalAllocator = adoptPtr(new ExternalMemoryAllocator(info, pixels, rowBytes));
SkBitmap bitmap = tryToResumeDecode(scaledSize, index);
if (bitmap.isNull())
return false;
// Don't keep the allocator because it contains a pointer to memory
// that we do not own.
m_externalAllocator.clear();
ASSERT(bitmap.width() == scaledSize.width());
ASSERT(bitmap.height() == scaledSize.height());
bool result = true;
SkAutoLockPixels bitmapLock(bitmap);
// Check to see if decoder has written directly to the memory provided
// by Skia. If not make a copy.
if (bitmap.getPixels() != pixels)
result = bitmap.copyPixelsTo(pixels, rowBytes * info.height(), rowBytes);
return result;
}