Bug 344012 - "Trim to Current Layer" increases canvas size
Summary: "Trim to Current Layer" increases canvas size
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: 2.9 Beta
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-10 17:58 UTC by mvowada
Modified: 2015-07-06 14:41 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
"Trim to Current Layer" increases canvas size - Video (767.83 KB, video/mp4)
2015-02-10 17:59 UTC, mvowada
Details
Thank you for feedbacks. Please, see the image in attachment for the settings I'm using for testing. I'm able to reproduce by deleting the second layer, filling the background layer and trimming. (102.73 KB, image/png)
2015-02-16 17:38 UTC, mvowada
Details
"Trim to Current Layer" increases canvas size - Video after rebuild (746.87 KB, video/mp4)
2015-02-18 12:00 UTC, mvowada
Details
Sorry, but it seems the problem is still present. This attachment is a new video with the steps to reproduce the issue - Tested with Krita: 2.9.0 (git bc0a3ce) (761.79 KB, video/mp4)
2015-02-27 15:05 UTC, mvowada
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mvowada 2015-02-10 17:58:12 UTC
Not sure, but it seems there's an issue on how the "Trim to Current Layer" behaves. 
Canvas sizes increase in some circumstances (please, see also the video in comment below):

Case example:
    - New document (single layer) > Trim to Current Layer = No problem
    - New document (single layer) > Fill with Foreground Color > Trim to Current Layer = Canvas sizes increase a bit.

Ubuntu 14.04 Unity - Krita 2.9 Beta 3 (git 38ed8ff)

Reproducible: Always

Steps to Reproduce:
1. New document (with one layer)
2. Edit > Fill with Foreground Color
3. Image > Trim to Current Layer

Actual Results:  
Canvas sizes increase a bit.
Comment 1 mvowada 2015-02-10 17:59:22 UTC
Created attachment 91011 [details]
"Trim to Current Layer" increases canvas size - Video
Comment 2 Dmitry Kazakov 2015-02-16 16:26:57 UTC
Hi, mvowada!

Could you please send me a test file? I'm afraid I cannot reproduce the problem here :(
Comment 3 Halla Rempt 2015-02-16 16:42:27 UTC
Oh, I actually didn't have any trouble reproducing. It's not something that you can reproduce from a file, it happens even with the default 1600x1200 dimensions.
Comment 4 mvowada 2015-02-16 17:38:52 UTC
Created attachment 91108 [details]
Thank you for feedbacks. Please, see the image in attachment for the settings I'm using for testing. I'm able to reproduce by deleting the second layer, filling the background layer and trimming.
Comment 5 Dmitry Kazakov 2015-02-18 06:18:42 UTC
Yes, got it, thank you! :)
Comment 6 Dmitry Kazakov 2015-02-18 07:28:37 UTC
Git commit 5f55698bc1867b9e7c7a082d33bd6661cad25d30 by Dmitry Kazakov.
Committed on 18/02/2015 at 07:27.
Pushed by dkazakov into branch 'calligra/2.9'.

Fix "Trim to current layer" not to use extents() in non-transparent layers

We should calculate real non-default pixel area instead

M  +38   -10   krita/image/kis_paint_device.cc
M  +22   -3    krita/image/kis_paint_device.h
M  +9    -1    krita/ui/kis_layer_manager.cc

http://commits.kde.org/calligra/5f55698bc1867b9e7c7a082d33bd6661cad25d30
Comment 7 mvowada 2015-02-18 11:51:01 UTC
Maybe there's something wrong on my settings. Unfortunately I'm still able to reproduce the problem. I'm on Ubuntu 14.04 Unity:

Qt: 4.8.6
KDE Development Platform: 4.13.3
Krita: 2.9 Beta 3 (git 5f55698)

My steps:
1. I've created a new document with 2 layer
2. deleted the second layer (transparent), the higher in the stack
3. Shift+Backspace to repaint the background layer
4. Image > Trim to current layer
Comment 8 mvowada 2015-02-18 12:00:27 UTC
Created attachment 91150 [details]
"Trim to Current Layer" increases canvas size - Video after rebuild
Comment 9 Halla Rempt 2015-02-18 15:59:27 UTC
I'm sorry -- but this still happens for me as well. It's really simple to reproduce here: create a new image with one layer, click the fill tool, fill, select trim to current layer, and suddenly there's a transparent strip on the bottom of the image, 16 pixels high -- and my 1600x1200 image has become 1600x1216.
Comment 10 Dmitry Kazakov 2015-02-21 20:46:18 UTC
Git commit ce9d79cf48ce664ef9a3487cc5187eb088ef2a8e by Dmitry Kazakov.
Committed on 21/02/2015 at 20:28.
Pushed by dkazakov into branch 'calligra/2.9'.

Fix KisPaintDevice::nonDefaultPixelArea() not care about opacity

nonDefaultPixelArea() returns just a an area of non-default pixels,
it shouldn't bother about opacity or stuff.

M  +1    -0    krita/image/kis_default_bounds.h
M  +74   -24   krita/image/kis_paint_device.cc
M  +48   -10   krita/image/tests/kis_paint_device_test.cpp
M  +1    -0    krita/image/tests/kis_paint_device_test.h

http://commits.kde.org/calligra/ce9d79cf48ce664ef9a3487cc5187eb088ef2a8e
Comment 11 mvowada 2015-02-27 15:05:23 UTC
Created attachment 91323 [details]
Sorry, but it seems the problem is still present. This attachment is a new video with the steps to reproduce the issue - Tested with Krita: 2.9.0 (git bc0a3ce)
Comment 12 Dmitry Kazakov 2015-07-06 14:41:32 UTC
Git commit efc662e6bd297904588c277f9619f681bc0a7ba4 by Dmitry Kazakov.
Committed on 06/07/2015 at 14:41.
Pushed by dkazakov into branch 'calligra/2.9'.

Change exactBounds() to handle non-transparent default pixel properly

Now the semantics of exactBounds() has changed. In the case when
the default pixel is not fully transparent, now we do not return the
extent of the device. Instead, we return either the image bounds value,
or (if the device is bigger than the image) device's nonDefaultPixelArea().
Technically it looks like a union
(defaultBounds()->bounds() | nonDefaultPixelArea()).

This fixes a bug when exactBounds() were gradually growing during the
merge operations in:

M  +6    -6    krita/image/kis_image.cc
M  +0    -1    krita/image/kis_image.h
M  +45   -27   krita/image/kis_paint_device.cc
M  +3    -2    krita/image/kis_paint_device.h
M  +40   -0    krita/image/tests/kis_paint_device_test.cpp
M  +1    -0    krita/image/tests/kis_paint_device_test.h

http://commits.kde.org/calligra/efc662e6bd297904588c277f9619f681bc0a7ba4