ImageProcessing-ElectronicPublications / photoquick

Light-weight image viewer with crop,resize,collage, photogrid and filters
GNU General Public License v3.0
4 stars 0 forks source link

Un-tilt && scale 1:1 && big image #37

Open zvezdochiot opened 3 years ago

zvezdochiot commented 3 years ago

On large images (http://papacoma.narod.ru/maps/maps-images2/agdm_18615_b.jpg) in 1: 1 mode, when using Un-tilt and based on it, there are hard glitches: twitching and disappearing of the image from the canvas. It is impossible to work. Observed on both my Un-tilt implementation and implementation @ksharindam .

ksharindam commented 3 years ago

normal crop function should have the same problem. Because, the large pixmap is copied and drawn over it. may be drawing the rectangle on large pixmap is slow, or setting the pixmap is slow. Have to test it.

In both cases there is no simple solution.

zvezdochiot commented 3 years ago

❓ Maybe you should move drawCropBox(); in onMouseRelease?

zvezdochiot commented 3 years ago

It was possible to achieve performance by replacing interactivity with a pure click:

void
PerspectiveTransform:: onMousePress(QPoint pos)
{
    int i, n;
    float dx, dy, r, rmin = 0.0f;
    clk_pos = pos;
    clk_area = 0;
    n = pt.count();
    for (i = 0; i < n; i++)
    {
        dx = clk_pos.x() - pt[i].x();
        dy = clk_pos.y() - pt[i].y();
        r = dx * dx + dy * dy;
        if ((i == 0) || (r < rmin))
        {
            clk_area = i + 1;
            rmin = r;
        }
    }
    QPointF last_pt = QPoint(pixmap.width()-1, pixmap.height()-1);
    QPointF new_pt;
    if (clk_area > 0)
    {
        new_pt = pos;
        p[clk_area - 1] = QPointF(MIN(last_pt.x(), MAX(0, new_pt.x())), MIN(last_pt.y(), MAX(0, new_pt.y())));
    }
    pt = p;
}

void
PerspectiveTransform:: onMouseRelease(QPoint /*pos*/)
{
    drawCropBox();
}

⚠️ The bug with the disappearance of the image from the canvas remains!

ksharindam commented 3 years ago

Working with very large images require large memory. How much ram do your pc have?

Absence of interactive nature is undesirable. Interactivity should be disabled only in larger images.

On Sun, 8 Aug, 2021, 10:00 PM звездочёт, @.***> wrote:

It was possible to achieve performance by replacing interactivity with a pure click:

void

PerspectiveTransform:: onMousePress(QPoint pos)

{

int i, n;

float dx, dy, r, rmin = 0.0f;

clk_pos = pos;

clk_area = 0;

n = pt.count();

for (i = 0; i < n; i++)

{

    dx = clk_pos.x() - pt[i].x();

    dy = clk_pos.y() - pt[i].y();

    r = dx * dx + dy * dy;

    if ((i == 0) || (r < rmin))

    {

        clk_area = i + 1;

        rmin = r;

    }

}

QPointF last_pt = QPoint(pixmap.width()-1, pixmap.height()-1);

QPointF new_pt;

if (clk_area > 0)

{

    new_pt = pos;

    p[clk_area - 1] = QPointF(MIN(last_pt.x(), MAX(0, new_pt.x())), MIN(last_pt.y(), MAX(0, new_pt.y())));

}

pt = p;

drawCropBox();

}

⚠️ The bug with the disappearance of the image from the canvas remains!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ImageProcessing-ElectronicPublications/photoquick/issues/37#issuecomment-894822033, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEKWXPWRX6ZPHD2ISDF2D33T32WKVANCNFSM5BXJAIFQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

zvezdochiot commented 3 years ago

ℹ️ RAM: 8.00 Gb

Interactivity should be disabled only in larger images.

No. The bug does not occur if the large image is scaled to fit the window. The bug is related to scrolling.

zvezdochiot commented 3 years ago

https://github.com/ImageProcessing-ElectronicPublications/photoquick/blob/2bbafe0cb64368a4951518f2e868e1a890e22224/src/transform.cpp#L324 https://github.com/ImageProcessing-ElectronicPublications/photoquick/blob/2bbafe0cb64368a4951518f2e868e1a890e22224/src/transform.cpp#L399-L400 in 1: 1 mode, it triples memory consumption.

zvezdochiot commented 3 years ago

Hi @ksharindam .

❓ Maybe add a selection dialog box to reduce memory consumption: color / quant / BW (threshold)?