BufferedImage scaledImg = powerOfTwoATOp.filter((BufferedImage)ri, null);
powerOfTwoATOp.filter(bi, scaledImg);
    void evaluateExtNonPowerOfTwo(int ext) {        // Only need to enforce for Raster or Background.        if(!enforceNonPowerOfTwoSupport) {            return;        }                // If npotSupported is false, a copy power of two image has been created        // so we don't have to check again.        if(!npotSupported) {            return;        }        if (imageData == null && !isByReference()) {            return;        }                if((ext & Canvas3D.TEXTURE_NON_POWER_OF_TWO) != 0) {            return;        }        // NPOT is unsupported, set flag to false.        npotSupported = false;        int npotWidth;        int npotHeight;                // Always scale up if image size is smaller 512*512.        if((width * height) < IMAGE_SIZE_512X512) {            npotWidth = getCeilPowerOf2(width);            npotHeight = getCeilPowerOf2(height);        } else {            npotWidth = getClosestPowerOf2(width);            npotHeight = getClosestPowerOf2(height);        }                // System.err.println("width " + width + " height " + height + " npotWidth " + npotWidth + " npotHeight " + npotHeight);        float xScale = (float)npotWidth/(float)width;        float yScale = (float)npotHeight/(float)height;                // scale if scales aren't 1.0        if (!(xScale == 1.0f && yScale == 1.0f)) {            RenderedImage ri = null;                        if (imageData == null) {                // This is a byRef, support format and is a RenderedImage case.                // See ImageComponent2DRetained.set(RenderedImage image)                ri = (RenderedImage) getRefImage(0);                if(!(ri instanceof BufferedImage)) {                    // Create a buffered image from renderImage                    ColorModel cm = ri.getColorModel();                    WritableRaster wRaster = ri.copyData(null);                    ri = new BufferedImage(cm,                            wRaster,                            cm.isAlphaPremultiplied()                            ,null);                                        // Create image data object with buffer for image. */                    imageData = createRenderedImageDataObject(null);                    copySupportedImageToImageData(ri, 0, imageData);                }            }                        assert imageData != null;            ri = imageData.createBufferedImage(0);                        AffineTransform at = AffineTransform.getScaleInstance(xScale,                    yScale);                        powerOfTwoATOp = new AffineTransformOp(at,                    AffineTransformOp.TYPE_BILINEAR);                        BufferedImage scaledImg = powerOfTwoATOp.filter((BufferedImage)ri, null);            imageDataPowerOfTwo = createRenderedImageDataObject(null, npotWidth, npotHeight);            // Since ri is created from imageData, it's imageType is supported.            copySupportedImageToImageData(scaledImg, 0, imageDataPowerOfTwo);                    } else {            imageDataPowerOfTwo = null;        }    }