Transforms a layer and returns the resulting pixel data.
339120
function getTransformedLayerData(iCanvas, layer, rect) {
    var canvas = document.createElement('canvas');
    var ctx = canvas.getContext('2d');
    canvas.width = rect.width;
    canvas.height = rect.height;
    ctx.translate(-rect.x, -rect.y);
    transformLayer(ctx, iCanvas, layer);
    ctx.drawImage(layer.img, 0, 0);
    return ctx.getImageData(0, 0, rect.width, rect.height);
}
762334
def tiles_to_pixels(self, tiles):
        """"""
        pixel_coords = Vector2()
        pixel_coords.X = tiles[0] * self.spritesheet[0].width
        pixel_coords.Y = tiles[1] * self.spritesheet[0].height
        return pixel_coords
13762
def transform_data(self, data, request=None, response=None, context=None):
        transform = self.transform
        if hasattr(transform, 'context'):
            self.transform.context = context
        """"""
        if transform and not (isinstance(transform, type) and isinstance(data, transform)):
            if self._params_for_transform:
                return transform(data, **self._arguments(self._params_for_transform, request, response))
            else:
                return transform(data)
        return data
122047
def _transform(self, data, transform, step_size):
    '''
    
    '''
    if transform=='mean':
      total = sum( k*v for k,v in data.items() )
      count = sum( data.values() )
      data = float(total)/float(count) if count>0 else 0
    elif transform=='count':
      data = sum(data.values())
    elif transform=='min':
      data = min(data.keys() or [0])
    elif transform=='max':
      data = max(data.keys() or [0])
    elif transform=='sum':
      data = sum( k*v for k,v in data.items() )
    elif transform=='rate':
      data = { k:v/float(step_size) for k,v in data.items() }
    elif callable(transform):
      data = transform(data, step_size)
    return data
507598
def _blend_layers(self, imagecontent, z_x_y):
        
        (z, x, y) = z_x_y
        result = self._tile_image(imagecontent)
        # Paste each layer
        for (layer, opacity) in self._layers:
            try:
                # Prepare tile of overlay, if available
                overlay = self._tile_image(layer.tile((z, x, y)))
            except (IOError, DownloadError, ExtractionError)as e:
                logger.warn(e)
                continue
            # Extract alpha mask
            overlay = overlay.convert("RGBA")
            r, g, b, a = overlay.split()
            overlay = Image.merge("RGB", (r, g, b))
            a = ImageEnhance.Brightness(a).enhance(opacity)
            overlay.putalpha(a)
            mask = Image.merge("L", (a,))
            result.paste(overlay, (0, 0), mask)
        # Read result
        return self._image_tile(result)
426620
def transform(self):
        """"""
        ax = self.ax
        return {'axes': ax.transAxes,
                'fig': ax.get_figure().transFigure,
                'data': ax.transData}
641205
def _tile_image(self, data):
        
        image = Image.open(BytesIO(data))
        return image.convert('RGBA')
256607
def convert(self, layer=2, split_sign = '_', *args, **kwargs):
        """"""
        return series2df(self.series, *args, **kwargs)
306034
def convert_layer_to_pil(layer, apply_icc=True, **kwargs):
    """"""
    from PIL import Image
    header = layer._psd._record.header
    if header.color_mode == ColorMode.BITMAP:
        raise NotImplementedError
    width, height = layer.width, layer.height
    channels, alpha = [], None
    for ci, cd in zip(layer._record.channel_info, layer._channels):
        if ci.id in (ChannelID.USER_LAYER_MASK,
                     ChannelID.REAL_USER_LAYER_MASK):
            continue
        channel = cd.get_data(width, height, header.depth, header.version)
        channel_image = _create_channel(
            (width, height), channel, header.depth
        )
        if ci.id == ChannelID.TRANSPARENCY_MASK:
            alpha = channel_image
        else:
            channels.append(channel_image)
    mode = get_pil_mode(header.color_mode.name)
    channels = _check_channels(channels, header.color_mode)
    image = Image.merge(mode, channels)
    if mode == 'CMYK':
        image = image.point(lambda x: 255 - x)
    if alpha is not None:
        if mode in ('RGB', 'L'):
            image.putalpha(alpha)
        else:
            logger.debug('Alpha channel is not supported in %s' % (mode))

    if apply_icc and 'ICC_PROFILE' in layer._psd.image_resources:
        image = _apply_icc(
            image, layer._psd.image_resources.get_data('ICC_PROFILE')
        )
    return image
552643
public void render(int x, int y, int layer) {
		render(x, y, 0, 0, getWidth(), getHeight(), layer, false);
	}
536667
def _pixel_data(image):
    
    # Test for PIL.Image and numpy.ndarray without requiring that cv2 or PIL
    # are installed.
    if 'PIL.' in str(type(image)):
        if 'L' != image.mode:
            image = image.convert('L')
        pixels = image.tobytes()
        width, height = image.size
    elif 'numpy.ndarray' in str(type(image)):
        if 3 == len(image.shape):
            # Take just the first channel
            image = image[:, :, 0]
        if 'uint8' != str(image.dtype):
            image = image.astype('uint8')
        try:
            pixels = image.tobytes()
        except AttributeError:
            # `numpy.ndarray.tobytes()` introduced in `numpy` 1.9.0 - use the
            # older `tostring` method.
            pixels = image.tostring()
        height, width = image.shape[:2]
    else:
        # image should be a tuple (pixels, width, height)
        pixels, width, height = image

        # Check dimensions
        if 0 != len(pixels) % (width * height):
            raise PyZbarError(
                (
                    'Inconsistent dimensions: image data of {0} bytes is not '
                    'divisible by (width x height = {1})'
                ).format(len(pixels), (width * height))
            )

    # Compute bits-per-pixel
    bpp = 8 * len(pixels) // (width * height)
    if 8 != bpp:
        raise PyZbarError(
            'Unsupported bits-per-pixel [{0}]. Only [8] is supported.'.format(
                bpp
            )
        )

    return pixels, width, height
321937
function readImageLayer(map, data, z) {
        // Normalize properties
        me.TMXUtils.applyTMXProperties(data.properties, data);

        // create the layer
        var imageLayer = me.pool.pull("me.ImageLayer",
            // x/y is deprecated since 0.15 and replace by offsetx/y
            +data.offsetx || +data.x || 0,
            +data.offsety || +data.y || 0,
            Object.assign({
                name: data.name,
                image: data.image,
                z: z
            }, data.properties)
        );

        // set some additional flags
        var visible = typeof(data.visible) !== "undefined" ? data.visible : true;
        imageLayer.setOpacity(visible ? +data.opacity : 0);

        return imageLayer;
    }
600967
def layerData(self):
        
        output = {}
        
        output['visible'] = self.isVisible()
        output['zValue']  = self.zValue()
        output['current'] = self.isCurrent()
        
        return output
966276
function storedPixelDataToImageData (image) {
  // Transfer image data to alpha channel of WebGL texture
  // Store data in Uint8Array
  const pixelData = image.getPixelData();
  const numberOfChannels = 2;
  const data = new Uint8Array(image.width * image.height * numberOfChannels);
  let offset = 0;

  for (let i = 0; i < pixelData.length; i++) {
    data[offset++] = pixelData[i];
    data[offset++] = pixelData[i] < 0 ? 0 : 1; // 0 For negative, 1 for positive
  }

  return data;
}
227173
def get_transform(self):
        
        return _InterpolatedInverseTransform(transform=self._transform,
                                             smin=0,
                                             smax=self._transform._M)
267989
def transformer(data, label):
    """"""
    # resize to 64x64
    data = mx.image.imresize(data, 64, 64)
    # transpose from (64, 64, 3) to (3, 64, 64)
    data = mx.nd.transpose(data, (2, 0, 1))
    # normalize to [-1, 1]
    data = data.astype(np.float32)/128 - 1
    # if image is greyscale, repeat 3 times to get RGB image.
    if data.shape[0] == 1:
        data = mx.nd.tile(data, (3, 1, 1))
    return data, label
208639
def convolve(data, h, res_g=None, sub_blocks=None):
    

    if not len(data.shape) in [1, 2, 3]:
        raise ValueError("dim = %s not supported" % (len(data.shape)))

    if len(data.shape) != len(h.shape):
        raise ValueError("dimemnsion of data (%s) and h (%s) are different" % (len(data.shape), len(h.shape)))

    if isinstance(data, OCLArray) and isinstance(h, OCLArray):
        return _convolve_buf(data, h, res_g)
    elif isinstance(data, np.ndarray) and isinstance(h, np.ndarray):
        if sub_blocks == (1,) * len(data.shape) or sub_blocks is None:
            return _convolve_np(data, h)
        else:
            # cut the image into tile and operate on every of them
            N_sub = [int(np.ceil(1. * n / s)) for n, s in zip(data.shape, sub_blocks)]
            Npads = [int(s / 2) for s in h.shape]
            res = np.empty(data.shape, np.float32)
            for data_tile, data_s_src, data_s_dest \
                    in tile_iterator(data, blocksize=N_sub,
                                     padsize=Npads,
                                     mode="constant"):
                res_tile = _convolve_np(data_tile.copy(),
                                        h)
                res[data_s_src] = res_tile[data_s_dest]
            return res
    else:
        raise TypeError("unknown types (%s, %s)" % (type(data), type(h)))