Frage

Ich mag einen Byte-Array aus einem JPEG-Bild in meinem res / ziehbar Datei gespeichert bekommen?

Wer weiß, wie das bitte tun?

War es hilfreich?

Lösung

Get a Bitmap decodeResource(android.content.res.Resources, int) Dann entweder komprimiert es ByteArrayOutputStream () oder copyPixelsToBuffer und erhalten Sie Ihre Array aus dem Puffer. http://developer.android.com/reference/android/graphics/Bitmap.html

Andere Tipps

    Drawable drawable;

    Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
    byte[] bitmapdata = stream.toByteArray();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
mPhoto.compress(Bitmap.CompressFormat.JPEG /* FileType */,
                        100 /* Ratio */, stream);

HTH!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top