繁体   English   中英

CodenameOne中java.awt.image.BufferedImage的替代方案是什么

[英]what is alternative of java.awt.image.BufferedImage in codenameone

嗨,我需要类似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
}

}

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM