2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "image-api.h"
23 #include <image/image-wrapper.h>
31 Image ImageApi::GetImage( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
33 v8::HandleScope handleScope( isolate );
35 v8::Local<v8::Object> object = args.This();
36 v8::Local<v8::External> field = v8::Local<v8::External>::Cast( object->GetInternalField(0) );
37 void* ptr = field->Value();
39 ImageWrapper* wrapper = static_cast< ImageWrapper *>(ptr);
40 return wrapper->GetImage();
47 * @return {Object} Image
49 Image ImageApi::New( const v8::FunctionCallbackInfo< v8::Value >& args )
51 v8::Isolate* isolate = args.GetIsolate();
52 v8::HandleScope handleScope( isolate );
53 DALI_SCRIPT_EXCEPTION( isolate, "Image base class can not be constructed, try new dali.ResourceImage()");
58 * Return the image width in pixels
62 void ImageApi::GetWidth( const v8::FunctionCallbackInfo< v8::Value >& args )
64 v8::Isolate* isolate = args.GetIsolate();
65 v8::HandleScope handleScope( isolate );
67 Image image = GetImage( isolate, args );
69 args.GetReturnValue().Set( v8::Integer::New( isolate, image.GetWidth() ) );
72 * Return the image height in pixels
76 void ImageApi::GetHeight( const v8::FunctionCallbackInfo< v8::Value >& args )
78 v8::Isolate* isolate = args.GetIsolate();
79 v8::HandleScope handleScope( isolate );
81 Image image = GetImage( isolate, args );
83 args.GetReturnValue().Set( v8::Integer::New( isolate, image.GetHeight() ) );
86 } // namespace V8Plugin