Android: Check if bitmap has aspect ratio 4:3 -
i retrieving images gallery using content resolver
final string[] columns = {mediastore.images.media.data, mediastore.images.media._id}; final string orderby = mediastore.images.media._id; cursor imagecursor = context.getcontentresolver().query( mediastore.images.media.external_content_uri, columns, null, null, orderby); int image_column_index = imagecursor .getcolumnindex(mediastore.images.media._id); count = imagecursor.getcount(); imagelist = new arraylist<bitmap>(); (int = 0; < count; i++) { imagecursor.movetoposition(i); int id = imagecursor.getint(image_column_index); bitmap b = mediastore.images.thumbnails.getthumbnail( context.getcontentresolver(), id, mediastore.images.thumbnails.micro_kind, null); imagelist.add(b); }
how check if bitmaps aspect ratio 4:3 , add arraylist?
you need check bitmap's width , height.
float ratio = 4 / 3; float epsilon = 0.00001f; float ratio = (float)bitmap.getwidth() / bitmap.getheight(); if (math.abs(ratio - ratio) < epsilon) { list.add(bitmap); }
Comments
Post a Comment