return imageData;
}
public static ImageData fillImage(Image image, double cw,double ch) {
Canvas canvasTmp = Canvas.createIfSupported();
Context2d context = canvasTmp.getContext2d();
//double ch = (image.getHeight() * scaleToRatioh) + 100;
//double cw = (image.getWidth() * scaleToRatiow) + 100;
canvasTmp.setCoordinateSpaceHeight((int) ch);
canvasTmp.setCoordinateSpaceWidth((int) cw);
ImageElement imageElement = ImageElement.as(image.getElement());
// s = source
// d = destination
double sx = 0;
double sy = 0;
double sw = imageElement.getWidth();
double sh = imageElement.getHeight();
double dx = 0;
double dy = 0;
double dw = imageElement.getWidth();
double dh = imageElement.getHeight();
// tell it to scale image
//context.scale(scaleToRatioh, scaleToRatiow);
// draw image to canvas
context.drawImage(imageElement, sx, sy, sw, sh, dx, dy, cw, ch);
// get image data
//double w = dw * scaleToRatioh;
//double h = dh * scaleToRatiow;
ImageData imageData = context.getImageData(0, 0, cw, ch);
return imageData;
}