diff options
Diffstat (limited to 'ui/gfx')
-rw-r--r-- | ui/gfx/image/image.cc | 8 | ||||
-rw-r--r-- | ui/gfx/image/image.h | 7 |
2 files changed, 15 insertions, 0 deletions
diff --git a/ui/gfx/image/image.cc b/ui/gfx/image/image.cc index ea302ab..9854787 100644 --- a/ui/gfx/image/image.cc +++ b/ui/gfx/image/image.cc @@ -337,6 +337,14 @@ NSImage* Image::ToNSImage() const { } #endif +SkBitmap Image::AsBitmap() const { + return IsEmpty() ? SkBitmap() : *ToSkBitmap(); +} + +ImageSkia Image::AsImageSkia() const { + return IsEmpty() ? ImageSkia(SkBitmap()) : *ToImageSkia(); +} + ImageSkia* Image::CopyImageSkia() const { return new ImageSkia(*ToImageSkia()); } diff --git a/ui/gfx/image/image.h b/ui/gfx/image/image.h index c03db3a..04a79da 100644 --- a/ui/gfx/image/image.h +++ b/ui/gfx/image/image.h @@ -107,6 +107,13 @@ class UI_EXPORT Image { NSImage* ToNSImage() const; #endif + // Same as ToSkBitmap(), but returns a null SkBitmap if this image is empty. + SkBitmap AsBitmap() const; + + // Same as ToSkBitmap(), but returns a ImageSkia with a null SkBitmap if this + // image is empty. + ImageSkia AsImageSkia() const; + // Performs a conversion, like above, but returns a copy of the result rather // than a weak pointer. The caller is responsible for deleting the result. // Note that the result is only a copy in terms of memory management; the |