2shady4u / godot-krita-importer

Plugin for Godot Engine to import Krita KRA-files
MIT License
34 stars 1 forks source link

Crop to visible part of layer #4

Closed timkrief closed 3 months ago

timkrief commented 3 months ago

Hi the layer sizes were strange and not behaving as in krita (where the layer seems to have the size of the bounding rect of what's opaque)

I was able to fix that by changing some lines, I could do a merge request if you like the feature.


    var image = Image.create_from_data(layer_data.width, layer_data.height, false, layer_data.format, layer_data.data)
    var visible_region = image.get_used_rect()
    var cropped_image = image.get_region(visible_region);
    var texture = ImageTexture.create_from_image(cropped_image)

    sprite.position = layer_data.get("position", Vector2.ZERO) + Vector2(visible_region.position)

image

2shady4u commented 3 months ago

Hello @timkrief

Thank you for your interest in this plugin 😄 I am a bit confused on what the issue exactly is 🤔 Would it be possible to show me a before and after picture comparing the imported Krita file with the original Kirita file in Krita itself?

2shady4u commented 3 months ago

I figured out the difference by using the 'example.kra'-file 😄 I do think it would be better if this was a parameter in the import settings (can be true by default)

timkrief commented 3 months ago

How should it be named?

timkrief commented 3 months ago

crop_layers_to_visible_bounding_rect ?

2shady4u commented 3 months ago

crop_layers_to_visible_bounding_rect ?

Seems like you have a preference for long names 😄 crop_to_visible crop_to_visible_rect Are all fine choices!

timkrief commented 3 months ago

Updated #6 to add a parameter in the import settings ;)