Add nativeImage.createEmpty()

This commit is contained in:
Cheng Zhao 2015-02-12 13:55:45 +08:00
parent 8093300a43
commit b9f6d6dffc
3 changed files with 11 additions and 0 deletions

View file

@ -156,6 +156,11 @@ gfx::Size NativeImage::GetSize() {
return image_.Size();
}
// static
mate::Handle<NativeImage> NativeImage::CreateEmpty(v8::Isolate* isolate) {
return mate::CreateHandle(isolate, new NativeImage);
}
// static
mate::Handle<NativeImage> NativeImage::Create(
v8::Isolate* isolate, const gfx::Image& image) {
@ -203,6 +208,7 @@ namespace {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("createEmpty", &atom::api::NativeImage::CreateEmpty);
dict.SetMethod("createFromPng", &atom::api::NativeImage::CreateFromPNG);
dict.SetMethod("createFromJpeg", &atom::api::NativeImage::CreateFromJPEG);
dict.SetMethod("createFromPath", &atom::api::NativeImage::CreateFromPath);

View file

@ -23,6 +23,7 @@ namespace api {
class NativeImage : public mate::Wrappable {
public:
static mate::Handle<NativeImage> CreateEmpty(v8::Isolate* isolate);
static mate::Handle<NativeImage> Create(
v8::Isolate* isolate, const gfx::Image& image);
static mate::Handle<NativeImage> CreateFromPNG(

View file

@ -80,6 +80,10 @@ To mark an image as template image, its filename should end with the word
* `xxxTemplate.png`
* `xxxTemplate@2x.png`
## nativeImage.createEmpty()
Creates a new `NativeImage` instance that contains empty image.
## nativeImage.createFromPng(buffer)
* `buffer` [Buffer][buffer]