資源簡介
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個文件信息
評論
共有 條評論