我正在尝试使用双线性插值来调整图像的大小,但到目前为止,我只能进行以下操作,我不知道下一步该怎么做。
我知道我需要为所有新像素确定颜色,但是我不知道如何将新像素设置为其新颜色
public WritableImage resizeImage(WritableImage oldImage, float scaleX, float scaleY) {
//Calculate the new width and height
int newWidth = (int) (oldImage.getWidth() * scaleX);
int newHeight = (int) (oldImage.getHeight() * scaleY);
//Create a new image with the new width and height
WritableImage newImage = new WritableImage(newWidth, newHeight);
//create a pixel reader
PixelWriter image_writer = newImage.getPixelWriter();
for (int j = 0; j < newHeight; ++j) {
for (int i = 0; i < newWidth; ++i) {
float x = (float) (j * (newWidth/oldImage.getWidth()));
float y = (float) (i * (newHeight/oldImage.getHeight()));
}
}
return newImage;
}