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

List:       kde-kimageshop
Subject:    Re: Pixel access
From:       Cyrille Berger <cyb () lepi ! org>
Date:       2004-09-27 17:08:31
Message-ID: 200409271908.31903.cyb () lepi ! org
[Download RAW message or body]

> scaling gives good results, but the scaling code is really slow. The
> problem is, that the code accesses pixels using readpixel(x,y,x,y,pixel).
> This is probably the slowest way to access pixels. I think basically it
> would be the best idea to read a whole line from an image at a time. This
> could be done by calling readpixel (0,y,width(),y,line). But is this the
> most efficient way or is it better to use iterators. If yes, how can I use
> the iterators to read a whole line?

There are two functions to create an iterator : iteratorPixelBegin and 
iteratorPixelSelectionBegin, the first one if you don't care about selection, 
the second one if you care. I do think that in your case you need to use the 
first one.

KisIteratorLinePixel lineIt = device->iteratorPixelBegin( command, 0, width(), 
y);
KisIteratorPixel pixelIt = *linetIt;
KisIteratorPixel endIt = linetIt.end();
while( pixelIt <= endIt )
{
 // your computing
 ++pixelIt;
}

If y goes from 0 to height(), you might be willing to do this :

KisIteratorLinePixel lineIt = device->iteratorPixelBegin( command, 0, width(), 
0);
KisIteratorLinePixel endLineIt = device->iteratorPixelEnd( command, 0, 
width(), height);
while( lineIt <) endLineIt )
{
 KisIteratorPixel pixelIt = *linetIt;
 KisIteratorPixel endIt = linetIt.end();
 while( pixelIt <= endIt )
 {
   // your computing
   ++pixelIt;
 }
 ++lineIt;
}


-- 
--- Cyrille Berger ---
_______________________________________________
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