Android implements thumbnail image for video image

Source: Internet
Author: User

Taking thumbnails is not the same as zooming a picture.

Zooming the picture is done without distortion in the case of scale processing, and is smoothed.

Thumbnails are otherwise, allowing distortion, only to remove the outline of the image.

Save Bitmap Pictures

Private  void Savebitmap (Bitmap bm,string picname) {log.e (TAG, "Save Picture"); String Icon_dir=mmedialist.get (Mmedialist.size ()-1). Geticonpath (). Replace ("/", "__");//  string icon_dir= Picname.replace ("/", "__"); File dir = new file (Environment.getexternalstoragedirectory (). toString () + "/movdo/clip", Icon_dir); if (!dir.exists ()) if (!dir.mkdir ()) LOG.E (tag, "t create dir"), ELSELOG.I (tag, "DIR is created");p icname=picname.replace (". mp4", ". jpg "); File F = new file (Dir.getabsolutepath (), "0.jpg"), if (F.exists ()) {F.delete ();} try {fileoutputstream out = new FileOutputStream (f); bm.compress (Bitmap.CompressFormat.PNG, N, out); Out.flush (); O Ut.close (); LOG.I (TAG, "saved");} catch (FileNotFoundException e) {//Todo auto-generated catch Blocke.printstacktrace ();} catch (IOException e) {//Todo Au To-generated catch Blocke.printstacktrace ();}}

Take thumbnails of pictures

Public Bitmap getimagethumbnail (String filename,bitmap bmp,int width,int height) {Bitmap bitmap= Thumbnailutils.extractthumbnail (BMP, +);   Savebitmap (bitmap,filename); return bitmap;  }

Take thumbnails of videos

Private Bitmap Getvideothumbnail (String videopath, int width, int height) {Bitmap Bitmap = Null;bitmap = thumbnailutils.cr Eatevideothumbnail (Videopath, thumbnails.mini_kind); bitmap = Thumbnailutils.extractthumbnail (bitmap, width, height, Thumbnailutils.options_recycle_input); String Filename=new string (); Savebitmap (Bitmap,mmedialist.get (Mmedialist.size ()-1). Getitemname ()); return bitmap;}

Parse into bitmap based on path

Bitmap thumb = bitmapfactory.decodefile (filepath); Getimagethumbnail (filename,thumb,300,300);

Android implements thumbnail image for video image

Related Article

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.