Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.graphics.Bitmap;

import java.nio.ByteBuffer;

public class Main {
    public static byte[] getBytes(Bitmap bitmap) {
        int byteCount = bitmap.getByteCount();
        ByteBuffer buffer = ByteBuffer.allocate(byteCount);
        bitmap.copyPixelsToBuffer(buffer);
        buffer.rewind();

        byte[] data = new byte[byteCount];
        buffer.get(data);
        return data;
    }
}