[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-kimageshop
Subject:    Re: Image update strategy
From:       Emanuele Tamponi <emanuele () valinor ! it>
Date:       2008-04-05 8:24:37
Message-ID: 200804051024.37789.emanuele () valinor ! it
[Download RAW message or body]

I wrote a simple (not optimized) version of the algorithm.
It takes as input a set of rects from command line (x,y,w,h) and calculates 
the non overlapping regions of them.

This solves one of the two problems in my idea, the second being the 
difficulty of finding "visible" layers.

Even without a solution to this second problem, I think that this way to do 
layer updating is very clear, linear, without strange recursive needs of 
visitors and the like. And it works directly as a bottom-up update strategy, 
so that adj. layers as well as alpha blending can be easily taken into 
account.

The executable is in:

www.valinor.it/test2


["main.cpp" (text/x-c++src)]

#include <QtCore>
#include <QtGui>

#include <iostream>
using namespace std;

QVector<QRegion> findNonOverlapping(QVector<QRegion> list)
{
    if (list.size() <= 1) {
        if (list.size() == 1 && list[0].isEmpty())
            list.clear();
        return list;
    } else {
        QVector<QRegion> list1;
        QVector<QRegion> list2;
        list1.append(list[1]);
        list2.append(list[0] ^ list[1]);
        for (int i = 2; i < list.size(); i++) {
            list1.append(list[i] & list1[0]);
            list2.append(list[i] & list2[0]);
        }
        return findNonOverlapping(list1) + findNonOverlapping(list2);
    }
}

int main(int argc, char *argv[])
{
    QVector<QRegion> starting;
    
    int x,y,w,h; char c = 'c';
    cout << "Base rect: ";
    cin >> x >> y >> w >> h;
    starting.append(QRegion(x,y,w,h));
    // QRegion base = QRegion(x,y,w,h);
    while (c == 'c') {
        cout << "New rect: ";
        cin >> x >> y >> w >> h >> c;
        starting.append(QRegion(x,y,w,h) & starting[0]);
    }
    
    QVector<QRegion> final = findNonOverlapping(starting);
    
    qDebug() << final;
    
    return 0;
}


_______________________________________________
kimageshop mailing list
kimageshop@kde.org
https://mail.kde.org/mailman/listinfo/kimageshop


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic