On 1/18/07, Manuel Quiñones <[EMAIL PROTECTED]> wrote:
I've had a similar idea than yours, and implemented it right away. But
instead of changing zones with keystrokes, the zone can be selected
using the crosspoint of two perpendicular guides. I know this is ugly,
and maybe your idea about changing to next/previous zone is better.
Here it is:
http://www.box.net/public/arhs7a3h9m
I'm sorry but not direct link. I cannot register it to the gimp
registry, because of http errors. And a fine tutorial:
http://wiki.gimp.org/gimp/DrawingZones
Regards,
Manuel
That gives me an idea: Sample points are probably quite appropriate to use
here. We just need a PDB interface to access them.
My implementation of my idea is attached. It ISN'T a plugin, it's just a
module that can be copy+pasted into a plugin.
(or in my case, imported. I have written >360k of libraries for pygimp so I
set up PyGimp to be able to find them)
def zonemapInfo(drawable):
"""Return a (maybe newly created) zone map and the currently selected area number"""
import gimp
tattoo = drawable.tattoo
channels = drawable.image.channels
searchstring = '%d-Zonemap;' % tattoo
# if there isn't one, just create one.
channels = filter(lambda v: v.name.startswith (searchstring), channels)
if len (channels) == 0:
# create a new zonemap
image = drawable.image
zonemap = gimp.Channel (image, '%d-Zonemap; Current: 00' % drawable.tattoo, image.width, image.height, 100.0, gimp.get_foreground())
from gimpenums import FOREGROUND_FILL
zonemap.fill (FOREGROUND_FILL)
image.add_channel(zonemap)
return zonemap, 0
zonemap = channels[0]
import re
current = re.findall("[0-9]+-Zonemap; Current: ([0-9a-fA-F]{2,2})",zonemap.name)[0]
current = int (current, 16)
return zonemap, current
def nextZonemapValue (zm, thisv):
"""Return the next area number used in the zonemap"""
import gimp
pr = zm.get_pixel_rgn(0,0, zm.width, zm.height, True, False)
data = pr[:,:]
r = range((thisv+1) % 256, 256)
if r[0] > 0:
# wraparound
r.extend (range (0, thisv + 1))
for v in r:
if chr(v) in data:
return v
return 0
def cycleZonemap(drawable):
"""Cycle to the next area defined in the zonemap"""
zonemap,activepoint = zonemapInfo (drawable)
nextv = nextZonemapValue (zonemap, activepoint)
drawable.image.undo_group_start()
from gimp import pdb
pdb.gimp_selection_load(zonemap)
from ai.gimp.pibgimp.tools import threshold
threshold(drawable.image.selection, nextv, nextv)
zonemap.name = '%d-Zonemap; Current: %02x' % (drawable.tattoo, nextv)
drawable.image.undo_group_end()
def enforceZonemap(drawable):
"""Limit the selection to the currently selected zonemap area"""
zonemap,activepoint = zonemapInfo (drawable)
# intersect the thresholded zonemap with the selection.
drawable.image.undo_group_start()
tmp = zonemap.copy()
zonemap.image.add_channel (tmp)
from ai.gimp.pibgimp.tools import threshold
saved = drawable.image.selection.copy()
drawable.image.add_channel(saved)
# channel apply
import gimp
gimp.pdb.gimp_selection_none (drawable.image)
threshold(tmp, activepoint, activepoint)
gimp.pdb.gimp_selection_load (saved)
drawable.image.remove_channel (saved)
gimp.delete (saved)
from gimpenums import CHANNEL_OP_INTERSECT, CHANNEL_OP_REPLACE
op = CHANNEL_OP_INTERSECT
if gimp.pdb.gimp_selection_is_empty (drawable.image):
op = CHANNEL_OP_REPLACE
gimp.pdb.gimp_channel_combine_masks (drawable.image.selection, tmp, op, 0, 0)
# gimp.pdb.gimp_selection_sharpen(drawable.image)
zonemap.image.remove_channel (tmp)
gimp.delete(tmp)
drawable.image.undo_group_end()
_______________________________________________
Gimp-developer mailing list
[email protected]
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer