src/main/java/org/jfree/graphics2d/svg/SVGGraphics2D.java
@Override
    public boolean drawImage(Image img, int x, int y, int w, int h, 
            ImageObserver observer) {

        if (img == null) {
            return true; 
        }
        // the rendering hints control whether the image is embedded or
        // referenced...
        Object hint = getRenderingHint(SVGHints.KEY_IMAGE_HANDLING);
        if (SVGHints.VALUE_IMAGE_HANDLING_EMBED.equals(hint)) {
            this.sb.append("<image ");
            appendOptionalElementIDFromHint(this.sb);
            this.sb.append("preserveAspectRatio=\"none\" ");
            this.sb.append("xlink:href=\"data:image/png;base64,");
            this.sb.append(Base64.getEncoder().encode(getPNGBytes(
                    img)));
            this.sb.append("\" ");
            this.sb.append(getClipPathRef()).append(" ");
            if (!this.transform.isIdentity()) {
            	this.sb.append("transform=\"").append(getSVGTransform(
                    this.transform)).append("\" "); 
            }
            this.sb.append("x=\"").append(geomDP(x))
                    .append("\" y=\"").append(geomDP(y))
                    .append("\" ");
            this.sb.append("width=\"").append(geomDP(w)).append("\" height=\"")
                    .append(geomDP(h)).append("\"/>\n");
            return true;
        } else { // here for SVGHints.VALUE_IMAGE_HANDLING_REFERENCE
            int count = this.imageElements.size();
            String href = (String) this.hints.get(SVGHints.KEY_IMAGE_HREF);
            if (href == null) {
                href = this.filePrefix + count + this.fileSuffix;
            } else {
                // KEY_IMAGE_HREF value is for a single use...
                this.hints.put(SVGHints.KEY_IMAGE_HREF, null);
            }
            ImageElement imageElement = new ImageElement(href, img);
            this.imageElements.add(imageElement);
            // write an SVG element for the img
            this.sb.append("<image ");
            appendOptionalElementIDFromHint(this.sb);
            this.sb.append("xlink:href=\"");
            this.sb.append(href).append("\" ");
            this.sb.append(getClipPathRef()).append(" ");
            if (!this.transform.isIdentity()) {
            	this.sb.append("transform=\"").append(getSVGTransform(
                    this.transform)).append("\" ");
            }
            this.sb.append("x=\"").append(geomDP(x))
                    .append("\" y=\"").append(geomDP(y))
                    .append("\" ");
            this.sb.append("width=\"").append(geomDP(w)).append("\" height=\"")
                    .append(geomDP(h)).append("\"/>\n");
            return true;
        }
    }
@Override
    public boolean drawImage(Image img, int x, int y, int w, int h, 
            ImageObserver observer) {

        if (img == null) {
            return true; 
        }
        // the rendering hints control whether the image is embedded or
        // referenced...
        Object hint = getRenderingHint(SVGHints.KEY_IMAGE_HANDLING);
        if (SVGHints.VALUE_IMAGE_HANDLING_EMBED.equals(hint)) {
            this.sb.append("<image ");
            appendOptionalElementIDFromHint(this.sb);
            this.sb.append("preserveAspectRatio=\"none\" ");
            this.sb.append("xlink:href=\"data:image/png;base64,");
            this.sb.append(Base64.getEncoder().encode(getPNGBytes(
                    img)));
            this.sb.append("\" ");
            this.sb.append(getClipPathRef()).append(" ");
            if (!this.transform.isIdentity()) {
            	this.sb.append("transform=\"").append(getSVGTransform(
                    this.transform)).append("\" "); 
            }
            this.sb.append("x=\"").append(geomDP(x))
                    .append("\" y=\"").append(geomDP(y))
                    .append("\" ");
            this.sb.append("width=\"").append(geomDP(w)).append("\" height=\"")
                    .append(geomDP(h)).append("\"/>\n");
            return true;
        } else { // here for SVGHints.VALUE_IMAGE_HANDLING_REFERENCE
            int count = this.imageElements.size();
            String href = (String) this.hints.get(SVGHints.KEY_IMAGE_HREF);
            if (href == null) {
                href = this.filePrefix + count + this.fileSuffix;
            } else {
                // KEY_IMAGE_HREF value is for a single use...
                this.hints.put(SVGHints.KEY_IMAGE_HREF, null);
            }
            ImageElement imageElement = new ImageElement(href, img);
            this.imageElements.add(imageElement);
            // write an SVG element for the img
            this.sb.append("<image ");
            appendOptionalElementIDFromHint(this.sb);
            this.sb.append("xlink:href=\"");
            this.sb.append(href).append("\" ");
            this.sb.append(getClipPathRef()).append(" ");
            if (!this.transform.isIdentity()) {
            	this.sb.append("transform=\"").append(getSVGTransform(
                    this.transform)).append("\" ");
            }
            this.sb.append("x=\"").append(geomDP(x))
                    .append("\" y=\"").append(geomDP(y))
                    .append("\" ");
            this.sb.append("width=\"").append(geomDP(w)).append("\" height=\"")
                    .append(geomDP(h)).append("\"/>\n");
            return true;
        }
    }
@ Override public boolean drawImage ( Image img , int x , int y , int w , int h , ImageObserver observer ) { if ( img == null ) { return true ; } // the rendering hints control whether the image is embedded or // referenced... Object hint = getRenderingHint ( SVGHints . KEY_IMAGE_HANDLING ) ; if ( SVGHints . VALUE_IMAGE_HANDLING_EMBED . equals ( hint ) ) { this . sb . append ( "<image " ) ; appendOptionalElementIDFromHint ( this . sb ) ; this . sb . append ( "preserveAspectRatio=\"none\" " ) ; this . sb . append ( "xlink:href=\"data:image/png;base64," ) ; this . sb . append ( Base64 . getEncoder ( ) . encode ( getPNGBytes ( img ) ) ) ; this . sb . append ( "\" " ) ; this . sb . append ( getClipPathRef ( ) ) . append ( " " ) ; if ( ! this . transform . isIdentity ( ) ) { this . sb . append ( "transform=\"" ) . append ( getSVGTransform ( this . transform ) ) . append ( "\" " ) ; } this . sb . append ( "x=\"" ) . append ( geomDP ( x ) ) . append ( "\" y=\"" ) . append ( geomDP ( y ) ) . append ( "\" " ) ; this . sb . append ( "width=\"" ) . append ( geomDP ( w ) ) . append ( "\" height=\"" ) . append ( geomDP ( h ) ) . append ( "\"/>\n" ) ; return true ; } else { // here for SVGHints.VALUE_IMAGE_HANDLING_REFERENCE int count = this . imageElements . size ( ) ; String href = ( String ) this . hints . get ( SVGHints . KEY_IMAGE_HREF ) ; if ( href == null ) { href = this . filePrefix + count + this . fileSuffix ; } else { // KEY_IMAGE_HREF value is for a single use... this . hints . put ( SVGHints . KEY_IMAGE_HREF , null ) ; } ImageElement imageElement = new ImageElement ( href , img ) ; this . imageElements . add ( imageElement ) ; // write an SVG element for the img this . sb . append ( "<image " ) ; appendOptionalElementIDFromHint ( this . sb ) ; this . sb . append ( "xlink:href=\"" ) ; this . sb . append ( href ) . append ( "\" " ) ; this . sb . append ( getClipPathRef ( ) ) . append ( " " ) ; if ( ! this . transform . isIdentity ( ) ) { this . sb . append ( "transform=\"" ) . append ( getSVGTransform ( this . transform ) ) . append ( "\" " ) ; } this . sb . append ( "x=\"" ) . append ( geomDP ( x ) ) . append ( "\" y=\"" ) . append ( geomDP ( y ) ) . append ( "\" " ) ; this . sb . append ( "width=\"" ) . append ( geomDP ( w ) ) . append ( "\" height=\"" ) . append ( geomDP ( h ) ) . append ( "\"/>\n" ) ; return true ; } }
Draws the image into the rectangle defined by {@code (x, y, w, h)}.
Note that the {@code observer} is ignored (it is not useful in this
context).

@param img  the image ({@code null} permitted...draws nothing).
@param x  the x-coordinate.
@param y  the y-coordinate.
@param w  the width.
@param h  the height.
@param observer  ignored.

@return {@code true} if there is no more drawing to be done.
Draws the image into the rectangle defined by { @code ( x y w h ) } . Note that the { @code observer } is ignored ( it is not useful in this context ) .