Android pictures with thumbnails

Source: Internet
Author: User

/** * The original scale of the picture file is abbreviated and not exceeding the maximum width, height * @param path: Picture file * @param requestw: Max width after thumbnail * @param requesth: max height after thumbnail * @return thumbnail image pair Like */public static Bitmap getthumbnailbyreq (String path,int requestw, int requesth) {bitmapfactory.options Options = new Opt Ions ();//Only the source graph size information is parsed, so the source graph boundary information is only loaded into memory, not the full source graph, thus saving memory Options.injustdecodebounds = true; Bitmapfactory.decodefile (path, options); int outw = options.outwidth;//source map width int outh = options.outheight;//source Height// Set the thumbnail multiplier if (outw > REQUESTW | | outh > REQUESTH) {int radiow = Math.Round ((float) outw/requestw); int radioh = Math.Round (( float) outh/requesth); options.insamplesize = Radiow > Radioh? Radiow:radioh;} Else{options.insamplesize = 1;} Need to parse out the correct picture object, so the image of the thumbnail after the complete addition of memory Options.injustdecodebounds = false; Bitmap Bitmap = bitmapfactory.decodefile (path, options); return Bitmap;}

Android pictures with thumbnails

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.