Skip to main content

image view  convert  to Bitmap and bitmap convert to byte[]image

image view  convert  to Bitmap

BitmapDrawable bitmapDrawable= (BitmapDrawable) imageView.getDrawable();
Bitmap bitmap=bitmapDrawable.getBitmap();

Bitmap convert to a byte array(byte[]image)

private byte[] imagaetobyte(Bitmap bitmap) {

ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG,90,byteArrayOutputStream);
byte[]image=byteArrayOutputStream.toByteArray();
return image;


}

byte[] convert to bitmap set in imageview 
Bitmap bitmap= BitmapFactory.decodeByteArray(reconizeimage,0,reconizeimage.length);
holder.imageview.setImageBitmap(bitmap);




Comments

Popular posts from this blog

 var val  deference in kotlin  fun main () { var Android_Programing_language : String = "java" println ( "android official programing language: " + Android_Programing_language ) Android_Programing_language = "Kotline" println ( "2019 google announced android official programing language: " + Android_Programing_language ) val Android_MultiPlatform_language : String = "Dart" println ( "multiple device run : " + Android_MultiPlatform_language ) /* Android_MultiPlatform_language="" /* note: var--------------valu changable note: val--------------valu not changable (final) */ */ }
 Firebase Cloud Messaging With  push notification with Image  public class ImageDownload extends AsyncTask < String , Void , Bitmap >{ @Override protected Bitmap doInBackground ( String ... strings ) { InputStream inputStream ; try { URL url = new URL( strings [ 0 ]) ; try { HttpURLConnection connection = ( HttpURLConnection ) url .openConnection() ; connection .connect() ; inputStream = connection .getInputStream() ; return BitmapFactory . decodeStream ( inputStream ) ; } catch ( IOException e ) { e .printStackTrace() ; } } catch ( MalformedURLException e ) { e .printStackTrace() ; } return null; } @Override protected void onPostExecute ( Bitmap bitmap ) { ShowNotification( bitmap ) ; } }
 Android Notification show  public static void shownotification ( Context context , int id , String title , String Content , Intent intent ) { PendingIntent pendingIntent= null; if ( intent != null ) { pendingIntent= PendingIntent . getActivities ( context , id , new Intent[]{ intent } , PendingIntent . FLAG_UPDATE_CURRENT ) ; String NOTIIFCATION_CHANNEL_ID = "UClone android" ; NotificationManager notificationManager = ( NotificationManager ) context .getSystemService( Context . NOTIFICATION_SERVICE ) ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . O ) { NotificationChannel notificationChannel = new NotificationChannel( NOTIIFCATION_CHANNEL_ID , "" , NotificationManager . IMPORTANCE_HIGH ) ; notificationChannel .setDescription( "" ) ; notificationChannel .enableLights( true ) ; notificationChannel .setLightColor( Color . RED ) ; no...