SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) { const SkImageInfo info = bm.info(); if (kUnknown_SkColorType == info.colorType()) { return NULL; } SkImage* image = NULL; if (canSharePixelRef || bm.isImmutable()) { image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes()); } else { bm.lockPixels(); if (bm.getPixels()) { image = SkImage::NewRasterCopy(info, bm.getPixels(), bm.rowBytes()); } bm.unlockPixels(); } return image; }
SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) { SkImageInfo info; if (!bm.asImageInfo(&info)) { return NULL; } SkImage* image = NULL; if (canSharePixelRef || bm.isImmutable()) { image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes()); } else { bm.lockPixels(); if (bm.getPixels()) { image = SkImage::NewRasterCopy(info, bm.getPixels(), bm.rowBytes()); } bm.unlockPixels(); } return image; }