Enable converting gfx::Image to Buffer
This commit is contained in:
parent
ab315e502f
commit
878d25e91e
2 changed files with 15 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue