Android Bitmap to Base64 String

use following method to convert bitmap to byte array: ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream .toByteArray(); to encode base64 from byte array use following method String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT);

“Bitmap too large to be uploaded into a texture”

This isn’t a direct answer to the question (loading images >2048), but a possible solution for anyone experiencing the error. In my case, the image was smaller than 2048 in both dimensions (1280×727 to be exact) and the issue was specifically experienced on a Galaxy Nexus. The image was in the drawable folder and none … Read more

How to get Bitmap from an Uri?

Here’s the correct way of doing it: protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { Uri imageUri = data.getData(); Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), imageUri); } } If you need to load very large images, the following code will load it in in tiles (avoiding large memory … Read more

Saving and Reading Bitmaps/Images from Internal memory in Android

Use the below code to save the image to internal directory. private String saveToInternalStorage(Bitmap bitmapImage){ ContextWrapper cw = new ContextWrapper(getApplicationContext()); // path to /data/data/yourapp/app_data/imageDir File directory = cw.getDir(“imageDir”, Context.MODE_PRIVATE); // Create imageDir File mypath=new File(directory,”profile.jpg”); FileOutputStream fos = null; try { fos = new FileOutputStream(mypath); // Use the compress method on the BitMap object to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)