Fix image cropping/enlarging
Function imlib_create_cropped_image() from imlib2 doesn't initialize buffer for new image, so if we use crop bounds bigger than original ones we need to erase garbage from derived image. This bug produced colorful pressed buttons (FS#516, FS#822). Signed-off-by: Roman Kosenko <madkite@gmail.com> Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
825efd21b3
commit
dd656f514a
|
@ -415,7 +415,20 @@ luaA_image_crop(lua_State *L)
|
|||
new = image_new(L);
|
||||
|
||||
imlib_context_set_image(image->image);
|
||||
int ow = imlib_image_get_width(), oh = imlib_image_get_height();
|
||||
new->image = imlib_create_cropped_image(x, y, w, h);
|
||||
imlib_context_set_image(new->image);
|
||||
imlib_context_set_color(0, 0, 0, 0);
|
||||
imlib_context_set_blend(0);
|
||||
if(x < 0)
|
||||
imlib_image_fill_rectangle(0, 0, -x, h);
|
||||
if(y < 0)
|
||||
imlib_image_fill_rectangle(x < 0 ? -x : 0, 0, w, -y);
|
||||
if(x + w > ow)
|
||||
imlib_image_fill_rectangle(ow - x, y < 0 ? -y : 0, x + w - ow, h);
|
||||
if(y + h > oh)
|
||||
imlib_image_fill_rectangle(x < 0 ? -x : 0, oh - y, x + w > ow ? ow - x : w, y + h - oh);
|
||||
imlib_context_set_blend(1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue