| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2012 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #include "SkImagePriv.h" | |
| 9 #include "SkImage_Base.h" | |
| 10 #include "SkCanvas.h" | |
| 11 #include "SkPicture.h" | |
| 12 | |
| 13 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef, | |
| 14 const SkSurfaceProps* props) { | |
| 15 const SkImageInfo info = bm.info(); | |
| 16 if (kUnknown_SkColorType == info.colorType()) { | |
| 17 return NULL; | |
| 18 } | |
| 19 | |
| 20 SkImage* image = NULL; | |
| 21 if (canSharePixelRef || bm.isImmutable()) { | |
| 22 image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes(), props
); | |
| 23 } else { | |
| 24 bm.lockPixels(); | |
| 25 if (bm.getPixels()) { | |
| 26 image = SkImage::NewRasterCopy(info, bm.getPixels(), bm.rowBytes()); | |
| 27 } | |
| 28 bm.unlockPixels(); | |
| 29 | |
| 30 // we don't expose props to NewRasterCopy (need a private vers) so post-
init it here | |
| 31 if (image && props) { | |
| 32 as_IB(image)->initWithProps(*props); | |
| 33 } | |
| 34 } | |
| 35 return image; | |
| 36 } | |
| OLD | NEW |