No projeto, precisamos fazer alguns avatares, funções de corte de imagens, ok, leia o seguinte artigo!
Eu preciso de plug -in: jQuery jcrop
Back -nd Code:
pacote org.csg.UPLOAD; .Imageio.imageio; Param Path2 O caminho armazenado após corte* @param xx eixo* @param yy eixo* @param w* @param h*/ public static void CutImage (string path1, string path2, int x, int y, int w, int h) {FileInputStream FileInputStream = NULL; "JPG"); ).; ("Falha de corte");} finalmente {try (Arquivo inputStream! = Null) {FILEInputStream.close ();} if (is! = Null) {iis.close ();}} catch (ioexcetion e) {e. printStackTrace ();}}}}}}}}}}}}}}}
Código de acesso:
<%@Page Language = "java" import = "java.util.*, org.csg.upload. ; o servidor após cortar a string path2 = relpath+"/imagens/"+newFileName; Integer.parseint (request.getParameter ("w"); int h = Integer.parseint (request.getParameter ("h"); tente {upload.c.c utimage (path1, path2, x, y, w, h); out .print ("<img src = 'imagens/"+newFileName+"'/>");} Catch (Exceção e) {e.printStackTrace ();
Código JSP:
<%@ Page Language = "Java" Image = "Java.util.*" PageEncoding = "UTF-8"%> <! JSP Desenvolva corte de avatar </ititle> <meta http-equiv = "Pragma" content = "no-cache"> <meta http-equiv = "cache-CONTROL" content = "no-cache"> <meta http-equiv = "Expira" content = "0"> <meta http-equiv = "palavra-chave" content = "palavra-chave1, palavra-chave2, palavra-chave3"> <meta http-equiv = "descrição pion" content = "esta é minha página"> <link rel = "Stylesheet" href = "css/jQuery.jcrop.css" type = "text/css"/> <script type = "text/javascript" src = "js/jQuery.min.js"> </script> <script type = "text/javascript" src = "js/jQuery.jcrop.min.js"> </script> <alle type = "text/css"> *{margem: 0; {margem-top: 20px;} #Visualização {Display: Block; 0, .4) Sólido; ); } </style> <script type = "text/javascript"> nccction () {var jcrop_api, boundx = "", limite = "", $ visualize = $ ('#visualização-pane'), $ pcnt = $ ( '#Visualizar-pane .Preview-container'), $ PIMG = $ ('#Visualize-pane .Preview-Controlainer img'), xsize = $ pcnt.width (), ysize = $ pcnt.head (); '#cutimage') (Jcrop_api.ui.holder);}); $ ("#Y1"). ; Math.Round (rx * cx) + 'px', margintop: ' + math.round (ry * cy) +' px '});}}}); > Sistema de corte de avatar qq de desenvolvimento java </h1> <img id = "cutimage" src = "imagens/1.jpg"> <div id = "visualize pane"> <div> <img src = "imagens/1. jpg "/> </div> </div> </div> <form ação =" succcess.jsp "método =" post "> <input type =" text "value =" imagens/1.jpg "name =" Imgpath "> x eixo: <input type =" text "size =" 4 "id =" x1 "name =" x " /> y eixo: <input type =" text "size =" 4 "id =" y1 " name = "y"/> largura: <type de entrada = "text" size = "4" id = "w" name = "w"/> altura: <input type = "text" size = "4" id = " h "name =" h "/> <input type =" submit "value =" cut "/> </morm> </body> </html>
Mapa de efeitos:
O acima é todo o conteúdo deste artigo. Espero que todos possam gostar.