Im Projekt müssen wir einige Avatare hochladen, Bildschneidfunktionen, OK Lesen Sie den folgenden Artikel!
Ich brauche Stecker -in: JQuery JCrop
Back -End -Code:
Paket org.csg.Upload; .Imageo.imageo; Param Path2 Der Pfad, der nach dem Schneiden gespeichert ist* @param xx swaft* @param yy swaft {FileInputStream FileInputStream = null; "JPG"); ). EDIMAGE BI = Reader.read (0, Param); . printStackTrace ();}}}}}}}}}}}}}}}
Zugangscode:
<%@page Language = "java" import = "java.util.*, org.csg.Upload. ; Der Server nach dem Schneiden von String path2 = relpath+"/images/"+newFileName; Integer.ParseInt (Request.GetParameter ("W"); int H = Integer.parseInt (Request.GetParameter ("H"); Try {Upload.c.c utimage (Path1, Path2, X, Y, W, H); .print ("<img Src = 'Bilder/"+newFileName+"'/>");} catch (Ausnahme E) {E.printstacktrace ();
JSP -Code:
<%@ Page Language = "Java" Image = "java.util.*" PageCoding = "UTF-8"%> <! JSP entwickeln Avatar-Schneiden </title> <meta http-äquiv = "pragma" content = "no-cache"> <meta http-äquiv = "cache-control" content = "no-cache"> <meta http-equiv = "expires" content = "0"> <meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3"> <meta http-äquiv = "Beschreibung Ption" content = "Dies ist meine Seite"> <Link "> <Link rel = "styleSheet" href = "css/jquery.jcrop.css" type = "text/csS"/> <script type = "text/javaScript" <script type = "text/javaScript" {Margin-Top: 20px;} #Vorschau {Anzeige: Absolute; 0, .4) Solid; ; } </style> <script type = "text/javaScript"> nction () {var jcrop_api, boundx = "", boundy = "", $ preview = $ ('#preview-pane'), $ pcnt = $ ( '#Preview-Pane .Preview-Container'), $ pimg = $ ('#Vorschau-Pane .Preview-Controlainer IMG'), xsize = $ pcnt.width (), ysize = $ pcnt.head (); '#Cutimage') (JCROP_API.Ui.HOLDER);}); $ ("#y1"). ; var ry = ysize / ch; Math.round (rx * cx) + 'px', margintop: ' + math.round (ry * cy) +' px '});}}}); > Java Development QQ Avatar Schneidsystem </h1> <img id = "Cutimage" Src = "Bilder/1.JPG"> <Div ID = "Preview-Pane"> <div> <img src = "Bilder/1. JPG "/> </div> </div> </div> <form action =" success.jsp "methode =" post "> <Eingabe type =" text "value =" Bilder/1.JPG "name =" ImgPath "> x Achse: <Eingabe type =" text "size =" 4 "id =" x1 "name =" x " /> y axis: <Eingabe type =" text "size =" 4 "id =" y1 " name = "y"/> width: <Eingabe type = "text" size = "4" id = "w" name = "w"/> Höhe: <Eingabe type = "text" size = "4" id = " H "name =" h "/> <Eingabe type =" sureichen "value =" cut "/> </form> </body> </html>
Effektkarte:
Das obige ist der gesamte Inhalt dieses Artikels.