Hi,
On Mon, 2008-09-29 at 12:10 +0200, Samuel wrote:
> I have been at the GIMP IRC channel and they told me that C is faster
> than Python if I want many pixel ops. I wrote a test plugin in Python
> which copies a layer pixel per pixel to another one and it needs
> several minutes for a vga picture.
> I put it here:
> http://pastebin.com/m1e61c74a
What you are doing there is quite ineffecient. Your plug-in does not
allocate a tile cache. And since you are reading a pixel from one tile,
then writing a pixel to another tile, the tiles have to be re-requested
from the core over and over again. There are several ways you can
improve this:
(1) Use a tile-cache with two tiles: gimp.tile_cache_ntiles(2).
(2) Change your access pattern to iterate over the layer
tile-by-tile instead of doing it row-by-row. If you want to
keep row-by-row access, then you should increase your tile
cache further so that it can hold 2 rows of tiles.
(3) Instead of reading and writing single pixels, you could
read and write arrays of pixels. For example rows of
GIMP_TILE_WIDTH. This would reduce the overhead you have
to do for each pixel.
Sven
_______________________________________________
Gimp-developer mailing list
[email protected]
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer