java 编程 eclipse 怎么显示隐藏代码?
eclipse显示被隐藏的文件或文件夹
稷山网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、响应式网站设计等网站项目制作,到程序开发,运营维护。创新互联于2013年成立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联。
点击左边导航(Navigator或者PackageExplorer等)右上角的小三角 - Filters
点击需要显示文件,让复选框处于非选中状态。
在java中如何用类来实现图片的渐隐渐入不用javaScript
淡入淡出Swing组件
/**
* 淡入淡出式显示内容组件的容器
* @author William Chen
*/
public class GlassBox extends JComponent implements ActionListener{
//常数定义
private static final int ANIMATION_FRAMES=50;
private static final int ANIMATION_INTERVAL=10;
//帧索引
private int frameIndex;
//时钟
private Timer timer;
/** Creates a new instance of GlassBox */
public GlassBox() {
}
public void paint(Graphics g){
if(isAnimating()){
//根据当前帧显示当前透明度的内容组件
float alpha=(float)frameIndex/(float)ANIMATION_FRAMES;
Graphics2D g2d=(Graphics2D)g;
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
//Renderer渲染机制
super.paint(g2d);
}else{
//如果是第一次,启动动画时钟
frameIndex=0;
timer=new Timer(ANIMATION_INTERVAL, this);
timer.start();
}
}
//判断当前是否正在进行动画
private boolean isAnimating(){
return timer!=null timer.isRunning();
}
//关闭时钟,重新初始化
private void closeTimer() {
if(isAnimating()){
timer.stop();
frameIndex=0;
timer=null;
}
}
//动画时钟处理事件
public void actionPerformed(ActionEvent e) {
//前进一帧
frameIndex++;
if(frameIndex=ANIMATION_FRAMES)
//最后一帧,关闭动画
closeTimer();
else//更新当前一帧
repaint();
}
}
java中hidden属性怎样让隐藏的图片显示,之后再次隐藏
你在js中获取这个对象,隐藏就用.hidden(),显示就用.show(),把这个代码绑定在你想要的动作里面,比如onclick等事件
Java实现简单数据隐藏图片文件
我给你写的示例程序:隐藏数据调用hiddenWords,读取数据用readWords,移除数据用removeWords。不管是什么简单数据复杂数据,图片不管什么格式。主要都是转化为流来处理哈。代码如下:有不明白的可以hi 我
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* @author Think
*
*/
public class HiddenWords
{
/**
*
*/
public HiddenWords()
{
// TODO Auto-generated constructor stub
}
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
try
{
int picbytes = hiddenWords("c:\\Sunset.bmp", "c:\\hidden.bmp", "hidden words");
String s = readWords("c:\\hidden.bmp", picbytes);
removeWords("c:\\hidden.bmp", picbytes, "c:\\old.bmp");
System.out.println("read words is:" + s);
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
static int hiddenWords(String input, String output,String words)
{
try
{
InputStream is = new FileInputStream(new File(input/*"c:\\Sunset.bmp"*/));
int bytes = is.available();
DataOutputStream dos = new DataOutputStream(new FileOutputStream(new File(output/*"c:/s.bmp"*/)));
byte[] b = new byte[bytes];
int n = is.read(b, 0, bytes);
is.close();
dos.write(b, 0, n);
dos.writeUTF(words/*"ooeooeore"*/);
dos.close();
System.out.println("write end!!!");
return bytes;
}
catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return 0;
}
static String readWords(String input/*DataInputStream dis*/, int skipbytes)
{
try
{
DataInputStream dis = new DataInputStream(new FileInputStream(new File(input)));
dis.skip(skipbytes);
String result = dis.readUTF();
dis.close();
return result;
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return "";
}
static void removeWords(String input/*DataInputStream dis*/, int skipbytes,String output)
{
try
{
DataInputStream dis = new DataInputStream(new FileInputStream(new File(input)));
byte[] bs = new byte[skipbytes];
int x = dis.read(bs, 0, skipbytes);
dis.close();
DataOutputStream dos = new DataOutputStream(new FileOutputStream(new File(output)));
dos.write(bs, 0, x);
dos.close();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
java如何实现图片中隐藏数据信息的功能啊,小弟死憋两天没有憋出来,请大神指导。
就是加个水印吧
package com.jc.ts.services;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.sun.image.codec.jpeg.ImageFormatException;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
/**
*添加图片水印的服务类
* */
public class WaterMark {
/**
* @param sizeContext添加水印文字
* @param request 请求流对象
* @param request 响应流对象
* */
@SuppressWarnings("deprecation")
public static void createMarkSize(String sizeContext,HttpServletRequest request,HttpServletResponse response) {
try {
String path=request.getRealPath(request.getServletPath());
FileInputStream in=new FileInputStream(path);
Image src=ImageIO.read(in);
int w=src.getWidth(null);
int h=src.getHeight(null);
BufferedImage img=new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);//构建画板
Graphics g=img.getGraphics();//得到画笔
g.drawImage(src,0,0,w,h,null);//把源图片写入画板
g.setColor(Color.red);
g.drawString(sizeContext,10,5); // 添加文字
g.dispose();//生成图片
JPEGImageEncoder e=JPEGCodec.createJPEGEncoder(response.getOutputStream());
e.encode(img);
response.getOutputStream().close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ImageFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* @param localPath 添加水印LOGO路径
* @param request 请求流对象
* @param request 响应流对象
**/
@SuppressWarnings("deprecation")
public static void createMarkLogo(String localPath,HttpServletRequest request,HttpServletResponse response) {
try {
FileInputStream file=new FileInputStream(localPath);
Image fimg=ImageIO.read(file);
int fw=fimg.getWidth(null);
int fh=fimg.getHeight(null);
String path=request.getRealPath(request.getServletPath());
FileInputStream in=new FileInputStream(path);
Image src=ImageIO.read(in);
int w=src.getWidth(null);
int h=src.getHeight(null);
BufferedImage img=new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);//构建画板
Graphics g=img.getGraphics();//得到画笔
g.drawImage(src,0,0,w,h,null);//把原图片写入画板
g.drawImage(fimg,w-20,h-15,fw,fh,null);//把水印图片写入画板
g.dispose();//生成图片
JPEGImageEncoder e=JPEGCodec.createJPEGEncoder(response.getOutputStream());
e.encode(img);
response.getOutputStream().close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ImageFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/**
* @param localPath 添加水印图片路径
* @param request 请求流对象
* @param request 响应流对象
* @param width 水印图片的宽度
* @param height 水印图片的长度
**/
@SuppressWarnings("deprecation")
public static void createMarkLogo(String localPath,HttpServletRequest request,HttpServletResponse response,int width,int height) {
try {
FileInputStream file=new FileInputStream(localPath);
Image fimg=ImageIO.read(file);
int fw=fimg.getWidth(null);
int fh=fimg.getHeight(null);
String path=request.getRealPath(request.getServletPath());
FileInputStream in=new FileInputStream(path);
Image src=ImageIO.read(in);
int w=src.getWidth(null);//w为你过滤图片的宽度
int h=src.getHeight(null);//h为你过滤图片的长度
BufferedImage img=new BufferedImage(w+width,h+height,BufferedImage.TYPE_INT_RGB);//构建画板(画板的宽度为两个图片之和)
Graphics g=img.getGraphics();//得到画笔
g.drawImage(src,0,0,w,h,null);//把原图片写入画板
g.drawImage(fimg,width,height,fw,fh,null);//把水印图片写入画板
g.dispose();//生成图片
JPEGImageEncoder e=JPEGCodec.createJPEGEncoder(response.getOutputStream());
e.encode(img);
response.getOutputStream().close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ImageFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
注意第三个方法的注释地方g.drawImage(fimg,width,height,fw,fh,null);根据参数你在调调(放原图下面的)
过滤器调用
package com.jc.ts.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.jc.ts.services.WaterMark;
public class WaterFilter implements Filter {
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest arg0, ServletResponse arg1,
FilterChain arg2) throws IOException, ServletException {
HttpServletRequest request=(HttpServletRequest)arg0;
HttpServletResponse response=(HttpServletResponse)arg1;
//WaterMark.createMarkSize("南京ts", request, response);
//WaterMark.createMarkLogo("D:\\workspace\\mybook\\WebRoot\\images\\logo\\book.jpg", request, response);
WaterMark.createMarkLogo("D:\\workspace\\mybook\\WebRoot\\images\\logo\\book.jpg", request, response,20,30);
//注意路径为绝对路径且三个效果不能同时执行
}
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
}
}
web.xml配置(写在servlet上面)
filter
descriptionThis is the description of my J2EE component/description
display-nameThis is the display name of my J2EE component/display-name
filter-nameWaterFilter/filter-name
filter-classcom.jc.ts.filter.WaterFilter/filter-class
/filter
分享标题:Java中图片隐藏代码 java中图片隐藏代码是什么
网站路径:http://scyingshan.cn/article/hjghhg.html