viewing paste Unknown #6748 | Java

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
 @Override
                public void onBinaryMessage(byte[] image)
                {
                
                
                Bitmap receivedImage=BitmapFactory.decodeByteArray(image,0,image.length);
                    float scale=1;
                
                int width  = receivedImage.getWidth();
                    int height = receivedImage.getHeight();
                    float scaleHeight = (float)height/(float)200;
                    float scaleWidth  = (float)width /(float)200;
                    if (scaleWidth < scaleHeight) 
                        {scale = scaleHeight;}
                    else
                    {
                        scale = scaleWidth;
                    }
                    
                   Bitmap bitmaped = Bitmap.createScaledBitmap(receivedImage, (int)(width/scale), (int)(height/scale), true);
                addImage(new Message(bitmaped,false,false));
                
                }
 
 
public void addImage(Message path)
            
            {
                
                
                
                messages.add(path);
                adapter.notifyDataSetChanged();
                getListView().setSelection(messages.size()-1);
                v=(Vibrator) getSystemService(MainActivity.VIBRATOR_SERVICE);
                v.vibrate(200);
                
                
            }       
 
 
 
 
  listView1.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    Log.v("Module Item Trigger", "Module item was triggered");
                   // String c =  parent.getAdapter().getItem(position).toString();
                   
                    String s;
                   // ImageView im=  (ImageView) view.findViewById(R.id.message_image); 
                    // s = ((TextView) view.findViewById(R.id.message_text)).getText().toString();
                    Bitmap bmp = ((ImageView) view.findViewById(R.id.message_image)).getDrawingCache();
                   
                    ByteArrayOutputStream streamline = new ByteArrayOutputStream();
                       bmp.compress(Bitmap.CompressFormat.JPEG, 100, streamline);
                       
                       checkim=streamline.toByteArray();
                       
                    Intent myintent=new Intent(MainActivity.this,ImageFull.class);
                   Bundle bundle = new Bundle();
                   bundle.putByteArray("image", checkim);
                   myintent.putExtras(bundle);
                   startActivity(myintent);
                   
                   //TextView clickedView = (TextView) view;
           //Toast.makeText(MainActivity.this,"Byte array"+checkim.toString() , Toast.LENGTH_SHORT).show();   
                   
                  // Toast.makeText(getApplicationContext(),"this is ==>"+s,Toast.LENGTH_SHORT).show();
                }
            });
        
Viewed 781 times, submitted by Guest.