The image needs to be processed so that it can be properly displayed in the picture. After finding some information, processing is also simpler: * * Andychen (andy.chen.sh@gmail.com) * **/public static Icon Getfixedboundicon (String filePath, int h eight, int width) throws exception{double ratio=0.0;//zoom ratio file F = new file (FilePath); if (! F.isfile ()) throw new Exception (f+ "is not-image file error in getfixedboundicon!"); ICON ret = new ImageIcon (FilePath); BufferedImage Bi = Imageio.read (F); if ((Bi.getheight () >height) | | (Bi.getwidth () >width)) {if (Bi.getheight () >bi.getwidth ()) {Ratio = (new Integer (height)). Doublevalue ()/bi.getheight ();} else {Ratio = (new Integer (width)). Doublevalue ()/bi.getwidth (); The file ThF = new File (filepath+ "_" +height + "_" +width); Image itemp = bi.getscaledinstance (Width,height,bi.scale_smooth); Affinetransformop op = new Affinetransformop (Affinetransform.getscaleinstance (Ratio, Ratio), NULL); itemp = Op.filter (Bi, NULL); try {imageio.write (bufferedimage) itemp, "JPG", ThF); ret = new ImageIcon (Thf.getpath ());} catch (Exception ex) {}} RetuRN ret; }
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