Today, I wanted to create an image thumbnail in Android. There is no easyway out. So I wrote the code by my self.
byte[] imageData = null;
try
{
final int THUMBNAIL_SIZE = 64;
FileInputStream fis = new FileInputStream(fileName);
Bitmap imageBitmap = BitmapFactory.decodeStream(fis);
Float width = new Float(imageBitmap.getWidth());
Float height = new Float(imageBitmap.getHeight());
Float ratio = width/height;
imageBitmap = Bitmap.createScaledBitmap(imageBitmap, (int)(THUMBNAIL_SIZE * ratio), THUMBNAIL_SIZE, false);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
imageBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
imageData = baos.toByteArray();
}
catch(Exception ex) {
}
Aruna can you ever do Encryption decryption in android . I want do encpt decpt a file (PDF,doc,etc) through code ................can you help me
ReplyDeleteHi. I have not seen any file encryption algorithms built into Android yet. So I think you have to use your own encryption or you can read the files in bytes and pass it to a algorithm function which does the job for you.
ReplyDeleteAlso try Java 256bit AES Encryption library external lib which does the encryption for your.
take a look at http://stackoverflow.com/questions/992019/java-256bit-aes-encryption
close the streams after use? no?
ReplyDeleteI have an array of images and I want to create thumbnails of all these images. Will this peice of code work for me and Kindly tell me what is the format of "fileName"
ReplyDelete