资源简介
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源码,servlet+jsp),适
- java串口通信全套完整代码-导入eclip
- jsonarray所必需的6个jar包.rar
- JSP企业人事管理系统设计(源代码+论
- 三角网构TIN生成算法,Java语言实现
- java代码编写将excel数据导入到mysql数据
- Java写的cmm词法分析器源代码及javacc学
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- android-support-v4.jar已打包进去源代码
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
- Java 文件加密传输
评论
共有 条评论