(Y05) Reintroduced the methods for using ImageData, since they?re already implemented and I have a very good usecase:
It?s useful for the tricks we need on mobile for fast application launch: Take a snapshot of the UI at application shutdown and display it on application start.
1.1 --- a/javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java Wed Feb 12 14:19:10 2014 +0100
1.2 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java Wed Feb 12 14:43:38 2014 +0100
1.3 @@ -672,25 +672,25 @@
1.4 graphicsEnvironmentImpl.strokeText(text, x, y, maxWidth);
1.5 }
1.6
1.7 -// public ImageData createPixelMap(double x, double y) {
1.8 -// return graphicsEnvironmentImpl.createPixelMap(x, y);
1.9 -// }
1.10 -//
1.11 -// public ImageData createPixelMap(ImageData pixelMap) {
1.12 -// return graphicsEnvironmentImpl.createPixelMap(pixelMap);
1.13 -// }
1.14 -//
1.15 -// public ImageData getSnapshot(double x, double y, double width, double height) {
1.16 -// return graphicsEnvironmentImpl.getPixelMap(x, y, width, height);
1.17 -// }
1.18 -//
1.19 -// public void drawPixelMap(ImageData pixelMap, double x, double y) {
1.20 -// graphicsEnvironmentImpl.putPixelMap(pixelMap, x, y);
1.21 -// }
1.22 -//
1.23 -// public void drawPixelMap(ImageData pixelMap, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight) {
1.24 -// graphicsEnvironmentImpl.putPixelMap(pixelMap, x, y, dirtyx, dirtyy, dirtywidth, dirtyheight);
1.25 -// }
1.26 + public ImageData createPixelMap(double x, double y) {
1.27 + return graphicsEnvironmentImpl.createPixelMap(x, y);
1.28 + }
1.29 +
1.30 + public ImageData createPixelMap(ImageData pixelMap) {
1.31 + return graphicsEnvironmentImpl.createPixelMap(pixelMap);
1.32 + }
1.33 +
1.34 + public ImageData getSnapshot(double x, double y, double width, double height) {
1.35 + return graphicsEnvironmentImpl.getPixelMap(x, y, width, height);
1.36 + }
1.37 +
1.38 + public void drawPixelMap(ImageData pixelMap, double x, double y) {
1.39 + graphicsEnvironmentImpl.putPixelMap(pixelMap, x, y);
1.40 + }
1.41 +
1.42 + public void drawPixelMap(ImageData pixelMap, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight) {
1.43 + graphicsEnvironmentImpl.putPixelMap(pixelMap, x, y, dirtyx, dirtyy, dirtywidth, dirtyheight);
1.44 + }
1.45 /**
1.46 * Sets the global alpha of the current state.
1.47 *
2.1 --- a/javaquery/canvas/src/main/java/net/java/html/canvas/spi/GraphicsEnvironment.java Wed Feb 12 14:19:10 2014 +0100
2.2 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/spi/GraphicsEnvironment.java Wed Feb 12 14:43:38 2014 +0100
2.3 @@ -19,6 +19,7 @@
2.4
2.5 import net.java.html.canvas.Dimension;
2.6 import net.java.html.canvas.Image;
2.7 +import net.java.html.canvas.ImageData;
2.8 import net.java.html.canvas.Style;
2.9
2.10 /**
2.11 @@ -527,15 +528,51 @@
2.12 */
2.13 public void strokeText(String text, double x, double y, double maxWidth);
2.14
2.15 -// public ImageData createPixelMap(double x, double y);
2.16 -//
2.17 -// public ImageData createPixelMap(ImageData imageData);
2.18 -//
2.19 -// public ImageData getPixelMap(double x, double y, double width, double height);
2.20 -//
2.21 -// public void putPixelMap(ImageData imageData, double x, double y);
2.22 -//
2.23 -// public void putPixelMap(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight);
2.24 + /**
2.25 + * Get a pixel array that you can manipulate, e.g. apply effects / transparency
2.26 + * @param x width
2.27 + * @param y height
2.28 + * @return a PixelMap
2.29 + */
2.30 + public ImageData createPixelMap(double x, double y);
2.31 +
2.32 + /**
2.33 + * Create a new ImageData object with the same dimensions as the
2.34 + * object specified by imageData (this does not copy the image data)
2.35 + * @param imageData
2.36 + * @return
2.37 + */
2.38 + public ImageData createPixelMap(ImageData imageData);
2.39 +
2.40 + /**
2.41 + * Get the pixels for a region of your GraphicsContext
2.42 + * @param x start x coordinate
2.43 + * @param y start y coordinate
2.44 + * @param width width
2.45 + * @param height height
2.46 + * @return
2.47 + */
2.48 + public ImageData getPixelMap(double x, double y, double width, double height);
2.49 +
2.50 + /**
2.51 + * Render an ImageData Object at the specified position
2.52 + * @param imageData the Pixel array
2.53 + * @param x start x coordinate
2.54 + * @param y start y coordinate
2.55 + */
2.56 + public void putPixelMap(ImageData imageData, double x, double y);
2.57 +
2.58 + /**
2.59 + * Render an ImageData Object at the specified position
2.60 + * @param imageData the Pixel array to draw
2.61 + * @param x start x coordinate
2.62 + * @param y start y coordinate
2.63 + * @param dirtyx The horizontal (x) value, in pixels, where to place the image on the canvas
2.64 + * @param dirtyy The vertical (y) value, in pixels, where to place the image on the canvas
2.65 + * @param dirtywidth The width to use to draw the image on the canvas
2.66 + * @param dirtyheight The height to use to draw the image on the canvas
2.67 + */
2.68 + public void putPixelMap(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight);
2.69 /**
2.70 * Sets the global alpha of the current state.
2.71 *