From: Cheng Zhao Date: Thu, 26 Mar 2015 04:54:15 +0000 (+0800) Subject: Add clipboard.writeImage API X-Git-Tag: v0.22.3~25^2~2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=6f082b630dc4a9b942b8e83f6a661913ee9633b8;p=electron.git Add clipboard.writeImage API --- diff --git a/atom/common/api/atom_api_clipboard.cc b/atom/common/api/atom_api_clipboard.cc index 645e6a68..349b35ce 100644 --- a/atom/common/api/atom_api_clipboard.cc +++ b/atom/common/api/atom_api_clipboard.cc @@ -69,6 +69,11 @@ gfx::Image ReadImage(ui::ClipboardType type) { return gfx::Image::CreateFrom1xBitmap(bitmap); } +void WriteImage(const gfx::Image& image, ui::ClipboardType type) { + ui::ScopedClipboardWriter writer(type); + writer.WriteImage(image.AsBitmap()); +} + void Clear(ui::ClipboardType type) { ui::Clipboard::GetForCurrentThread()->Clear(type); } @@ -81,6 +86,7 @@ void Initialize(v8::Handle exports, v8::Handle unused, dict.SetMethod("_readText", &ReadText); dict.SetMethod("_writeText", &WriteText); dict.SetMethod("_readImage", &ReadImage); + dict.SetMethod("_writeImage", &WriteImage); dict.SetMethod("_clear", &Clear); } diff --git a/atom/common/api/lib/clipboard.coffee b/atom/common/api/lib/clipboard.coffee index 17b98e4a..17485618 100644 --- a/atom/common/api/lib/clipboard.coffee +++ b/atom/common/api/lib/clipboard.coffee @@ -10,4 +10,5 @@ else readText: (type='standard') -> binding._readText type writeText: (text, type='standard') -> binding._writeText text, type readImage: (type='standard') -> binding._readImage type + writeImage: (image, type='standard') -> binding._writeImage image, type clear: (type='standard') -> binding._clear type