diff --git a/atom/common/api/atom_api_native_image.cc b/atom/common/api/atom_api_native_image.cc index 821417d524c1..e74d681cc0b8 100644 --- a/atom/common/api/atom_api_native_image.cc +++ b/atom/common/api/atom_api_native_image.cc @@ -156,6 +156,11 @@ gfx::Size NativeImage::GetSize() { return image_.Size(); } +// static +mate::Handle NativeImage::CreateEmpty(v8::Isolate* isolate) { + return mate::CreateHandle(isolate, new NativeImage); +} + // static mate::Handle NativeImage::Create( v8::Isolate* isolate, const gfx::Image& image) { @@ -203,6 +208,7 @@ namespace { void Initialize(v8::Handle exports, v8::Handle unused, v8::Handle context, void* priv) { mate::Dictionary dict(context->GetIsolate(), exports); + dict.SetMethod("createEmpty", &atom::api::NativeImage::CreateEmpty); dict.SetMethod("createFromPng", &atom::api::NativeImage::CreateFromPNG); dict.SetMethod("createFromJpeg", &atom::api::NativeImage::CreateFromJPEG); dict.SetMethod("createFromPath", &atom::api::NativeImage::CreateFromPath); diff --git a/atom/common/api/atom_api_native_image.h b/atom/common/api/atom_api_native_image.h index 615ac0762fb1..33c020f21ad2 100644 --- a/atom/common/api/atom_api_native_image.h +++ b/atom/common/api/atom_api_native_image.h @@ -23,6 +23,7 @@ namespace api { class NativeImage : public mate::Wrappable { public: + static mate::Handle CreateEmpty(v8::Isolate* isolate); static mate::Handle Create( v8::Isolate* isolate, const gfx::Image& image); static mate::Handle CreateFromPNG( diff --git a/docs/api/native-image.md b/docs/api/native-image.md index 6ce260e89932..e38f9abd35be 100644 --- a/docs/api/native-image.md +++ b/docs/api/native-image.md @@ -80,6 +80,10 @@ To mark an image as template image, its filename should end with the word * `xxxTemplate.png` * `xxxTemplate@2x.png` +## nativeImage.createEmpty() + +Creates a new `NativeImage` instance that contains empty image. + ## nativeImage.createFromPng(buffer) * `buffer` [Buffer][buffer]