Example usage for com.google.gwt.canvas.dom.client ImageData getBlueAt

List of usage examples for com.google.gwt.canvas.dom.client ImageData getBlueAt

Introduction

In this page you can find the example usage for com.google.gwt.canvas.dom.client ImageData getBlueAt.

Prototype

public final int getBlueAt(int x, int y) 

Source Link

Document

Returns the blue value at position (x,y).

Usage

From source file:nl.mpi.tg.eg.experiment.client.view.ColourPickerCanvasView.java

License:Open Source License

private void setColour(int x, int y, Canvas targetCanvas, VerticalPanel targetPanel) {
    x = (x >= targetCanvas.getCoordinateSpaceWidth()) ? targetCanvas.getCoordinateSpaceWidth() - 1 : x;
    y = (y >= targetCanvas.getCoordinateSpaceHeight()) ? targetCanvas.getCoordinateSpaceHeight() - 1 : y;
    final ImageData imageData = targetCanvas.getContext2d().getImageData(x, y, 1, 1);
    final int blue = imageData.getBlueAt(0, 0);
    final int green = imageData.getGreenAt(0, 0);
    final int red = imageData.getRedAt(0, 0);
    if (targetPanel.equals(selectedColourPanel)) {
        selectedColourData = new ColourData(red, green, blue);
    }//from w w w. j a v  a2 s  .com
    targetPanel.getElement().setAttribute("style", "background:rgb(" + red + "," + green + "," + blue + ")");
}

From source file:nl.mpi.tg.eg.experiment.client.view.ColourPickerCanvasView.java

License:Open Source License

private void setHue(int x, int y, Canvas targetCanvas) {
    x = (x >= targetCanvas.getCoordinateSpaceWidth()) ? targetCanvas.getCoordinateSpaceWidth() - 1 : x;
    y = (y >= targetCanvas.getCoordinateSpaceHeight()) ? targetCanvas.getCoordinateSpaceHeight() - 1 : y;
    final ImageData imageData = targetCanvas.getContext2d().getImageData(x, y, 1, 1);
    final int blue = imageData.getBlueAt(0, 0);
    final int green = imageData.getGreenAt(0, 0);
    final int red = imageData.getRedAt(0, 0);
    setHue(red, green, blue);/*from  www  . j a  v  a 2  s  . c  om*/
}