No description, website, or topics provided.
JavaScript
Latest commit 91c1469 Dec 7, 2015 Petar Petrov updated README
Permalink
Failed to load latest commit information.
dist
src small fix Dec 7, 2015
.gitignore initial code commit Oct 29, 2015
.jshintrc initial code commit Oct 29, 2015
Gulpfile.js initial code commit Oct 29, 2015
LICENSE Added Apache license Nov 3, 2015
README.md
package.json

README.md

OpenSeadragonRGB

An OpenSeadragon plugin to allow reading the rgb values of image pixels.

Demo

http://picturae.github.io/openseadragonselection/#tabs-rgb

Usage

This plugin requires the latest version of OpenSeadragon

Include dist/openseadragonrgb.js after OpenSeadragon in your html. Then after you create a viewer:

var rgbPlugin = viewer.rgb(options);

Options

viewer.rgb({
    onCanvasHover: function(color) {},
});

Get values

You can get the RGBA value at an arbitrary point using viewport coordinates like this:

var color = rgbPlugin.getValueAt(x, y);

Then color (wheter from getValueAt() or passed to the onCanvasHover callback) will contain:

{
    r: Number, // value for Red channel
    g: Number, // value for Green channel
    b: Number, // value for Blue channel
    a: Number, // value for Alpha channel
    image: OpenSeadragon.TiledImage // image that contains this pixel if there is any
}

CORS

If your tiles come from a different domain, you may get this error in the console:

Uncaught SecurityError: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.

The only way to fix this is to make the tile server return the Access-Control-Allow-Origin: * header and pass the crossOriginPolicy: 'Anonymous' option to OpenSeadragon. For more info on this go to https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Access-Control-Allow-Origin