[英]ClassNotFoundException for java.awt.image.BufferedImage on Android
[英]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.