Add a few more methods for NativeImage
This commit is contained in:
parent
aae576b484
commit
549df36f00
2 changed files with 18 additions and 0 deletions
|
@ -4,10 +4,12 @@
|
|||
|
||||
#include "atom/common/api/atom_api_native_image.h"
|
||||
|
||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||
#include "atom/common/native_mate_converters/image_converter.h"
|
||||
#include "native_mate/constructor.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
|
@ -30,6 +32,8 @@ mate::ObjectTemplateBuilder NativeImage::GetObjectTemplateBuilder(
|
|||
if (template_.IsEmpty())
|
||||
template_.Reset(isolate, mate::ObjectTemplateBuilder(isolate)
|
||||
.SetMethod("toPng", &NativeImage::ToPNG)
|
||||
.SetMethod("isEmpty", &NativeImage::IsEmpty)
|
||||
.SetMethod("getSize", &NativeImage::GetSize)
|
||||
.Build());
|
||||
|
||||
return mate::ObjectTemplateBuilder(
|
||||
|
@ -43,6 +47,14 @@ v8::Handle<v8::Value> NativeImage::ToPNG(v8::Isolate* isolate) {
|
|||
png->size());
|
||||
}
|
||||
|
||||
bool NativeImage::IsEmpty() {
|
||||
return image_.IsEmpty();
|
||||
}
|
||||
|
||||
gfx::Size NativeImage::GetSize() {
|
||||
return image_.Size();
|
||||
}
|
||||
|
||||
// static
|
||||
mate::Handle<NativeImage> NativeImage::Create(v8::Isolate* isolate,
|
||||
const gfx::Image& image) {
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
#include "native_mate/wrappable.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
|
||||
namespace gfx {
|
||||
class Size;
|
||||
}
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
@ -28,6 +32,8 @@ class NativeImage : public mate::Wrappable {
|
|||
|
||||
private:
|
||||
v8::Handle<v8::Value> ToPNG(v8::Isolate* isolate);
|
||||
bool IsEmpty();
|
||||
gfx::Size GetSize();
|
||||
|
||||
gfx::Image image_;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue