毕业论文--基于java网络相册系统的设计与实现内容摘要:

,相片资料的上传是必不可少的功能,但随着高分辨率相片的普及,上传图片的容量会很大,例如 300 万像素的相片文件大小基本上是大于 600KB。 在很多图片的网页中,图片容量越大打开网页的速度越慢。 为了解决这个问题,用户上传图片时可以在类中处理一张大相片并缩小它。 将大相片进行缩小的代码如下: public static void createSmallPhoto(String photoPath,String smallPath) { File_file=newFile(photoPath)。 //读入文件 Image src。 try { src=(_file)。 int wideth=110。 intheight=80。 BufferedImagetag=newBufferedImage(wideth,height,B)。 ().drawImage(src,0,0,wideth,height,null)。 //绘制缩小后的图 ileOutputStreamout=newFileOutputStream(smallPath)。 //输出到文件流 JPEGImageEncoderencoder=(out)。 (tag)。 ()。 }catch (IOException e){ ()。 } } 在上述代码中,参数 photoPath 表示上传相片的地址,参数 smallPath 表示生成缩略相片的地址。 在该方法中,首先将 photoPath 参数转换成 Image 对象 src,构造目标文件 tag,设置 tag 的长度和宽度,对 tag 进行编码,输出到文件流 out,最后关闭文件流。 相片水印效果 给图片加水印就是在图片加入指定文字。 网页中的图片上面写着网站的名称和地址,添加文字的作用就是可以最大限度防止盗用,同时也起到标识相片的功能。 本实例中,添加水印效果使用一个 JavaBean 的 createMark()方法,该方方案论证 第 19 页(共 46 页) 19 法的具体实现代码如下: Public static Boolean createMark(String filePath, String printPath, String markContent){ ImageIcon imgIcon=new ImageIcon (filePath); //读取源图片内容 Image theImg=()。 //读取图片的信息 int width=(null)。 //读取图片的宽度 int height= (null)。 //读取图片的长度 BufferedImagebimage=newBufferedImage(width,height,E_INT_RGB)。 Graphics2D g=()。 ()。 //设置文字颜色为红色 (theImg,0,0,null)。 Font font=new Font(markContent,200)。 //对文字进行加粗 (font)。 ((,0.5f))。 //透明 ()。 //文字的旋转角度 g,drawString(markContent,width/3,height/3)。 //绘制文字的位置 ()。 try { //通过输出流生成图片内容 FileOutputStream out=new FileOutputStream(printPath)。 JPEGImageEncoder encoder=(out)。 JPEGEncodeParamparam=(bimage)。 (100f,true)。 (bimage,param)。 ()。 }catch(Exception e) { ()。 return false。 } return true。 基于 Java网络相册系统的设计与实现 第 20 页(共 46 页) 20 } 7 站点运行情况 在网络相册模块的实现中,对于设计中的系统功能模块我基本上都已 实现,并且运行正常。 在模块的设计上还是有些欠缺。 8 结束语 在这次设计中,我完成了用户注册、登录,分栏显示相册,滚动浏览相片,幻灯片浏览相片,批量上传相片,相片加水印,删除相片等基本功能。 通过这次设计,我对 Java 和 SQLServer 技术在网络相册模块的应用有了更深一层的认识和应用。 在以后设计中可能会遇到一些意想不到的难题,我会在以后的学习和工作中会做进一步的学习和探索,以取得更大的进步。 方案论证 第 21 页(共 46 页) 21 附录: 判断用户是否登录 %@ page contentType=text/html。 charset=gb2312 language=java import=.*,.*,.* errorPage= % html head meta equiv=ContentType content=text/html。 charset=gb2312 / link href=css/ type=text/css rel=stylesheet / %@ taglib prefix=c uri= % jsp:useBean id=dao scope=page class=/jsp:useBean title宇晨相册 ——首页 /title /head body table border=0 align=center cellpadding=0 cellspacing=0 tr tdimg src=images/ width=753 height=200/td /tr /table table width=753 height=36 border=0 align=center cellpadding=0 cellspacing=0 background=images/ tr td width=48 /td td width=705 valign=toptable width=481 border=0 cellspacing=0 基于 Java网络相册系统的设计与实现 第 22 页(共 46 页) 22 cellpadding=0 tr td height=31font color=EDE6BCa href= class=a1相册首页 /a b|/b c:if test=${==null} a href= onclick=javascript:checkUserInfo() title=请您先登录 class=a1我的相册 /a /c:if c:if test=${!=null} a href=photoServlet?info=userQueryPhoto class=a1我的相册 /a /c:if b|/b a href= class=a1 分类相册 /a b|/b a href= class=a1 手机相册/a/font/td /tr /table/td /tr /table table height=597 border=0 align=center cellpadding=0 cellspacing=0 tr td img src=images/ width=9 height=597/td td width=535 valign=top background=images/ br % ListPhoto list1=(ListPhoto)(list)。 int a=0。 for(Photo photo1:list1){ % table border=0 align=center cellpadding=0 cellspacing=0 tr td height=20 colspan=2 class=word_black%=()%/td td height=20 class=word_black align=righta href=photoServlet?info=queryPhotoListamp。 type=%=()% 更多 /a/td /tr tr align=center % ListPhoto list2=(photoType=39。 +()+39。 )。 int b=0。 方案论证 第 23 页(共 46 页) 23 for(Photo photo2:list2){ % td width=134 height=103 background=images/a href=photoServlet?info=queryOnePhotoamp。 id=%=()%i mg src=%=()% class=cannelBorder/a/td % b++。 if(b==3) break。 } if(()3){ for(int i=0。 i()。 i++){ % td width=134 height=103 background=images/无 /td %} } % /tr /table table width=504 border=0 cellpadding=0 cellspacing=0 tr td width=504hr/td /tr /table % a++。 if(a==3) break。 } % table width=450 height=100 border=0 align=center cellpadding=0 cellspacing=0 tr td height=40 class=word_black其他类别相册 /td /tr tr td height=47 a href=photoServlet?info=queryPhotoListamp。 type=朋友情深 朋友情深/a a href=photoServlet?info=queryPhotoListamp。 type=甜蜜爱情 甜蜜爱情 /a a href=photoServlet?info=queryPhotoListamp。 type=亲亲 宝 贝 亲亲宝贝/a a href=photoServlet?info=queryPhotoListamp。 type=动漫卡通 动 漫卡通 /a a href=photoServlet?info=queryPhotoListamp。 type=游戏图案/a a href=photoServlet?info=queryPhotoListamp。 type=搞笑贴图 搞笑贴图 /a a href=photoServlet?info=queryPhotoListamp。 type=四季印象 四季印象/abrbr 基于 Java网络相册系统的设计与实现 第 24 页(共 46 页)。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。