I have a basic Hashmap code that wont work for some reason.
ConcurrentHashMap<Bitmap, byte[]> pixels = new ConcurrentHashMap<Bitmap, byte[]>();
it key is bitmap, and the value are its bytes that I get using this code:
public byte[] getPixels(Bitmap bmp) {
int bytes = bmp.getRowBytes() * bmp.getHeight();
buffer = ByteBuffer.allocateDirect(bytes);
bmp.copyPixelsToBuffer(buffer);
buffer.clear();
return buffer.array();
}
In the hashmap for all the bitmaps I have I put:
pixels.put(bitmap1, getPixels(b));
And when I want to get the value (bytes) back I do:
byte[] pixelData = pixels.get(bitmap1);
and for some odd reason its always null!, why? I tried on different bitmaps, they all return null, and it is the same bitmap..