codeameone中java.awt.image. buffereimage的替代方案是什么?



嗨,我需要类似于java.awt.image.BufferedImage对象。怎么可能在代码中定义这样的东西?

更新:这是一个我想移植到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
}
}

Image.create(width,height,argbBackground)将创建一个您可以修改的图像。您可以使用该类中的许多静态方法从流或字节数组加载图像,并且我们有自己的ImageIO API来保存图像。

相关内容

  • 没有找到相关文章