Android: Getting ARGB from a JPEG

With J2ME, “Opening” a JPEG into an ARGB array may look like:

Image jpegImage = Image.createImage( jpegByteArray, 0, arrayLength );
if (jpegImage == null) {
//ERROR
} else {
jpegImage.getRGB (argbArray, 0, jpegWidth, 0, 0, jpegWidth, jpegHeight);
}

Since Android does not have an Image class, the following code will produce the same results (Please note the similar API):

Bitmap jpegBitmap = BitmapFactory.decodeByteArray(jpegByteArray, 0, arrayLength);
if (jpegBitmap == null) {
//ERROR
} else {
decodedBitmap.getPixels(argbArray, 0, jpegWidth, 0, 0, jpegWidth, jpegHeight);
}

Not that different, isn’t it?

(And I know I need a better blockquote for code… working on it)

Tags: , ,

Leave a Reply