您好我需要java.awt.image.BufferedImage中的bufferedImage对象。如何在codenameone中定义这样的东西?
更新: 这是一个我想要移植到codenameone的课程
package org.rajman.map.awt;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.imageio.ImageIO;
import org.rajman.core.graphics.Bitmap;
class AwtBitmap implements Bitmap {
final BufferedImage bufferedImage;
AwtBitmap(InputStream inputStream) throws IOException {
this.bufferedImage = ImageIO.read(inputStream);
if (this.bufferedImage == null) {
throw new IOException("ImageIO filed to read inputStream");
}
}
AwtBitmap(int width, int height) {
this.bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
}
@Override
public void compress(OutputStream outputStream) throws IOException {
ImageIO.write(this.bufferedImage, "png", outputStream);
}
@Override
public void decrementRefCount() {
// no-op
}
@Override
public int getHeight() {
return this.bufferedImage.getHeight();
}
@Override
public int getWidth() {
return this.bufferedImage.getWidth();
}
@Override
public void incrementRefCount() {
// no-op
}
@Override
public void scaleTo(int width, int height) {
// TODO implement
}
@Override
public void setBackgroundColor(int color) {
// TODO implement
}
}
答案 0 :(得分:1)
Image.create(width,height,argbBackground)
将创建您可以修改的图像。您可以使用该类中的许多静态方法从流或字节数组加载图像,我们有自己的ImageIO
API来保存图像。