@@ -245,10 +245,15 @@ ImageBuffer *load_xpm_image(char **data) {
245245//
246246// png.clip(10, 10, 10, 10)
247247//
248- void cmd_image_clip (var_s *self, var_s *) {
249- var_int_t left, top, right, bottom;
248+ void cmd_image_clip (var_s *self, int param_count, slib_par_t *params, var_s *) {
250249 ImageBuffer *image = load_image (self);
251- if (par_massget (" iiii" , &left, &top, &right, &bottom) == 4 ) {
250+ if (param_count != 4 ) {
251+ err_parm_num (param_count, 4 );
252+ } else {
253+ var_int_t left = v_getint (params[0 ].var_p );
254+ var_int_t top = v_getint (params[1 ].var_p );
255+ var_int_t right = v_getint (params[2 ].var_p );
256+ var_int_t bottom = v_getint (params[3 ].var_p );
252257 int w = image->_width - (right + left);
253258 int h = image->_height - (bottom + top);
254259 int size = w * h * 4 ;
@@ -277,8 +282,6 @@ void cmd_image_clip(var_s *self, var_s *) {
277282 map_set_int (self, IMG_WIDTH, w);
278283 map_set_int (self, IMG_HEIGHT, h);
279284 }
280- } else {
281- err_throw (ERR_PARAM);
282285 }
283286}
284287
@@ -290,7 +293,7 @@ void cmd_image_clip(var_s *self, var_s *) {
290293// end
291294// png.filter(use colorToAlpha(x))
292295//
293- void cmd_image_filter (var_s *self, var_s *) {
296+ void cmd_image_filter (var_s *self, int param_count, slib_par_t *params, var_s *) {
294297 ImageBuffer *image_buffer = load_image (self);
295298 if (code_peek () == kwUSE && image_buffer != nullptr ) {
296299 code_skipnext ();
@@ -326,19 +329,22 @@ void cmd_image_filter(var_s *self, var_s *) {
326329// png2 = image(w, h)
327330// png2.paste(png1, 0, 0)
328331//
329- void cmd_image_paste (var_s *self, var_s *) {
330- var_int_t x, y;
331- var_t *var;
332+ void cmd_image_paste (var_s *self, int param_count, slib_par_t *params, var_s *) {
332333 ImageBuffer *image = load_image (self);
333- int count = par_massget ( " Piiii " , &var, &x, &y);
334- if (image != nullptr && (count == 1 || count == 3 )) {
334+ if (image != nullptr && (param_count == 1 || param_count == 3 )) {
335+ var_t *var = params[ 0 ]. var_p ;
335336 ImageBuffer *srcImage = load_image (var);
336337 if (srcImage == nullptr ) {
337338 err_throw (ERR_PARAM);
338339 } else {
340+ var_int_t x;
341+ var_int_t y;
339342 if (count == 1 ) {
340343 x = 0 ;
341344 y = 0 ;
345+ } else {
346+ x = v_getint (params[1 ].var_p );
347+ y = v_getint (params[2 ].var_p );
342348 }
343349 int dw = image->_width ;
344350 int dh = image->_height ;
@@ -370,7 +376,7 @@ void cmd_image_paste(var_s *self, var_s *) {
370376// png.save("horse1.png")
371377// png.save(#1)
372378//
373- void cmd_image_save (var_s *self, var_s *) {
379+ void cmd_image_save (var_s *self, int param_count, slib_par_t *params, var_s *) {
374380 ImageBuffer *image = load_image (self);
375381 dev_file_t *filep = nullptr ;
376382 byte code = code_peek ();
0 commit comments