@@ -370,7 +370,7 @@ ImageBuffer *load_xpm_image(char **data) {
370370 return result;
371371}
372372
373- void get_image_display (var_s *self, int param_count, slib_par_t *params, ImageDisplay *image) {
373+ void get_image_display (var_s *self, ImageDisplay *image) {
374374 image->_bid = map_get_int (self, IMG_BID, -1 );
375375
376376 List_each (ImageBuffer *, it, buffers) {
@@ -381,13 +381,14 @@ void get_image_display(var_s *self, int param_count, slib_par_t *params, ImageDi
381381 }
382382 }
383383
384- if (prog_error || image->_buffer == nullptr || param_count == 1 || param_count > 4 ) {
384+ var_int_t x, y, z, op;
385+ int count = par_massget (" iiii" , &x, &y, &z, &op);
386+
387+ if (prog_error || image->_buffer == nullptr || count == 1 || count > 4 ) {
385388 err_throw (ERR_PARAM);
386389 } else {
387390 // 0, 2, 3, 4 arguments accepted
388- if (param_count >= 2 ) {
389- var_int_t x = v_getint (params[0 ].var_p );
390- var_int_t y = v_getint (params[1 ].var_p );
391+ if (count >= 2 ) {
391392 image->_x = x;
392393 image->_y = y;
393394 map_set_int (self, IMG_X, x);
@@ -396,15 +397,13 @@ void get_image_display(var_s *self, int param_count, slib_par_t *params, ImageDi
396397 image->_x = map_get_int (self, IMG_X, -1 );
397398 image->_y = map_get_int (self, IMG_Y, -1 );
398399 }
399- if (param_count >= 3 ) {
400- var_int_t z = v_getint (params[2 ].var_p );
400+ if (count >= 3 ) {
401401 image->_zIndex = z;
402402 map_set_int (self, IMG_ZINDEX, z);
403403 } else {
404404 image->_zIndex = map_get_int (self, IMG_ZINDEX, -1 );
405405 }
406- if (param_count == 4 ) {
407- var_int_t op = v_getint (params[3 ].var_p );
406+ if (count == 4 ) {
408407 image->_opacity = op;
409408 map_set_int (self, IMG_OPACITY, op);
410409 } else {
@@ -422,9 +421,9 @@ void get_image_display(var_s *self, int param_count, slib_par_t *params, ImageDi
422421//
423422// png.show(x, y, zindex, opacity)
424423//
425- void cmd_image_show (var_s *self, int param_count, slib_par_t *params, var_s *) {
424+ void cmd_image_show (var_s *self, var_s *) {
426425 ImageDisplay image;
427- get_image_display (self, param_count, params, &image);
426+ get_image_display (self, &image);
428427 if (!prog_error) {
429428 g_system->getOutput ()->addImage (image);
430429 }
@@ -433,9 +432,9 @@ void cmd_image_show(var_s *self, int param_count, slib_par_t *params, var_s *) {
433432//
434433// png.draw(x, y, opacity)
435434//
436- void cmd_image_draw (var_s *self, int param_count, slib_par_t *params, var_s *) {
435+ void cmd_image_draw (var_s *self, var_s *) {
437436 ImageDisplay image;
438- get_image_display (self, param_count, params, &image);
437+ get_image_display (self, &image);
439438 if (!prog_error) {
440439 image._opacity = image._zIndex ;
441440 g_system->getOutput ()->drawImage (image);
@@ -445,7 +444,7 @@ void cmd_image_draw(var_s *self, int param_count, slib_par_t *params, var_s *) {
445444//
446445// png.hide()
447446//
448- void cmd_image_hide (var_s *self, int param_count, slib_par_t *params, var_s *) {
447+ void cmd_image_hide (var_s *self, var_s *) {
449448 int id = map_get_int (self, IMG_ID, -1 );
450449 g_system->getOutput ()->removeImage (id);
451450}
@@ -456,7 +455,7 @@ void cmd_image_hide(var_s *self, int param_count, slib_par_t *params, var_s *) {
456455// png.save("horse1.png")
457456// png.save(#1)
458457//
459- void cmd_image_save (var_s *self, int param_count, slib_par_t *params, var_s *) {
458+ void cmd_image_save (var_s *self, var_s *) {
460459 unsigned id = map_get_int (self, IMG_BID, -1 );
461460 ImageBuffer *image = get_image (id);
462461 dev_file_t *file;
@@ -517,16 +516,17 @@ void cmd_image_save(var_s *self, int param_count, slib_par_t *params, var_s *) {
517516//
518517// png.clip(10, 10, 10, 10)
519518//
520- void cmd_image_clip (var_s *self, int param_count, slib_par_t *params, var_s *) {
519+ void cmd_image_clip (var_s *self, var_s *) {
521520 if (self->type == V_MAP) {
522521 int bid = map_get_int (self, IMG_BID, -1 );
523522 if (bid != -1 ) {
524523 ImageBuffer *image = get_image ((unsigned )bid);
525- if (image != nullptr && param_count == 4 ) {
526- map_set_int (self, IMG_OFFSET_LEFT, v_getint (params[0 ].var_p ));
527- map_set_int (self, IMG_OFFSET_TOP, v_getint (params[1 ].var_p ));
528- map_set_int (self, IMG_WIDTH, v_getint (params[2 ].var_p ));
529- map_set_int (self, IMG_HEIGHT, v_getint (params[3 ].var_p ));
524+ var_int_t left, top, right, bottom;
525+ if (image != nullptr && par_massget (" iiii" , &left, &top, &right, &bottom)) {
526+ map_set_int (self, IMG_OFFSET_LEFT, left);
527+ map_set_int (self, IMG_OFFSET_TOP, top);
528+ map_set_int (self, IMG_WIDTH, right);
529+ map_set_int (self, IMG_HEIGHT, bottom);
530530 }
531531 }
532532 }
0 commit comments