# HG changeset patch # User Anton Epple # Date 1392212618 -3600 # Node ID 0726c97795243c76294cf25736c4dd0a7a3e472e # Parent 6be5961e27ee1f5bab766c5a7186562b6dddba23 (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. diff -r 6be5961e27ee -r 0726c9779524 javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java --- a/javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java Wed Feb 12 14:19:10 2014 +0100 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java Wed Feb 12 14:43:38 2014 +0100 @@ -672,25 +672,25 @@ graphicsEnvironmentImpl.strokeText(text, x, y, maxWidth); } -// public ImageData createPixelMap(double x, double y) { -// return graphicsEnvironmentImpl.createPixelMap(x, y); -// } -// -// public ImageData createPixelMap(ImageData pixelMap) { -// return graphicsEnvironmentImpl.createPixelMap(pixelMap); -// } -// -// public ImageData getSnapshot(double x, double y, double width, double height) { -// return graphicsEnvironmentImpl.getPixelMap(x, y, width, height); -// } -// -// public void drawPixelMap(ImageData pixelMap, double x, double y) { -// graphicsEnvironmentImpl.putPixelMap(pixelMap, x, y); -// } -// -// public void drawPixelMap(ImageData pixelMap, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight) { -// graphicsEnvironmentImpl.putPixelMap(pixelMap, x, y, dirtyx, dirtyy, dirtywidth, dirtyheight); -// } + public ImageData createPixelMap(double x, double y) { + return graphicsEnvironmentImpl.createPixelMap(x, y); + } + + public ImageData createPixelMap(ImageData pixelMap) { + return graphicsEnvironmentImpl.createPixelMap(pixelMap); + } + + public ImageData getSnapshot(double x, double y, double width, double height) { + return graphicsEnvironmentImpl.getPixelMap(x, y, width, height); + } + + public void drawPixelMap(ImageData pixelMap, double x, double y) { + graphicsEnvironmentImpl.putPixelMap(pixelMap, x, y); + } + + public void drawPixelMap(ImageData pixelMap, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight) { + graphicsEnvironmentImpl.putPixelMap(pixelMap, x, y, dirtyx, dirtyy, dirtywidth, dirtyheight); + } /** * Sets the global alpha of the current state. * diff -r 6be5961e27ee -r 0726c9779524 javaquery/canvas/src/main/java/net/java/html/canvas/spi/GraphicsEnvironment.java --- a/javaquery/canvas/src/main/java/net/java/html/canvas/spi/GraphicsEnvironment.java Wed Feb 12 14:19:10 2014 +0100 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/spi/GraphicsEnvironment.java Wed Feb 12 14:43:38 2014 +0100 @@ -19,6 +19,7 @@ import net.java.html.canvas.Dimension; import net.java.html.canvas.Image; +import net.java.html.canvas.ImageData; import net.java.html.canvas.Style; /** @@ -527,15 +528,51 @@ */ public void strokeText(String text, double x, double y, double maxWidth); -// public ImageData createPixelMap(double x, double y); -// -// public ImageData createPixelMap(ImageData imageData); -// -// public ImageData getPixelMap(double x, double y, double width, double height); -// -// public void putPixelMap(ImageData imageData, double x, double y); -// -// public void putPixelMap(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight); + /** + * Get a pixel array that you can manipulate, e.g. apply effects / transparency + * @param x width + * @param y height + * @return a PixelMap + */ + public ImageData createPixelMap(double x, double y); + + /** + * Create a new ImageData object with the same dimensions as the + * object specified by imageData (this does not copy the image data) + * @param imageData + * @return + */ + public ImageData createPixelMap(ImageData imageData); + + /** + * Get the pixels for a region of your GraphicsContext + * @param x start x coordinate + * @param y start y coordinate + * @param width width + * @param height height + * @return + */ + public ImageData getPixelMap(double x, double y, double width, double height); + + /** + * Render an ImageData Object at the specified position + * @param imageData the Pixel array + * @param x start x coordinate + * @param y start y coordinate + */ + public void putPixelMap(ImageData imageData, double x, double y); + + /** + * Render an ImageData Object at the specified position + * @param imageData the Pixel array to draw + * @param x start x coordinate + * @param y start y coordinate + * @param dirtyx The horizontal (x) value, in pixels, where to place the image on the canvas + * @param dirtyy The vertical (y) value, in pixels, where to place the image on the canvas + * @param dirtywidth The width to use to draw the image on the canvas + * @param dirtyheight The height to use to draw the image on the canvas + */ + public void putPixelMap(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight); /** * Sets the global alpha of the current state. *