This method maintain an index of image masks associated with the provided
canvas. This method could be overloaded to implement a global index of
image masks.
512850
function(image, options) {
        var index = options.imageMaskIndex || this.options.imageMaskIndex;
        if (!index)
            return;
        if (typeof index === 'function') {
            index = index(image, options);
        }
        return index;
    }
883825
function(x, y) {
        var maskX = this._getMaskX(x);
        var maskY = this._getMaskY(y);
        var key = this._getIndexKey(maskX, maskY);
        return this._dataIndex[key];
    }
88230
function Canvas(width, height, gmsmith) {
  // Ignore width/height
  // DEV: Our canvas dimensions are dynamically defined by x/y of each image
  var canvas = gmsmith.gm(1, 1, 'transparent');

  // Override the -size options (won't work otherwise)
  canvas._in = ['-background', 'transparent'];

  // Save the canvas
  this.canvas = canvas;
}
679000
function canvasFilters(canvas, settings) {
    settings = Object.assign({}, {
        smoothing   : false,  // Smoothing [true|fale]
        brightness  : 0,      // Image brightness [-255 to +255]
        contrast    : 0,      // Image contrast [-255 to +255]
        gamma       : 0,      // Image gamma correction [0.01 to 7.99]
        grayscale   : 'none', // Graysale algorithm [average, luma, luma-601, luma-709, luma-240, desaturation, decomposition-[min|max], [red|green|blue]-chanel]
        shadesOfGray: 256,    // Number of shades of gray [2-256]
        invertColor : false   // Invert color...
    }, settings || {})

    // Get canvas 2d context
    let context = canvas.getContext('2d')

    // Smoothing
    if (context.imageSmoothingEnabled !== undefined) {
        context.imageSmoothingEnabled = settings.smoothing
    }
    else {
        context.mozImageSmoothingEnabled    = settings.smoothing
        context.webkitImageSmoothingEnabled = settings.smoothing
        context.msImageSmoothingEnabled     = settings.smoothing
        context.oImageSmoothingEnabled      = settings.smoothing
    }

    // Get image data
    let imageData = context.getImageData(0, 0, canvas.width, canvas.height)
    let data      = imageData.data

    let contrastFactor, brightnessOffset, gammaCorrection, shadesOfGrayFactor

    if (settings.contrast !== 0) {
        contrastFactor = (259 * (settings.contrast + 255)) / (255 * (259 - settings.contrast))
    }

    if (settings.brightness !== 0) {
        brightnessOffset = settings.brightness
    }

    if (settings.gamma !== 0) {
        gammaCorrection = 1 / settings.gamma
    }

    // Shades of gray
    if (settings.shadesOfGray > 1 && settings.shadesOfGray < 256) {
        shadesOfGrayFactor = 255 / (settings.shadesOfGray - 1)
    }

    // For each pixel
    for (let i = 0, il = data.length; i < il; i += 4) {
        // Apply filters
        invertColor(data, i, settings.invertColor)
        brightness(data, i, brightnessOffset)
        contrast(data, i, contrastFactor)
        gamma(data, i, gammaCorrection)
        grayscale(data, i, settings.grayscale, shadesOfGrayFactor)
    }

    // Write new image data on the context
    context.putImageData(imageData, 0, 0)
}
1092106
function(node) {
        var zIndex = node._style.graphicZIndex;
        
        // Everything must have a zIndex. If none is specified,
        // this means the user *must* (hint: assumption) want this
        // node to succomb to drawing order. To enforce drawing order
        // over all indexing methods, we'll create a new z-index that's
        // greater than any currently in the indexer.
        if (zIndex == null) {
            zIndex = this.maxZIndex;
            node._style.graphicZIndex = zIndex; 
        } else if (zIndex > this.maxZIndex) {
            this.maxZIndex = zIndex;
        }
    }
180756
function (canvasEl) {
       var context = canvasEl.getContext('2d'),
           imageData = context.getImageData(0, 0, canvasEl.width, canvasEl.height),
           data = imageData.data,
           iLen = imageData.width,
           jLen = imageData.height,
           index, average, i, j;

       for (i = 0; i < iLen; i++) {
         for (j = 0; j < jLen; j++) {

           index = (i * 4) * jLen + (j * 4);
           average = (data[index] + data[index + 1] + data[index + 2]) / 3;

           data[index]     = average;
           data[index + 1] = average;
           data[index + 2] = average;
         }
       }

       context.putImageData(imageData, 0, 0);
     }
559426
def redo(self):
        """"""
        if not self.gui_up:
            return

        self.clear_mask()

        image = self.fitsimage.get_image()
        if image is None:
            return

        n_obj = len(self._maskobjs)
        self.logger.debug('Displaying {0} masks'.format(n_obj))
        if n_obj == 0:
            return

        # Display info table
        self.recreate_toc()

        # Draw on canvas
        self.masktag = self.canvas.add(self.dc.CompoundObject(*self._maskobjs))
        self.fitsimage.redraw()
969818
function findCanvas(canvasId) {	
	for (var i = 0; i < canvases.length; i++)
		if(canvases[i].id == canvasId)
			return canvases[i];
	return null;
}
358244
def set_moving_mask(self, image):
        
        if not isinstance(image, iio.ANTsImage):
            raise ValueError('image must be ANTsImage type')

        if image.dimension != self.dimension:
            raise ValueError('image dim (%i) does not match metric dim (%i)' % (image.dimension, self.dimension))

        self._metric.setMovingImage(image.pointer, True)
        self.moving_mask = image
537512
public Integer getTextureMagFilter(AiTextureType type, int index) {
        checkTexRange(type, index);

        Property p = getProperty(PropertyKey.TEX_MAG_FILTER.m_key);

        if (null == p || null == p.getData()) {
            return (Integer) m_defaults.get(PropertyKey.TEX_MAG_FILTER);
        }
        Object rawValue = p.getData();
        if (rawValue instanceof java.nio.ByteBuffer)
        {
            java.nio.IntBuffer ibuf = ((java.nio.ByteBuffer) rawValue).asIntBuffer();
            return ibuf.get();
        }
        else
        {
            return (Integer) rawValue;
        }
    }
18278
function(e){
    var property = e.property;
    var ruleIds = this.get('ruleIds');
    var imageIndex = property.indexOf('background');

    if (imageIndex == -1) imageIndex = property.indexOf('background-image');

    ruleIds.push(e.id);
    if (imageIndex > -1) {
      this._collectImages(e, imageIndex);
    }
  }
716058
public void updateBitmapShader() {
		if (image == null)
			return;

		shader = new BitmapShader(image, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);

		if(canvasSize != image.getWidth() || canvasSize != image.getHeight()) {
			Matrix matrix = new Matrix();
			float scale = (float) canvasSize / (float) image.getWidth();
			matrix.setScale(scale, scale);
			shader.setLocalMatrix(matrix);
		}
	}
706465
def overlaps(self, canvas, exclude=[]):
        
        try:
            exclude = list(exclude)
        except TypeError:
            exclude = [exclude]
        exclude.append(self)

        for selfY, row in enumerate(self.image.image()):
            for selfX, pixel in enumerate(row):
                canvasPixelOn = canvas.testPixel(
                    (selfX + self.position[0], selfY + self.position[1]),
                    excludedSprites=exclude
                )
                if pixel and canvasPixelOn:
                    return True
        return False
263201
def _update_mask(self, mask: np.ndarray, polygons: Iterable, separate_instances: bool = False) -> None:
        
        for i, p in enumerate(polygons):
            if isinstance(p, geometry.MultiPolygon):
                self._update_mask(mask=mask, polygons=p.geoms, separate_instances=True)
                continue
            elif not isinstance(p, geometry.Polygon):
                continue
            poly_area = Image.fromarray(np.zeros(mask.shape, dtype=np.uint8))
            holes = Image.fromarray(np.zeros(mask.shape, dtype=np.uint8))
            outline_color = 0 if separate_instances else 255
            ImageDraw.Draw(poly_area).polygon(p.exterior.coords, fill=255, outline=outline_color)
            for h in p.interiors:
                ImageDraw.Draw(holes).polygon(h.coords, fill=255, outline=255)
            mask[np.nonzero(np.array(poly_area, dtype=np.uint8))] = 255
            mask[np.nonzero(np.array(holes, dtype=np.uint8))] = 0
1178460
def image2array(self, image):
        
        idex_mask = self._idex_mask
        array = util.image2array(image)
        if self._idex_mask_bool is True:
            return array[idex_mask == 1]
        else:
            return array
374356
public void imageUpdate(ImageReader source, BufferedImage theImage,
            int minX, int minY, int width, int height, int periodX,
            int periodY, int[] bands)
    {
        if (image == null || !image.equals(theImage))
        {
            repaint(0);
            image = theImage;
        }
    }
100137
def _clear(self):
        
        self._plain_image = [" " * self._width for _ in range(self._height)]
        self._colour_map = [[(None, 0, 0) for _ in range(self._width)]
                            for _ in range(self._height)]