android-so speichern Sie eine bitmap - buggy-code

Ich versuche zu serialisieren einer Klasse in die ich eine bitmap-variable. Hier ist der code, dass ist ein bisschen Arbeit.... Ich brauche Hilfe, um herauszufinden, was ist immer noch falsch.....

private Bitmap myVideoScreenshotBm;

private void writeObject(ObjectOutputStream out) throws IOException{

    out.writeInt(myVideoScreenshotBm.getRowBytes());
    out.writeInt(myVideoScreenshotBm.getHeight());
    out.writeInt(myVideoScreenshotBm.getWidth());

    int bmSize = myVideoScreenshotBm.getHeight() * myVideoScreenshotBm.getRowBytes();
    ByteBuffer dst= ByteBuffer.allocate(bmSize);

    myVideoScreenshotBm.copyPixelsToBuffer(dst);

    byte[] bytesar=new byte[bmSize];
    dst.position(0);
    dst.get(bytesar);

    out.write(bytesar);


}

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException{

    int nbRowBytes=in.readInt();
    int height=in.readInt();
    int width=in.readInt();
    //
    int bmSize = nbRowBytes * height;
    byte[] toread= new byte[bmSize];

    in.read(toread, 0, toread.length);
    ByteBuffer dst= ByteBuffer.allocate(bmSize);
    dst.put(toread);
    dst.position(0);
    myVideoScreenshotBm=Bitmap.createBitmap(width, height, Bitmap.Config.ALPHA_8);
    myVideoScreenshotBm.copyPixelsFromBuffer(dst);

}

Ich bin nicht immer ein Fehler sein, aber die bitmap Im immer falsch sind... auch, ich weiß nicht, wie zu wissen, welche Bitmap.Config-flag eignet sich... wie zu wissen ?

Hilfe ?

InformationsquelleAutor Fabien | 2010-09-02
Schreibe einen Kommentar