com.hmw.picmark; java.awt.image.affinetransformop; ข้อความลายน้ำ, ซูม, อาหารเสริมสีขาว, ฯลฯ ฯลฯ ฯลฯ @author Carl HE*/Public Final Class ImageUtils {/** รูปแบบรูปภาพ: JPG*/ส่วนตัวสตริงสุดท้ายคงที่ PICTRUE_FORMATE_JPG = "JPG"; * เพิ่มภาพลายน้ำ * @Param TargetImg เส้นทางรูปภาพเป้าหมายเช่น: C: //MypicTrue//1.jpg * @param Watermg เส้นทางลายน้ำเช่น: C: //MypicTrue//logo.png * @param x ระยะทางภาพลายน้ำเป้าหมายการชดเชยทางด้านซ้ายของภาพถ้า x <0, ตรงกลาง* @param y ระยะห่างของลายน้ำ ความโปร่งใส (0.0- -1.0, 0.0 มีความโปร่งใสอย่างสมบูรณ์, 1.0 เป็นทึบแสงอย่างสมบูรณ์) */สาธารณะสุดท้ายของสาธารณะ pressimage คง (ไฟล์); (ภาพ, 0, 0, ความกว้าง, ความสูง, null); .SetComposite (alphacomposite.getInstance (alphacomposition.src_atop, alpha)); x = widthdiff;} if (y <0) {y = heightdiff / 2;} อื่นถ้า (y> heightdiff) {y = heightdiff;} g.drawimage (waterimage, x, y, width_1, height_1, null); ไฟล์ลายน้ำที่สิ้นสุด G.Dispose (); imageio.write (bufferedimage, pictrue_formate_jpg, ไฟล์);} catch (ioexception e) stacktrace ();}} : c: //mypictrue//1.jpg* @param presterstext ข้อความลายน้ำเช่น: China Securities Network* @param Fontname ชื่อตัวอักษรเช่น: สไตล์เพลง* @param fontstyle สไตล์สไตล์ตัวอักษรเช่น: font.bold | Font.italic)* @Param FontSize ขนาดตัวอักษรหน่วยคือ Pixel* @param Color Font สี* @param X ข้อความลายน้ำถูกชดเชยจากด้านซ้ายของภาพเป้าหมายถ้า x <0, ตรงกลาง* @param ข้อความลายน้ำ, ออฟเซ็ตของด้านบนของภาพเป้าหมายถ้า y <0, ตรงกลาง * @param alpha ความโปร่งใส (0.0 - 1.0, 0.0 มีความโปร่งใสอย่างสมบูรณ์ 1.0 คือ 1.0 เป็นทึบแสงอย่างสมบูรณ์) */สาธารณะคงที่ เป็นโมฆะ PrestersText (String TargetImg, String Presterstext, String fontname, int fontstyle, int fontsize, สี, int y, float alpha) {ลอง {ไฟล์ไฟล์ = ไฟล์ใหม่ (targetImg); ความกว้าง = image.getWidth (null); 0, 0, ความกว้าง, ความสูง, null); ); 0) {y = hightdiff / 2;} อื่นถ้า (y> heightdiff) {y = heightdiff;} g.drawstring (P. restext, x, y + height_1); piction_formate_jpg, ไฟล์);} catch (Exception e) {E.printStackTrace ();}/** * รับความยาวอักขระ, อักขระจีนเป็น 1 อักขระ, ตัวอักษรภาษาอังกฤษเป็น 0.5 อักขระ * @param text * @return อักขระ เช่น: text = "จีน", return 2; text = "test", return 2; ความยาว (); ความยาว int = textLength; }} return (ความยาว % 2 == 0)? ความสูง, ความกว้าง, บูลีน BB) {ลอง {อัตราส่วนคู่ = 0; , buffredimage.scale_smooth); = (ความสูงใหม่ (ความสูง)) ), null); (สีขาว); G.Fillred (0, 0, ความกว้าง, ความสูง); 2, itemp.getWidth (null), itmp.getheight (null), สีขาว, null) ;;; ), สีขาว ll); เป็นโมฆะหลัก (สตริง [] args) พ่น IOException {pressimage ("c: // pic // jpg", "c: //pic/test.gif", 5000, 5000, 0f); pic // jpg "," 旺仔之印 "," 宋体 ", font.bold | font.italic, 20, color.black, 0, 0, 8f); resize (" c: // pic // 4 jpg ", 1,000, 500, true);}}