Java Picture set fillet (set border, narration)

Source: Internet
Author: User

/*** Picture setting fillet *@paramSrcimage *@paramradius *@paramBorder *@parampadding *@return     * @throwsIOException*/     Public StaticBufferedImage Setradius (BufferedImage srcimage,intRadiusintBorderintPaddingthrowsioexception{intwidth =srcimage.getwidth (); intHeight =srcimage.getheight (); intCanvaswidth = width + padding * 2; intCanvasheight = height + padding * 2; BufferedImage Image=Newbufferedimage (Canvaswidth, Canvasheight, Bufferedimage.type_int_argb); Graphics2D GS=Image.creategraphics ();        Gs.setcomposite (ALPHACOMPOSITE.SRC);        Gs.setrenderinghint (renderinghints.key_antialiasing, renderinghints.value_antialias_on);        Gs.setcolor (Color.White); Gs.fill (NewRoundrectangle2d.float (0, 0, Canvaswidth, canvasheight, radius, radius));        Gs.setcomposite (Alphacomposite.srcatop); Gs.drawimage (SetClip (srcimage, radius), padding, padding,NULL); if(Border!=0) {gs.setcolor (Color.gray); Gs.setstroke (NewBasicstroke (border)); Gs.drawroundrect (padding, padding, canvaswidth-2 * padding, canvasHeight-2 *padding, radius, radius);        } gs.dispose (); returnimage; }        /*** Picture setting fillet *@paramSrcimage *@return     * @throwsIOException*/     Public StaticBufferedImage Setradius (BufferedImage srcimage)throwsioexception{intRadius = (srcimage.getwidth () + srcimage.getheight ())/6; returnSetradius (Srcimage, RADIUS, 2, 5); }        /*** Picture Cut fillet *@paramSrcimage *@paramradius *@return     */     Public StaticBufferedImage SetClip (BufferedImage srcimage,intradius) {        intwidth =srcimage.getwidth (); intHeight =srcimage.getheight (); BufferedImage Image=Newbufferedimage (width, height, bufferedimage.type_int_argb); Graphics2D GS=Image.creategraphics ();        Gs.setrenderinghint (renderinghints.key_antialiasing, renderinghints.value_antialias_on); Gs.setclip (NewRoundrectangle2d.double (0, 0, width, height, radius, radius)); Gs.drawimage (Srcimage,0, 0,NULL);        Gs.dispose (); returnimage; }

Java Picture set fillet (set border, narration)

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.