[Bug 120450] New: Strange helper lines behavior in ratio crop tool

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug 120450] New: Strange helper lines behavior in ratio crop tool

Bugzilla from thorsten.schnebeck@gmx.net
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=120450         
           Summary: Strange helper lines behavior in ratio crop tool
           Product: digikamimageplugins
           Version: unspecified
          Platform: Compiled Sources
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: general
        AssignedTo: digikam-devel kde org
        ReportedBy: thorsten.schnebeck gmx net


Version:            (using KDE KDE 3.5.0)
Installed from:    Compiled From Sources

When using the ratio crop tool in 3:4 mode and active golden mean helper lines I see a displacement of the helper lines when toggling "mirror horizontal/vertical". Cause the lines should be fully h/v-symmetrical *me* wonders about this displacement.

Bye

  Thorsten
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Digikam-devel] [Bug 120450] Strange helper lines behavior in ratio crop tool

Gilles Caulier
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=120450         
caulier.gilles free fr changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|general                     |Core Plugin
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 120450] Strange helper lines behavior in ratio crop tool

Arnd Baecker
In reply to this post by Bugzilla from thorsten.schnebeck@gmx.net
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=120450         




------- Additional Comments From arnd.baecker web de  2007-06-14 12:53 -------
Created an attachment (id=20856)
 --> (http://bugs.kde.org/attachment.cgi?id=20856&action=view)
no more jumping lines.

The attached patch solves (at least for me ;-)
the jumping helper lines under flip.
The origin of the problem were a combination of several 1 pixel round-off
errors.

Best, Arnd
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 120450] Strange helper lines behavior in ratio crop tool

Bugzilla from thorsten.schnebeck@gmx.net
In reply to this post by Bugzilla from thorsten.schnebeck@gmx.net
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=120450         




------- Additional Comments From thorsten.schnebeck gmx net  2007-06-17 01:06 -------
Patch looks fine. As its not applied can you change the bug status to confirmed (=NEW)?

Bye

  Thorsten
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 120450] Strange helper lines behavior in ratio crop tool

Gilles Caulier-4
In reply to this post by Bugzilla from thorsten.schnebeck@gmx.net
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=120450         
caulier.gilles gmail com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From caulier.gilles gmail com  2007-06-17 09:17 -------
SVN commit 676579 by cgilles:

digikam from KDE3 branch : Ratio Crop Tool : patch from Arnd Beacker about to fix round off error in helper lines computation.
BUG: 120450


 M  +35 -22    imageselectionwidget.cpp  


--- branches/extragear/kde3/graphics/digikam/imageplugins/coreplugin/ratiocrop/imageselectionwidget.cpp #676578:676579
 @ -29,10 +29,10  @
 
 #define MINRANGE 0
 
-// Fibanocci irrationel Golden Number.
-#define PHI      1.618033988
+// Golden number (1+sqrt(5))/2
+#define PHI      1.61803398874989479
 // 1/PHI
-#define INVPHI   0.61803398903633
+#define INVPHI   0.61803398874989479
 
 // C++ includes.
 
 @ -858,43 +858,53  @
             if (d->flipHorGoldenGuide)
                 p.scale(-1, 1);
 
-            // Flip verical.
+            // Flip vertical.
             if (d->flipVerGoldenGuide)
                 p.scale(1, -1);
 
             int w = d->localRegionSelection.width();
             int h = d->localRegionSelection.height();
 
-            QRect R1(-w/2, -h/2,
-                     (int)(w/PHI), h);
-            QRect R2((int)(w*(INVPHI - 0.5)), (int)(h*(0.5 - INVPHI)),
-                     (int)(w*(1 - INVPHI)), (int)(h/PHI));
-            QRect R3((int)(w/2 - R2.width()/PHI), -h/2,
-                     (int)(R2.width()/PHI), h - R2.height());
+            // lengths for the golden mean and half the sizes of the region:
+            int w_g = (int)(w*INVPHI);
+            int h_g = (int)(h*INVPHI);
+            int w_2 = w/2;
+            int h_2 = h/2;
+
+            QRect R1(-w_2, -h_2, w_g, h);
+            // w - 2*w_2 corrects for one-pixel difference
+            // so that R2.right() is really at the right end of the region
+            QRect R2(w_g-w_2, h_2-h_g, w-w_g+1-(w - 2*w_2), h_g);
+
+            QRect R3((int)(w_2 - R2.width()*INVPHI), -h_2,
+                     (int)(R2.width()*INVPHI), h - R2.height());
             QRect R4(R2.x(), R1.y(), R3.x() - R2.x(),
-                     (int)(R3.height()/PHI));
-            QRect R5(R4.x(), R4.bottom(), (int)(R4.width()/PHI),
+                     (int)(R3.height()*INVPHI));
+            QRect R5(R4.x(), R4.bottom(), (int)(R4.width()*INVPHI),
                      R3.height() - R4.height());
-            QRect R6(R5.x() + R5.width(), R5.bottom() - (int)(R5.height()/PHI),
-                     R3.x() - R5.right(), (int)(R5.height()/PHI));
-            QRect R7(R6.right() - (int)(R6.width()/PHI), R4.bottom(),
-                     (int)(R6.width()/PHI), R5.height() - R6.height());
+            QRect R6(R5.x() + R5.width(), R5.bottom() - (int)(R5.height()*INVPHI),
+                     R3.x() - R5.right(), (int)(R5.height()*INVPHI));
+            QRect R7(R6.right() - (int)(R6.width()*INVPHI), R4.bottom(),
+                     (int)(R6.width()*INVPHI), R5.height() - R6.height());
 
             p.setPen(QPen(Qt::white, d->guideSize, Qt::SolidLine));
 
             // Drawing Golden sections.
             if (d->drawGoldenSection)
             {
+               // horizontal lines:
                p.drawLine( R1.left(), R2.top(),
                            R2.right(), R2.top());
 
                p.drawLine( R1.left(), R1.top() + R2.height(),
                            R2.right(), R1.top() + R2.height());
 
-               p.drawLine( R2.right() - R1.width(), R1.top(),
-                           R2.right() - R1.width(), R1.bottom() );
+               // vertical lines:
+               p.drawLine( R1.right(), R1.top(),
+                           R1.right(), R1.bottom() );
 
-               p.drawLine( R1.topRight(), R1.bottomRight() );
+               p.drawLine( R1.left()+R2.width(), R1.top(),
+                           R1.left()+R2.width(), R1.bottom() );              
             }
 
             // Drawing Golden triangle guides.
 @ -966,16 +976,19  @
             // Drawing Golden sections.
             if (d->drawGoldenSection)
             {
+               // horizontal lines:
                p.drawLine( R1.left(), R2.top(),
                            R2.right(), R2.top());
 
                p.drawLine( R1.left(), R1.top() + R2.height(),
                            R2.right(), R1.top() + R2.height());
 
-               p.drawLine( R2.right() - R1.width(), R1.top(),
-                           R2.right() - R1.width(), R1.bottom() );
+               // vertical lines:
+               p.drawLine( R1.right(), R1.top(),
+                           R1.right(), R1.bottom() );
 
-               p.drawLine( R1.topRight(), R1.bottomRight() );
+               p.drawLine( R1.left()+R2.width(), R1.top(),
+                           R1.left()+R2.width(), R1.bottom() );              
             }
 
             // Drawing Golden triangle guides.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 120450] Strange helper lines behavior in ratio crop tool

Gilles Caulier-4
In reply to this post by Bugzilla from thorsten.schnebeck@gmx.net
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=120450         




------- Additional Comments From caulier.gilles gmail com  2007-06-17 09:22 -------
SVN commit 676582 by cgilles:

digikam from trunk (KDE4) : Ratio crop tool : backport patch from Arnd about helper lines round off error
CCBUGS: 120450


 M  +35 -22    imageselectionwidget.cpp  


--- trunk/extragear/graphics/digikam/imageplugins/coreplugin/ratiocrop/imageselectionwidget.cpp #676581:676582
 @ -29,10 +29,10  @
 
 #define MINRANGE 0
 
-// Fibanocci irrationel Golden Number.
-#define PHI      1.618033988
+// Golden number (1+sqrt(5))/2
+#define PHI      1.61803398874989479
 // 1/PHI
-#define INVPHI   0.61803398903633
+#define INVPHI   0.61803398874989479
 
 // C++ includes.
 
 @ -862,43 +862,53  @
             if (d->flipHorGoldenGuide)
                 p.scale(-1, 1);
 
-            // Flip verical.
+            // Flip vertical.
             if (d->flipVerGoldenGuide)
                 p.scale(1, -1);
 
             int w = d->localRegionSelection.width();
             int h = d->localRegionSelection.height();
 
-            QRect R1(-w/2, -h/2,
-                     (int)(w/PHI), h);
-            QRect R2((int)(w*(INVPHI - 0.5)), (int)(h*(0.5 - INVPHI)),
-                     (int)(w*(1 - INVPHI)), (int)(h/PHI));
-            QRect R3((int)(w/2 - R2.width()/PHI), -h/2,
-                     (int)(R2.width()/PHI), h - R2.height());
+            // lengths for the golden mean and half the sizes of the region:
+            int w_g = (int)(w*INVPHI);
+            int h_g = (int)(h*INVPHI);
+            int w_2 = w/2;
+            int h_2 = h/2;
+
+            QRect R1(-w_2, -h_2, w_g, h);
+            // w - 2*w_2 corrects for one-pixel difference
+            // so that R2.right() is really at the right end of the region
+            QRect R2(w_g-w_2, h_2-h_g, w-w_g+1-(w - 2*w_2), h_g);
+
+            QRect R3((int)(w_2 - R2.width()*INVPHI), -h_2,
+                     (int)(R2.width()*INVPHI), h - R2.height());
             QRect R4(R2.x(), R1.y(), R3.x() - R2.x(),
-                     (int)(R3.height()/PHI));
-            QRect R5(R4.x(), R4.bottom(), (int)(R4.width()/PHI),
+                     (int)(R3.height()*INVPHI));
+            QRect R5(R4.x(), R4.bottom(), (int)(R4.width()*INVPHI),
                      R3.height() - R4.height());
-            QRect R6(R5.x() + R5.width(), R5.bottom() - (int)(R5.height()/PHI),
-                     R3.x() - R5.right(), (int)(R5.height()/PHI));
-            QRect R7(R6.right() - (int)(R6.width()/PHI), R4.bottom(),
-                     (int)(R6.width()/PHI), R5.height() - R6.height());
+            QRect R6(R5.x() + R5.width(), R5.bottom() - (int)(R5.height()*INVPHI),
+                     R3.x() - R5.right(), (int)(R5.height()*INVPHI));
+            QRect R7(R6.right() - (int)(R6.width()*INVPHI), R4.bottom(),
+                     (int)(R6.width()*INVPHI), R5.height() - R6.height());
 
             p.setPen(QPen(Qt::white, d->guideSize, Qt::SolidLine));
 
             // Drawing Golden sections.
             if (d->drawGoldenSection)
             {
+               // horizontal lines:
                p.drawLine( R1.left(), R2.top(),
                            R2.right(), R2.top());
 
                p.drawLine( R1.left(), R1.top() + R2.height(),
                            R2.right(), R1.top() + R2.height());
 
-               p.drawLine( R2.right() - R1.width(), R1.top(),
-                           R2.right() - R1.width(), R1.bottom() );
+               // vertical lines:
+               p.drawLine( R1.right(), R1.top(),
+                           R1.right(), R1.bottom() );
 
-               p.drawLine( R1.topRight(), R1.bottomRight() );
+               p.drawLine( R1.left()+R2.width(), R1.top(),
+                           R1.left()+R2.width(), R1.bottom() );              
             }
 
             // Drawing Golden triangle guides.
 @ -970,16 +980,19  @
             // Drawing Golden sections.
             if (d->drawGoldenSection)
             {
+               // horizontal lines:
                p.drawLine( R1.left(), R2.top(),
                            R2.right(), R2.top());
 
                p.drawLine( R1.left(), R1.top() + R2.height(),
                            R2.right(), R1.top() + R2.height());
 
-               p.drawLine( R2.right() - R1.width(), R1.top(),
-                           R2.right() - R1.width(), R1.bottom() );
+               // vertical lines:
+               p.drawLine( R1.right(), R1.top(),
+                           R1.right(), R1.bottom() );
 
-               p.drawLine( R1.topRight(), R1.bottomRight() );
+               p.drawLine( R1.left()+R2.width(), R1.top(),
+                           R1.left()+R2.width(), R1.bottom() );              
             }
 
             // Drawing Golden triangle guides.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel