Reputation: 2503
I have been struggling with this issue for some days now and I really don't know what is the problem. My CameraView class has the following code:
Camera.PictureCallback photoCallback = new Camera.PictureCallback() {
public void onPictureTaken(byte[] imageData, Camera camera) {
Intent mIntent = new Intent();
mIntent.putExtra(GeneralCodes.CREATE_NEW_ACCOUNT_PROFILE_PICTURE, imageData);
setResult(Activity.RESULT_OK, mIntent);
finish();
}
};
And then, my Activity that receives this result:
ImageView i = (ImageView) findViewById(R.id.createAccounProfileImage);
Bitmap yourSelectedImage = FileUtilities.createBitmapBasedOnByteImage(data.getByteArrayExtra(GeneralCodes.CREATE_NEW_ACCOUNT_PROFILE_PICTURE), getResources().getDisplayMetrics().density);
finalImage=yourSelectedImage;
i.setImageBitmap(BitmapUtils.getRoundedCornerBitmap(finalImage, Math.min(finalImage.getWidth(), finalImage.getHeight()), true));
The only thing the method FileUtilities.createBitmapBasedOnByteImage is really doing is just a BitmapFactory.decodeByteArray() call.
Then, my next step is sending this Bitmap to my server:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
if(finalImage!=null)finalImage.compress(Bitmap.CompressFormat.JPEG, 0, baos);
byte[] data = baos.toByteArray();
pairs.add(new BasicNameValuePair("PROFILE_PIC_DATA", Base64.encodeToString(data, Base64.DEFAULT)));
The information is sent to my server and image is persisted in the CLOB. When my next acticity retrieves this data:
bitmap = BitmapFactory.decodeStream(createInputStream(Base64.decode(obj.getString("photo_image"), Base64.DEFAULT)));
The quality is completely messed up. Like it was taken by a 0.3mpx camera. I am using Samsung Galaxy Nexus, so I believe that my screen is contributing to make it worse. The images have around 2.7kb size in the CLOB... so I am guessing data is being lost when sending to my server... Am not really sure.
Anyone ever seen this?
THanks, Felipe
Upvotes: 0
Views: 886