From 6f082b630dc4a9b942b8e83f6a661913ee9633b8 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 26 Mar 2015 12:54:15 +0800 Subject: [PATCH] Add clipboard.writeImage API --- atom/common/api/atom_api_clipboard.cc | 6 ++++++ atom/common/api/lib/clipboard.coffee | 1 + 2 files changed, 7 insertions(+) diff --git a/atom/common/api/atom_api_clipboard.cc b/atom/common/api/atom_api_clipboard.cc index 645e6a68b2d..349b35ce585 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 17b98e4aa17..174856181ab 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