01-24-2018, 12:07 AM
You are jumping to conclusions. The problem isn't accessing the region, it is looping... and you don't really need to copy to an array you can loop of the region directly (but it is only marginally faster).
Looping on tiles is fast, if you don't need to reload the tiles. Tiles are to Gimp what RAM pages are to your system. If your algorithm can use a tile, put it back, and never need to come back to it, it's fast. If you load tiles at random, performance will degrade.
1) How do I translate a tile's pixel position to it's layer's global pixel position so I can select it with "pdb.gimp_fuzzy_select(img.active_layer, <x_position_of_pixel>, <y_position_of_pixel>, 254.9 , 2,0,0, 0,0)" ?
Just add the "layer.offsets" to the layer-relative X and Y position.
2) How do I exit the loop, update the layer by clearing selection, update layer, and resume the loop from last tile?
f.e. I want to accomplishthese steps for a 1024x1024 image with 16x16 tiles:
-I find a non-transparent pixel at tile(3,4)
-I exit the tile loop
-select that pixel and neighboring non-transparent pixels with 'pdb.gimp_fuzzy_select'
-do some stuff
-update the layer
-and then resume tile loop at tile(3,4) until tile(16,16).
-script hopefully ends succesfully.
Why do you need to exit the tile loop? Just reload the tile when you are done with "some stuff/update the layer"
Looping on tiles is fast, if you don't need to reload the tiles. Tiles are to Gimp what RAM pages are to your system. If your algorithm can use a tile, put it back, and never need to come back to it, it's fast. If you load tiles at random, performance will degrade.
1) How do I translate a tile's pixel position to it's layer's global pixel position so I can select it with "pdb.gimp_fuzzy_select(img.active_layer, <x_position_of_pixel>, <y_position_of_pixel>, 254.9 , 2,0,0, 0,0)" ?
Just add the "layer.offsets" to the layer-relative X and Y position.
2) How do I exit the loop, update the layer by clearing selection, update layer, and resume the loop from last tile?
f.e. I want to accomplishthese steps for a 1024x1024 image with 16x16 tiles:
-I find a non-transparent pixel at tile(3,4)
-I exit the tile loop
-select that pixel and neighboring non-transparent pixels with 'pdb.gimp_fuzzy_select'
-do some stuff
-update the layer
-and then resume tile loop at tile(3,4) until tile(16,16).
-script hopefully ends succesfully.
Why do you need to exit the tile loop? Just reload the tile when you are done with "some stuff/update the layer"