com.hmw.picmark; java.affinetransformop; 텍스트 워터 마크, 줌, 흰색 등. @author carl he*/public final class imageUtils {/** 이미지 형식 : jpg*/private static final string pictrue_formate_jpg = "jpg"; * 이미지 watermark 추가 * @param targetimg 대상 그림 경로 : c : //mypictrue//1.jpg * @param watermark watermark 그림 경로 : c : //mypictrue//logo.png * @param x. 워터 마크 그림 거리는 그림의 왼쪽 오프셋을 대상으로, x <0이면 중간* @param y 워터 마크 대상 그림의 상단에서 그림 거리, y <0이면 중간* @param에 있습니다. 알파 투명성 (0.0-1.0, 0.0은 완전히 투명하고 1.0은 완전히 불투명합니다) */public final static void pressimage (String targetimg, String waterimg, int x, inty, float alpha) le (targetimg); int width = image.getwidth = indime.getheight (null); drawImage (이미지, 0, 너비, 높이, null); G. 세트 콤포 사이트 (alphacomposite.src_atop, alpha); {x = widthdiff;} if (y <0) {y = heightdiff / 2;} else if (y> highdiff) {y = highdiff;} g.drawimage (Waterimage, x, y, width_1, height_1, null); // WaterMark 파일 끝 G.Dispose (); imageio.write (bufferedImage, pictrue_formate_jpg, file);} catch (ioExcept e) stacktrace ();}}/*** 텍스트 watermark* @param targetimg target 그림 경로. as : c : //mypictrue//1.jpg* @param presterstext watermark 텍스트 : : China Securities Network* @param fontname font 이름 : 송 스타일* @param fontstyle 글꼴 스타일 : : font. BOLD |.. FONT.ITALIC)* @Param fontsize 글꼴 크기, 장치는 픽셀* @param 컬러 글꼴 색상* @param x 워터 마크 텍스트가 대상 그림의 왼쪽에서 x <0 인 경우 중간* @입니다. Param y Watermark 텍스트, 대상 그림의 상단의 오프셋, y <0 인 경우 중간 * @param alpha 투명도 (0.0-1.0, 0.0은 완전히 투명하고 1.0은 완전히 불투명합니다) */public static void prestersText (String targetImg, String PrestersText, String fontName, int fontstyle, int fontsize, int y, float alpha) {file {file file = new File (targetImg); int width = getWidth (null); , 0, 0, 너비, 높이, null); prestext height_1 = int widthdiff = height -height_1; <0) {y = heightdiff / 2;} else (y> highdiff) {y = highdiff;} g.drawstring (p. restext, x, y + height_1); , piction_formate_jpg, file);} catch (예외 e) {e.printstacktrace ();}/** * 문자 길이, 중국어를 1 자, 영어 문자 0.5 문자로 받기 * @param text * @return 문자 예를 들어 : 텍스트 = "중국", 텍스트 = "테스트", 텍스트 2; .length (); int i = 0; i valueof (acturef (i)) {length ++ ;}} return (길이 2 == 0) : 특정 / 2+1; int height, int width, bbb) {double ratio = 0; 높이, buffredimage.scale_smooth); // 계산 비율 if ((bi.getheight ()> height) || (bi.getWidth ()> width) {if (bi.getheight ()> bi.getWidth ()) { 비율 = (새 정수 (높이)) / bi.getheight (); 비율); itemp = op.filter (bi, null)} if (bb) {width, height, buffredimage.type_int_rgb); olor (color.white) G.Fillred (0, 0, 너비); / 2, itemp.getwidth (null), itemp.getheight (null), white, null);; NULL) ic void main (string [] 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 ", 1000, 500, true);}}