Confusing results from ThumbnailUtils.createImageThumbnail

Published

I am trying to use ThumbnailUtils.createImageThumbnail but I’m getting confusing results. My code:

String pathAAAA = "/sdcard/000_kmg/bbbb.jpg";

File file = new File( pathAAAA );
Size size = new Size( 100, 300 );
Drawable drawable = Drawable.createFromPath( pathAAAA );

try
{   Bitmap bitmap = ThumbnailUtils.createImageThumbnail( file, size, null );
    Log.e( "###", "    size = " + size );
    Log.e( "###", "  bitmap = " + bitmap.getWidth( ) + " x " + bitmap.getHeight( ));
    Log.e( "###", "drawable = " + drawable.getIntrinsicWidth( ) + " x " + drawable.getIntrinsicHeight( ));
}
catch( IOException e )
{   Log.e( "###", "error", e );
}

The output:

    size = 100 x 300
  bitmap = 128 x 57
drawable = 745 x 333

Other tests also show that the createImageThumbnail seems to totally ignore the "size" parameter. I realise that the image perspective is being preserved but one of the dimensions should be (approximately) equal to "size".

Source: Android Questions

Published
Categorized as android

Answers

Leave a Reply

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq