@@ -101,6 +101,13 @@ void ImageDisplay::draw(int x, int y, int w, int h, int cw) {
101101 srcRect.width = MIN (w, MIN (_buffer->_width , _width));
102102 srcRect.height = MIN (h, MIN (_buffer->_height , _height));
103103
104+ if (unsigned (srcRect.top + srcRect.height ) > _buffer->_height ) {
105+ srcRect.height = _buffer->_height - srcRect.top ;
106+ }
107+ if (unsigned (srcRect.left + srcRect.width ) > _buffer->_width ) {
108+ srcRect.width = _buffer->_width - srcRect.left ;
109+ }
110+
104111 maDrawRGB (&dstPoint, _buffer->_image , &srcRect, _opacity, _buffer->_width );
105112 }
106113}
@@ -503,25 +510,19 @@ void cmd_image_save(var_s *self, var_s *) {
503510// png.clip(10, 10, 10, 10)
504511//
505512void cmd_image_clip (var_s *self, var_s *) {
506- bool updated = false ;
507513 if (self->type == V_MAP) {
508514 int bid = map_get_int (self, IMG_BID, -1 );
509515 if (bid != -1 ) {
510516 ImageBuffer *image = get_image ((unsigned )bid);
511517 var_int_t left, top, right, bottom;
512- if (image != nullptr && par_massget (" iiii" , &left, &top, &right, &bottom) == 4 &&
513- left >= 0 && left < image->_width && top >= 0 && top < image->_height ) {
518+ if (image != nullptr && par_massget (" iiii" , &left, &top, &right, &bottom)) {
514519 map_set_int (self, IMG_OFFSET_LEFT, left);
515520 map_set_int (self, IMG_OFFSET_TOP, top);
516521 map_set_int (self, IMG_WIDTH, right);
517522 map_set_int (self, IMG_HEIGHT, bottom);
518- updated = true ;
519523 }
520524 }
521525 }
522- if (!updated) {
523- err_throw (ERR_PARAM);
524- }
525526}
526527
527528void create_image (var_p_t var, ImageBuffer *image) {
0 commit comments