Thursday, April 25, 2013

Re: [android-developers]

i try this, but i don't know it will help or not 

ImageView img;
 Bitmap decodedByte,bit,bmp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bit = BitmapFactory.decodeFile("/sdcard/images10.jpeg");
// ByteArrayOutputStream bos = new ByteArrayOutputStream();
//    bit.compress(CompressFormat.PNG, 0, bos);
ByteArrayOutputStream byteArrayBitmapStream = new ByteArrayOutputStream();
bit.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayBitmapStream);
byte[] decodedString = byteArrayBitmapStream.toByteArray();
   System.out.println("ssssssssssssss"+decodedString);
   decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
   
   System.out.println("aaaaaaaaaaaaaaaaaaaaaaa"+decodedString.length);
    bmp = Bitmap.createBitmap(decodedByte);
OutputStream stream = null;
try {
stream = new FileOutputStream("/sdcard/test.jpg");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
bmp.compress(CompressFormat.JPEG, 100, stream);
 //  map.put(IMAGE,decodedByte);
   //System.out.println("bbbbbbbbb"+decodedByte.createBitmap(decodedByte));
 //  bit = Bitmap.createScaledBitmap(decodedByte, 100, 100, true);//ateBitmap(decodedByte);

if (decodedByte != null) {
img = (ImageView)findViewById(R.id.img);
/*Bitmap bmp = Bitmap.createBitmap(decodedByte);
OutputStream stream = null;
try {
stream = new FileOutputStream("/sdcard/test.jpg");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
bmp.compress(CompressFormat.JPEG, 100, stream);*/
img.setImageURI(Uri.fromFile(new File("/sdcard/test.jpg")));
   System.out.println("bitmap is not null");
} else {
   System.out.println("bitmap is null");
}
}


On Thu, Apr 25, 2013 at 12:24 AM, asma rezgui <asmarezgui88@gmail.com> wrote:
in the logcat i have also seen this message , i didn't understand where is the cause
04-24 17:48:54.370: I/dalvikvm-heap(1121): Grow heap (frag case) to 8.921MB for 448446-byte allocation


2013/4/24 asma rezgui <asmarezgui88@gmail.com>
unfortunately i didn't forget it . Thanks


2013/4/24 bob <bob@coolfone.comze.com>
It sounds like this returned null:

findViewById(R.id.imageview);

Maybe you forgot to do a setContentView?

Thanks.


On Wednesday, April 24, 2013 12:50:04 PM UTC-5, ASMA wrote:
hello, i have followed the steps in this tutorial  and the encoding is done successfully in the server side. the problem now in the decoding
in the client side
this is my code:
byte[] decodedString = Base64.decode(image, Base64.DEFAULT);
    System.out.println("ssssssssssssss"+decodedString);
    decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
   
    System.out.println("aaaaaaaaaaaaaaaaaaaaaaa"+decodedString.length);
    map.put(IMAGE,decodedByte);
    System.out.println("bbbbbbbbb"+decodedByte);


if (decodedByte != null) {
    img = (ImageView) findViewById(R.id.imageview);
  img.setImageBitmap(decodedByte);
    System.out.println("bitmap is not null");
} else {
    System.out.println("bitmap is null");
}

in the logcat i found null pointer exception in this line     (img.setImageBitmap(decodedByte);)
and no message is shown. does anyone know the reason !!


2013/4/24 asma rezgui <asmare...@gmail.com>
thanks Manish Shrivas


2013/4/24 Manish Srivas <manish...@adisoftin.com>


On Wed, Apr 24, 2013 at 7:35 PM, asma rezgui <asmare...@gmail.com> wrote:
hii , does anyone know how to solve my problem, i have to convert an image from byte[] to base64 to read it in json file and convert it back from base64 to byte and from byte[] to bitmap to display it in imageview
in converting it to bitmap , i have this error: --- SkImageDecoder::Factory returned null  and the byte[]is shown as below [B@4059e1a0
i don t understand where is the problem and if there is the correct form of bitmap or not :(
pleaaase i need help


--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-d...@googlegroups.com

To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--

Thanks & Regards,
--------------------------
Manish Shrivas
ADI Soft Tech (P)  Ltd.
54, Anand Nagar, Near Devi Ahilya Hospital,
Chitawad Road ,
INDORE
Mob no. 9907631333
------------------------
manish...@adisoftin.com
http://www.adisoftin.com/

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-d...@googlegroups.com

To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--

Thanks & Regards,
--------------------------
Manish Shrivas
ADI Soft Tech (P)  Ltd.
54, Anand Nagar, Near Devi Ahilya Hospital,
Chitawad Road ,
INDORE
Mob no. 9907631333
------------------------
manish.srivas@adisoftin.com
http://www.adisoftin.com/

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate