我在以下代码中的 android java 代码中遇到了 nullpointerexception。这是在 AndroidGraphics.java 中。
public void drawPixmap(Pixmap pixmap, int x, int y) {
canvas.drawBitmap(((AndroidPixmap)pixmap).bitmap, x, y, null);
}
AndroidPixmap.java 在这里:
package com.badlogic.androidgames.framework.impl;
import android.graphics.Bitmap;
import com.badlogic.androidgames.framework.Graphics.PixmapFormat;
import com.badlogic.androidgames.framework.Pixmap;
public class AndroidPixmap implements Pixmap{
Bitmap bitmap;
PixmapFormat format;
public AndroidPixmap(Bitmap bitmap, PixmapFormat format){
this.bitmap = bitmap;
this.format = format;
}
@Override
public int getWidth(){
return bitmap.getWidth();
}
@Override
public int getHeight(){
return bitmap.getHeight();
}
@Override
public PixmapFormat getFormat(){
return format;
}
@Override
public void dispose(){
bitmap.recycle();
}
}
选角有问题吗?任何帮助都会很棒!
编辑:这是像素图类:
package com.badlogic.androidgames.framework;
import com.badlogic.androidgames.framework.Graphics.PixmapFormat;
public interface Pixmap {
public int getWidth();
public int getHeight();
public PixmapFormat getFormat();
public void dispose();
}