// // Image.cc // // Copyright (c) 2010 LearnBoost // #include "canvas.h" #include "image.h" /* * Initialize Image. */ void Image::Initialize(Handle target) { HandleScope scope; Local t = FunctionTemplate::New(Image::New); t->InstanceTemplate()->SetInternalFieldCount(1); t->SetClassName(String::NewSymbol("Image")); Local proto = t->PrototypeTemplate(); proto->SetAccessor(String::NewSymbol("src"), GetSrc, SetSrc); target->Set(String::NewSymbol("Image"), t->GetFunction()); } /* * Initialize a new Image. */ Handle Image::New(const Arguments &args) { HandleScope scope; Image *img = new Image; img->Wrap(args.This()); return args.This(); } /* * Initialize a new Image. */ Image::Image() { _surface = NULL; } /* * Destroy image and associated surface. */ Image::~Image() { cairo_surface_destroy(_surface); }