mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Enable converting gfx::Image to Buffer
This commit is contained in:
@@ -16,10 +16,12 @@
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
#include "ui/base/layout.h"
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
namespace mate {
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
|
||||
namespace {
|
||||
|
||||
struct ScaleFactorPair {
|
||||
@@ -122,6 +124,14 @@ bool Converter<gfx::Image>::FromV8(v8::Isolate* isolate,
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace mate
|
||||
|
||||
#endif // !defined(OS_MACOSX)
|
||||
|
||||
v8::Handle<v8::Value> Converter<gfx::Image>::ToV8(v8::Isolate* isolate,
|
||||
const gfx::Image& val) {
|
||||
scoped_refptr<base::RefCountedMemory> png = val.As1xPNGBytes();
|
||||
return node::Buffer::New(isolate,
|
||||
reinterpret_cast<const char*>(png->front()),
|
||||
png->size());
|
||||
}
|
||||
|
||||
} // namespace mate
|
||||
|
||||
@@ -26,6 +26,8 @@ struct Converter<gfx::Image> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Handle<v8::Value> val,
|
||||
gfx::Image* out);
|
||||
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const gfx::Image& val);
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
Reference in New Issue
Block a user