@@ -128,25 +128,39 @@ napi_value Image::Init(napi_env env, napi_value exports) { // {{{
128
128
regAllCodecs ();
129
129
130
130
napi_status status;
131
+
132
+ // global properties
133
+ napi_property_descriptor globalProperties[] = {
134
+ DECLARE_NAPI_ACCESSOR (" maxWidth" , GetMaxWidth, SetMaxWidth),
135
+ DECLARE_NAPI_ACCESSOR (" maxHeight" , GetMaxHeight, SetMaxHeight),
136
+ DECLARE_NAPI_ACCESSOR (" usedMemory" , GetUsedMemory, nullptr ),
137
+ DECLARE_NAPI_METHOD (" gc" , GC)
138
+ };
139
+
140
+ napi_property_descriptor desc = { " SetMaxHeight" , 0 , SetMaxHeight, 0 , 0 , 0 , napi_default, 0 };
141
+ status = napi_define_properties (env, exports, sizeof (globalProperties) / sizeof (globalProperties[0 ]), globalProperties);
142
+ assert (status == napi_ok);
143
+
144
+ // Image properties
131
145
napi_property_descriptor properties[] = {
132
146
DECLARE_NAPI_ACCESSOR (" width" , GetWidth, SetWidth),
133
147
DECLARE_NAPI_ACCESSOR (" height" , GetHeight, SetHeight),
134
148
DECLARE_NAPI_ACCESSOR (" transparent" , GetTransparent, nullptr ),
135
- DECLARE_NAPI_ACCESSOR (" maxWidth" , GetMaxWidth, SetMaxWidth),
136
- DECLARE_NAPI_ACCESSOR (" maxHeight" , GetMaxHeight, SetMaxHeight),
137
- DECLARE_NAPI_ACCESSOR (" usedMemory" , GetUsedMemory, nullptr ),
149
+ // DECLARE_NAPI_ACCESSOR("maxWidth", GetMaxWidth, SetMaxWidth),
150
+ // DECLARE_NAPI_ACCESSOR("maxHeight", GetMaxHeight, SetMaxHeight),
151
+ // DECLARE_NAPI_ACCESSOR("usedMemory", GetUsedMemory, nullptr),
138
152
DECLARE_NAPI_METHOD (" resize" , Resize),
139
153
DECLARE_NAPI_METHOD (" rotate" , Rotate),
140
154
DECLARE_NAPI_METHOD (" fillColor" , FillColor),
141
155
DECLARE_NAPI_METHOD (" loadFromBuffer" , LoadFromBuffer),
142
156
DECLARE_NAPI_METHOD (" copyFromImage" , CopyFromImage),
143
157
DECLARE_NAPI_METHOD (" drawImage" , DrawImage),
144
158
DECLARE_NAPI_METHOD (" toBuffer" , ToBuffer),
145
- DECLARE_NAPI_METHOD (" gc" , GC)
159
+ // DECLARE_NAPI_METHOD("gc", GC)
146
160
};
147
161
148
162
napi_value cons;
149
- status = napi_define_class (env, " Image" , NAPI_AUTO_LENGTH, New, nullptr , 14 , properties, &cons);
163
+ status = napi_define_class (env, " Image" , NAPI_AUTO_LENGTH, New, nullptr , sizeof (globalProperties) / sizeof (globalProperties[ 0 ]) , properties, &cons);
150
164
assert (status == napi_ok);
151
165
152
166
status = napi_create_reference (env, cons, 1 , &constructor);
0 commit comments