예제 #1
0
파일: grid.py 프로젝트: ria4/bourrette
 def has_transparent_end(self, layer):
     # Detect degraded fibers from a transparent end
     nbr_channels, m = pdb.gimp_drawable_get_pixel(layer, self.m.x,
                                                   self.m.y)
     nbr_channels, n = pdb.gimp_drawable_get_pixel(layer, self.n.x,
                                                   self.n.y)
     if nbr_channels < 4:
         return False
     return (m[3] == 0) or (n[3] == 0)
def nobox(image=None):
    if not image:
        image = gimp.image_list()[0]
    pdb.gimp_context_set_sample_transparent(True)
    image_size = (image.width, image.height)
    for layer in image.layers:
        if not pdb.gimp_drawable_has_alpha(layer):
            layer.add_alpha()
        if layer.offsets != (0, 0) or (layer.width,
                                       layer.height) != image_size:
            pdb.gimp_layer_resize_to_image_size(layer)
        (xmax, ymax) = (image.width - 1, image.height - 1)
        for (x, y) in [(0, 0), (xmax, 0), (0, ymax), (xmax, ymax)]:
            _num_channels, pixel = pdb.gimp_drawable_get_pixel(layer, x, y)
            if all(p > 240 for p in pixel):
                pdb.gimp_image_select_contiguous_color(image, 2, layer, x, y)
                pdb.gimp_edit_clear(layer)
def _is_black(inImg, inLayer, inX, inY):
    _, pixel = pdb.gimp_drawable_get_pixel(inLayer, inX, inY)
    return pixel[0] == 0 and pixel[1] == 0 and pixel[2] == 0
def _is_transparent(inImg, inLayer, inX, inY):
    _, pixel = pdb.gimp_drawable_get_pixel(inLayer, inX, inY)
    return pixel[3] == 0