资源简介
Java写的为图片添加水印的软件(含源代码)
具体可以参看:http://blog.csdn.net/cannel_2020/article/details/7525047
代码片段和文件信息
package watermark;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.MemoryImageSource;
import java.io.FileInputStream;
import java.io.IOException;
/**
* 处理bmp后缀的图片
* @author 代码来自网上
*
*/
public class BMPLoader
{
// build an int from a byte array - convert little to big endian
public static int constructInt(byte[] in int offset) {
int ret = ((int) in[offset + 3] & 0xff);
ret = (ret << 8) | ((int) in[offset + 2] & 0xff);
ret = (ret << 8) | ((int) in[offset + 1] & 0xff);
ret = (ret << 8) | ((int) in[offset + 0] & 0xff);
return (ret);
}
// build an int from a byte array - convert little to big endian
// set high order bytes to 0xfff
public static int constructInt3(byte[] in int offset) {
int ret = 0xff;
ret = (ret << 8) | ((int) in[offset + 2] & 0xff);
ret = (ret << 8) | ((int) in[offset + 1] & 0xff);
ret = (ret << 8) | ((int) in[offset + 0] & 0xff);
return (ret);
}
// build an int from a byte array - convert little to big endian
public static long constructLong(byte[] in int offset) {
long ret = ((long) in[offset + 7] & 0xff);
ret |= (ret << 8) | ((long) in[offset + 6] & 0xff);
ret |= (ret << 8) | ((long) in[offset + 5] & 0xff);
ret |= (ret << 8) | ((long) in[offset + 4] & 0xff);
ret |= (ret << 8) | ((long) in[offset + 3] & 0xff);
ret |= (ret << 8) | ((long) in[offset + 2] & 0xff);
ret |= (ret << 8) | ((long) in[offset + 1] & 0xff);
ret |= (ret << 8) | ((long) in[offset + 0] & 0xff);
return (ret);
}
// build an double from a byte array - convert little to big endian
public static double constructDouble(byte[] in int offset) {
long ret = constructLong(in offset);
return (Double.longBitsToDouble(ret));
}
// build an short from a byte array - convert little to big endian
public static short constructShort(byte[] in int offset) {
short ret = (short) ((short) in[offset + 1] & 0xff);
ret = (short) ((ret << 8) | (short) ((short) in[offset + 0] & 0xff));
return (ret);
}
// internal class representing a bitmap header structure
// with code to read it from a file
static class BitmapHeader {
public int nsize;
public int nbisize;
public int nwidth;
public int nheight;
public int nplanes;
public int nbitcount;
public int ncompression;
public int nsizeimage;
public int nxpm;
public int nypm;
public int nclrused;
public int nclrimp;
// read in the bitmap header
public void read(FileInputStream fs) throws IOException
{
final int bflen = 14; // 14 byte BITMAPFILEHEADER
byte bf[] = new byte[bflen];
fs.read(bf 0 bflen);
final int bilen = 40; // 40-byte BITMAPINFOHEADER
byte bi[] = new byte[bilen];
fs.read(bi 0 bilen);
// Interperet data.
nsize = constructInt(bf 2);
// System.out.println(“File type is :“+(char)bf[0]+(c
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 232 2012-04-30 23:55 watermark\.classpath
文件 385 2012-04-30 23:55 watermark\.project
文件 1324 2012-04-30 23:55 watermark\bin\watermark\BMPLoader$BitmapHeader.class
文件 4722 2012-04-30 23:55 watermark\bin\watermark\BMPLoader.class
文件 965 2012-04-30 23:55 watermark\bin\watermark\ButtonAction$1.class
文件 8004 2012-04-30 23:55 watermark\bin\watermark\ButtonAction.class
文件 1713 2012-04-30 23:55 watermark\bin\watermark\CommandButton$Buttonst
文件 734 2012-04-30 23:55 watermark\bin\watermark\CommandButton.class
文件 3700 2012-04-30 23:55 watermark\bin\watermark\Common.class
文件 919 2012-04-30 23:55 watermark\bin\watermark\FileBean.class
文件 5202 2012-04-30 23:55 watermark\bin\watermark\ImageDropTargetListener.class
文件 6910 2012-04-30 23:55 watermark\bin\watermark\ImageTool.class
文件 458 2012-04-30 23:55 watermark\bin\watermark\Main.class
文件 890 2012-04-30 23:59 watermark\bin\watermark\Mainfr
文件 1706 2012-04-30 23:59 watermark\bin\watermark\Mainfr
文件 9835 2012-04-30 23:59 watermark\bin\watermark\Mainfr
文件 1033 2012-04-30 23:55 watermark\bin\watermark\PreviewImage$1.class
文件 785 2012-04-30 23:55 watermark\bin\watermark\PreviewImage$2.class
文件 1891 2012-04-30 23:55 watermark\bin\watermark\PreviewImage$DragPicListener.class
文件 1568 2012-04-30 23:55 watermark\bin\watermark\PreviewImage.class
文件 10299 2012-04-30 23:55 watermark\src\watermark\BMPLoader.java
文件 6935 2012-04-30 23:55 watermark\src\watermark\ButtonAction.java
文件 791 2012-04-30 23:55 watermark\src\watermark\CommandButton.java
文件 2895 2012-04-30 23:55 watermark\src\watermark\Common.java
文件 583 2012-04-30 23:55 watermark\src\watermark\FileBean.java
文件 3711 2012-04-30 23:55 watermark\src\watermark\ImageDropTargetListener.java
文件 7333 2012-04-30 23:55 watermark\src\watermark\ImageTool.java
文件 179 2012-04-30 23:55 watermark\src\watermark\Main.java
文件 10862 2012-04-30 23:59 watermark\src\watermark\Mainfr
文件 2374 2012-04-30 23:55 watermark\src\watermark\PreviewImage.java
............此处省略9个文件信息
相关资源
- Java信息科技管理人员面试题中国邮政
- java发送ISO8583报文接口框架
- java中cos文件上传
- JAVA数据结构排序动态演示
- okhttp3(包含http-3.9.0.jar和okio1.13.0.ja
- Java中国象棋有悔棋功能
- 利用java多线程汉字打字练习程序
- java 多个实习报告
- java通过HTTP调用接口Get请求和Post请求
- 闹钟java源码
- 数据库管理系统java实现
- java实现DBMS
- 《Java程序设计教程》习题及参考答案
- JAVA外文翻译212329
- jsp java web在线订购系统
- 进程管理系统java程序+设计文档
- java实现的即时通讯
- javaWeb实现二维码名片生成
- MR编程之Top3源代码
- JAVA JSP题库组卷管理系统 源代码 论文
- java金融项目开发-银行核心系统业务介
- WXPayUtil.java
- java实现工作流以及工作流的处理
- java超级玛丽游戏
- 200道Java程序设计练习题 PDF
-
java中li
nkedList任意排序 - 邮件客户端程序
- java连接vfp数据库的
- 《Java从入门到精通》第四版pdf及光盘
- Java开发软件整理Maven、Eclipse、JDK8、
评论
共有 条评论