Some operation processing of Android image

Source: Internet
Author: User

1, Android Image transparency processing: 0-100 To set the transparency from: http://blog.csdn.net/yanzi1225627/article/details/29661935

Way One

  Public StaticBitmap Gettransparentbitmap (Bitmap sourceimg,intNumber ) {        int[] Argb =New int[Sourceimg.getwidth () *sourceimg.getheight ()]; Sourceimg.getpixels (ARGB,0, Sourceimg.getwidth (), 0, 0, sourceimg. GetWidth (), Sourceimg.getheight ());//get the ARGB value of the picture Number= number * 255/100;  for(inti = 0; i < argb.length; i++) {Argb[i]= (number << 24) | (Argb[i] & 0X00FFFFFF); } sourceimg=Bitmap.createbitmap (ARGB, Sourceimg.getwidth (), sourceimg. GetHeight (), Bitmap.Config.ARGB_8888); returnsourceimg; }
View Code

Way two:

classDrawcanvasextendsView { PublicDrawcanvas (Context context) {Super(context); } @Overrideprotected voidOnDraw (canvas canvas) {Super. OnDraw (canvas); //get the bitmap of resource picturesBitmap Vbitmap = Bitmapfactory.decoderesource ( This. Getresources (), R.drawable.icon            ); //Creating Paint ObjectsPaint Vpaint =NewPaint ();   Vpaint. SetStyle (Paint.Style.STROKE); //HollowVpaint. Setalpha (75);//   Canvas.drawbitmap (Vbitmap,50, 100,NULL);//No TransparencyCanvas.drawbitmap (Vbitmap, vpaint);//have transparent    }  }  
View Code

Some operation processing of Android 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.