=== modified file 'src/com/goldencode/p2j/ui/client/gui/ImageGuiImpl.java' --- src/com/goldencode/p2j/ui/client/gui/ImageGuiImpl.java 2015-05-18 20:48:28 +0000 +++ src/com/goldencode/p2j/ui/client/gui/ImageGuiImpl.java 2015-09-01 18:03:50 +0000 @@ -415,6 +415,15 @@ { offsetY = 0; } + /** + * Sets the window icon. The drawing parameters are due to the drawing operations are + * performed on the server side for the web rendering engine implementation. + */ + if (isIcon) + { + gd.setIcon(img, 0, 0, iw, ih, offsetX, offsetY, icfg.transparent, + icfg.stretchToFit && !isIcon, icfg.retainShape, icfg.convert3D); + } // render image gd.drawImage(img, 0, 0, iw, ih, offsetX, offsetY, icfg.transparent, icfg.stretchToFit && !isIcon, icfg.retainShape, icfg.convert3D); === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java' --- src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java 2015-09-01 15:52:56 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java 2015-09-01 18:07:39 +0000 @@ -931,17 +931,7 @@ boolean convert3D) { PaintStructure ps = new PaintStructure(PaintPrimitives.DRAW_IMAGE); - ps.x = x; - ps.y = y; - ps.width = w; - ps.height = h; - ps.xOffset = xoff; - ps.yOffset = yoff; - ps.transparent = transparent; - ps.stretchToFit = stretch; - ps.retainShape = retain; - ps.convert3D = convert3D; - ps.img = img; + fillPaintStructure(ps, img, x, y, w, h, xoff, yoff, transparent, stretch, retain, convert3D); ews.offer(ps); } @@ -1015,21 +1005,105 @@ * * @param icon * The wrapped icon. + * @param x + * The icon left location. + * @param y + * The icon top location. * @param width - * the icon width. + * The icon width. * @param height - * the icon height. + * The icon height. + * @param xoff + * x offset inside image of the icon to select drawing region. + * @param yoff + * y offset inside image of the icon to select drawing region. + * @param transparent + * Flag indicating to use lower-left pixel as color marker to draw part of image as + * transparent. + * @param stretch + * Flag indicating stretch or shrink the image to fit display area. + * @param retain + * Flag indicating keep original image aspect ratio when stretching the image. + * @param convert3D + * Flag indicating autoconvert some image colors to the corresponding system wide 3D + * colors. */ @Override - public void setIcon(ImageWrapper icon, int width, int height) + public void setIcon(ImageWrapper icon, + int x, + int y, + int width, + int height, + int xoff, + int yoff, + boolean transparent, + boolean stretch, + boolean retain, + boolean convert3D) { PaintStructure ps = new PaintStructure(PaintPrimitives.SET_ICON); - ps.img = icon; - ps.width = width; - ps.height = height; + fillPaintStructure(ps, icon, x, y, width, height, xoff, yoff, transparent, stretch, retain, + convert3D); ews.offer(ps); } + + /** + * Fills the helper paint structure with target values. + * + * @param ps + * The paint structure to be filled with the provided values. + * @param img + * The wrapped image. + * @param x + * The image left location. + * @param y + * The image top location. + * @param w + * The image width. + * @param h + * The image height. + * @param xoff + * x offset inside image to select the drawing region. + * @param yoff + * y offset inside image to select the drawing region. + * @param transparent + * Flag indicating to use lower-left pixel as color marker to draw part of image as + * transparent. + * @param stretch + * Flag indicating stretch or shrink the image to fit display area. + * @param retain + * Flag indicating keep original image aspect ratio when stretching the image. + * @param convert3D + * Flag indicating autoconvert some image colors to the corresponding system wide 3D + * colors. + */ + private static void fillPaintStructure( + PaintStructure ps, + ImageWrapper img, + int x, + int y, + int w, + int h, + int xoff, + int yoff, + boolean transparent, + boolean stretch, + boolean retain, + boolean convert3D) + { + ps.x = x; + ps.y = y; + ps.width = w; + ps.height = h; + ps.xOffset = xoff; + ps.yOffset = yoff; + ps.transparent = transparent; + ps.stretchToFit = stretch; + ps.retainShape = retain; + ps.convert3D = convert3D; + ps.img = img; + } /** * Set current font used on draw operations. === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/EmulatedWindowState.java' --- src/com/goldencode/p2j/ui/client/gui/driver/EmulatedWindowState.java 2015-09-01 15:52:56 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/EmulatedWindowState.java 2015-09-01 18:07:39 +0000 @@ -474,6 +474,7 @@ ps.height, ps.arcDiameter); break; + case SET_ICON: case DRAW_RECT: case FILL_RECT: case DRAW_IMAGE: === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java' --- src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java 2015-09-01 12:47:54 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java 2015-09-01 17:41:20 +0000 @@ -964,10 +964,38 @@ * * @param icon * The wrapped icon. + * @param x + * The icon left location. + * @param y + * The icon top location. * @param width - * the icon width. + * The icon width. * @param height - * the icon height. + * The icon height. + * @param xoff + * x offset inside image of the icon to select drawing region. + * @param yoff + * y offset inside image of the icon to select drawing region. + * @param transparent + * Flag indicating to use lower-left pixel as color marker to draw part of image as + * transparent. + * @param stretch + * Flag indicating stretch or shrink the image to fit display area. + * @param retain + * Flag indicating keep original image aspect ratio when stretching the image. + * @param convert3D + * Flag indicating autoconvert some image colors to the corresponding system wide 3D + * colors. */ - public void setIcon(ImageWrapper icon, int width, int height); + public void setIcon(ImageWrapper icon, + int x, + int y, + int width, + int height, + int xoff, + int yoff, + boolean transparent, + boolean stretch, + boolean retain, + boolean convert3D); } === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java' --- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java 2015-09-01 15:52:56 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java 2015-09-01 18:19:43 +0000 @@ -401,12 +401,13 @@ break; case SET_ICON: { - ImageWrapper wrappedImage = ps.img; - Object[] imageEncodedPacket = encodeImage(0, 0, wrappedImage); + ImageWrapper wrappedImage = drawHelper.processImage(ps); + Object[] imageEncodedPacket = encodeImage(ps.x, ps.y, wrappedImage); int imageHash = (Integer) imageEncodedPacket[0]; ImageEncoding encoding = (ImageEncoding) imageEncodedPacket[1]; byte[] encodedImage = (byte[]) imageEncodedPacket[2]; - websock.setIconImage(ps.width, ps.height, encoding, imageHash, encodedImage); + websock.setIconImage(wrappedImage.getWidth(), wrappedImage.getHeight(), encoding, + imageHash, encodedImage); } break; default: === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js' --- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2015-09-01 15:52:56 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2015-09-01 18:07:39 +0000 @@ -1151,6 +1151,7 @@ case ops.SET_ICON: var iconWidth = p2j.socket.readInt32BinaryMessage(message, idx + 1); var iconHeight = p2j.socket.readInt32BinaryMessage(message, idx + 5); + extra = " x = 0; y = 0; width = " + iconWidth + "; height = " + iconHeight; var encoding = message[idx + 9]; var key = p2j.socket.readInt32BinaryMessage(message, idx + 10); var pixelsInBytes = iconWidth * iconHeight * 4; @@ -1165,6 +1166,7 @@ this.iconWidth = iconWidth; this.iconHeight = iconHeight; } + break; default: if (typeof type !== "undefined")