package com.xiaoma.piccut.demo;
/**
* 下面这些注释是下载这个类的时候本来就有的,本来要删除的,但看了下竟然是license,吼吼,
* 好东西,留在注释里,以备不时之用,大家有需要加license的可以到下面的网址找哦
*/
//EPL, Eclipse Public License, V1.0 or later, http://www.eclipse.org/legal
//LGPL, GNU Lesser General Public License, V2.1 or later, http://www.gnu.org/licenses/lgpl.html
//GPL, GNU General Public License, V2 or later, http://www.gnu.org/licenses/gpl.html
//AL, Apache License, V2.0 or later, http://www.apache.org/licenses
//BSD, BSD License, http://www.opensource.org/licenses/bsd-license.php
/**
* A Base64 encoder/decoder.
*
* <p>
* This class is used to encode and decode data in Base64 format as described in RFC 1521.
*
* <p>
* Project home page: <a href="http://www.source-code.biz/base64coder/java/">www.source-code.biz/base64coder/java</a><br>
* Author: Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland<br>
* Multi-licensed: EPL / LGPL / GPL / AL / BSD.
*/
/**
* 这个类在上面注释的网址中有,大家可以自行下载下,也可以直接用这个,
* 公开的Base64Coder类(不用深究它是怎么实现的,
* 还是那句话,有轮子直接用轮子),好用的要死人了...
* 小马也很无耻的引用了这个网址下的东东,吼吼...
* @Title: Base64Coder.java
* @Package com.xiaoma.piccut.demo
* @Description: TODO
* @author XiaoMa
*/
public class Base64Coder {
//The line separator string of the operating system.
private static final String systemLineSeparator = System.getProperty("line.separator");
//Mapping table from 6-bit nibbles to Base64 characters.
private static char[] map1 = new char[64];
static {
int i=0;
for (char c='A'; c<='Z'; c++) map1[i++] = c;
for (char c='a'; c<='z'; c++) map1[i++] = c;
for (char c='0'; c<='9'; c++) map1[i++] = c;
map1[i++] = '+'; map1[i++] = '/'; }
//Mapping table from Base64 characters to 6-bit nibbles.
private static byte[] map2 = new byte[128];
static {
for (int i=0; i<map2.length; i++) map2[i] = -1;
for (int i=0; i<64; i++) map2[map1[i]] = (byte)i; }
/**
* Encodes a string into Base64 format.
* No blanks or line breaks are inserted.
* @param s A String to be encoded.
* @return A String containing the Base64 encoded data.
*/
public static String encodeString (String s) {
return new String(encode(s.getBytes())); }
/**
* Encodes a byte array into Base 64 format and breaks the output into lines of 76 characters.
* This method is compatible with <code>sun.misc.BASE64Encoder.encodeBuffer(byte[])</code>.
* @param in An array containing the data bytes to be encoded.
* @return A String containing the Base64 encoded data, broken into lines.
*/
public static String encodeLines (byte[] in) {
return encodeLines(in, 0, in.length, 76, systemLineSeparator); }
/**
* Encodes a byte array into Base 64 format and breaks the output into lines.
* @param in An array containing the data bytes to be encoded.
* @param iOff Offset of the first byte in <code>in</code> to be processed.
* @param iLen Number of bytes to be processed in <code>in</code>, starting at <code>iOff</code>.
* @param lineLen Line length for the output data. Should be a multiple of 4.
* @param lineSeparator The line separator to be used to separate the output lines.
* @return A String containing the Base64 encoded data, broken into lines.
*/
public static String encodeLines (byte[] in, int iOff, int iLen, int lineLen, String lineSeparator) {
int blockLen = (lineLen*3) / 4;
if (blockLen <= 0) throw new IllegalArgumentException();
int lines = (iLen+blockLen-1) / blockLen;
int bufLen = ((iLen+2)/3)*4 + lines*lineSeparator.length();
StringBuilder buf = new StringBuilder(bufLen);
int ip = 0;
while (ip < iLen) {
int l = Math.min(iLen-ip, blockLen);
buf.append (encode(in, iOff+ip, l));
buf.append (lineSeparator);
ip += l; }
return buf.toString(); }
/**
* Encodes a byte array into Base64 format.
* No blanks or line breaks are inserted in the output.
* @param in An array containing the data bytes to be encoded.
* @return A character array containing the Base64 encoded data.
*/
public static char[] encode (byte[] in) {
return encode(in, 0, in.length); }
/**
* Encodes a byte array into Base64 format.
* No blanks or line breaks are inserted in the output.
* @param in An array containing the data bytes to be encoded.
* @param iLen Number of bytes to process in <code>in</code>.
* @return A character array containing the Base64 encoded data.
*/
public static char[] encode (byte[] in, int iLen) {
return encode(in, 0, iLen); }
/**
* Encodes a byte array into Base64 format.
* No blanks or line breaks are inserted in the output.
* @param in An array containing the data bytes to be encoded.
* @param iOff Offset of the first byte in <code>in</code> to be processed.
* @param iLen Number of bytes to process in <code>in</code>, starting at <code>iOff</code>.
* @return A character array containing the Base64 encoded data.
*/
public static char[] encode (byte[] in, int iOff, int iLen) {
int oDataLen = (iLen*4+2)/3; // output length without padding
int oLen = ((iLen+2)/3)*4; // output length including padding
char[] out = new char[oLen];
int ip = iOff;
int iEnd = iOff + iLen;
int op = 0;
while (ip < iEnd) {
int i0 = in[ip++] & 0xff;
int i1 = ip < iEnd ? in[ip++] & 0xff : 0;
int i2 = ip < iEnd ? in[ip++] & 0xff : 0;
int o0 = i0 >>> 2;
int o1 = ((i0 & 3) << 4) | (i1 >>> 4);
int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6);
int o3 = i2 & 0x3F;
out[op++] = map1[o0];
out[op++] = map1[o1];
out[op] = op < oDataLen ? map1[o2] : '='; op++;
out[op] = op < oDataLen ? map1[o3] : '='; op++; }
return out; }
/**
* Decodes a string from Base64 format.
* No blanks or line breaks are allowed within the Base64 encoded input data.
* @param s A Base64 String to be decoded.
* @return A String containing the decoded data.
* @throws IllegalArgumentException If the input is not valid Base64 encoded data.
*/
public static String decodeString (String s) {
return new String(decode(s)); }
/**
* Decodes a byte array from Base64 format and ignores line separators, tabs and blanks.
* CR, LF, Tab and Space characters are ignored in the input data.
* This method is compatible with <code>sun.misc.BASE64Decoder.decodeBuffer(String)</code>.
* @param s A Base64 String to be decoded.
* @return An array containing the decoded data bytes.
* @throws IllegalArgumentException If the input is not valid Base64 encoded data.
*/
public static byte[] decodeLines (String s) {
char[] buf = new char[s.length()+3];
int p = 0;
for (int ip = 0; ip < s.length(); ip++) {
char c = s.charAt(ip);
if (c != ' ' && c != '\r' && c != '\n' && c != '\t')
buf[p++] = c; }
while ((p % 4) != 0)
buf[p++] = '0';
return decode(buf, 0, p); }
/**
* Decodes a byte array from Base64 format.
* No blanks or line breaks are allowed within the Base64 encoded input data.
* @param s A Base64 String to be decoded.
* @return An array containing the decoded data bytes.
* @throws IllegalArgumentException If the input is not valid Base64 encoded data.
*/
public static byte[] decode (String s) {
return decode(s.toCharArray()); }
/**
* Decodes a byte array from Base64 format.
* No blanks or line breaks are allowed within the Base64 encoded input data.
* @param in A character array containing the Base64 encoded data.
* @return An array containing the decoded data bytes.
* @throws IllegalArgumentException If the input is not valid Base64 encoded data.
*/
public static byte[] decode (char[] in) {
return decode(in, 0, in.length); }
/**
* Decodes a byte array from Base64 format.
* No blanks or line breaks are allowed within the Base64 encoded input data.
* @param in A character array containing the Base64 en
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Android应用源码之Myjob3(图片剪辑功能)-IT计算机-毕业设计.zip (90个子文件)
Android应用源码之Myjob3(图片剪辑功能)
Myjob3
bin
classes.dex 22KB
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
popup.png 2KB
drawable-mdpi
ic_launcher.png 2KB
Myjob2.apk 76KB
classes
classes.dex 22KB
gl
test
Myjob2Activity$LightOnclickListener.class 883B
R$layout.class 390B
Myjob2Activity$SaveOnclickListener.class 1KB
R$id.class 677B
R$drawable.class 460B
Myjob2Activity$CancleOnclickListener.class 926B
view
ToneMenuView.class 3KB
MenuView$3.class 748B
ToneMenuView$1.class 950B
ToneView.class 5KB
MenuView$1.class 922B
MenuView$2.class 748B
MenuView.class 3KB
R$attr.class 307B
Myjob2Activity$1.class 674B
Myjob2Activity$CrapOnclickListener.class 2KB
Myjob2Activity$ScrawlOnclickListener.class 2KB
Myjob2Activity.class 9KB
R.class 454B
R$string.class 394B
Myjob2Activity$RotateOnclickListener.class 887B
Myjob2Activity$ZoomOnclickListener.class 879B
util
ZoomImage.class 931B
ImageService.class 1KB
CropImage.class 2KB
PaintView.class 2KB
resources.ap_ 64KB
Myjob3.apk 77KB
resources.ap_ 64KB
Myjob3.apk 77KB
PicCutDemo
bin
classes.dex 10KB
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
drawable-mdpi
ic_launcher.png 2KB
xiaoma.png 16KB
PicCutDemo.apk 34KB
classes
com
xiaoma
piccut
demo
R$layout.class 1KB
Base64Coder.class 3KB
R$id.class 1KB
R$drawable.class 1KB
PicCutDemoActivity.class 6KB
R$attr.class 1KB
R.class 1KB
R$string.class 1KB
resources.ap_ 27KB
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
values
strings.xml 192B
drawable-mdpi
ic_launcher.png 3KB
xiaoma.png 23KB
layout
main.xml 1016B
default.properties 362B
gen
com
xiaoma
piccut
demo
R.java 913B
proguard.cfg 1KB
src
com
xiaoma
piccut
demo
Base64Coder.java 9KB
PicCutDemoActivity.java 7KB
.project 846B
.classpath 364B
project.properties 360B
AndroidManifest.xml 913B
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
patient.jpg 36KB
ic_launcher.png 4KB
bj.jpg 14KB
popup.png 2KB
values
strings.xml 178B
drawable-mdpi
ic_launcher.png 3KB
layout
main.xml 2KB
popup.xml 751B
default.properties 362B
gen
gl
test
R.java 1KB
proguard.cfg 1KB
src
gl
test
Myjob2Activity.java 9KB
view
ToneMenuView.java 2KB
ToneView.java 4KB
MenuView.java 3KB
util
ImageService.java 1KB
CropImage.java 786B
ZoomImage.java 729B
PaintView.java 2KB
.project 842B
.classpath 364B
AndroidManifest.xml 1KB
共 90 条
- 1
资源评论
芝麻粒儿
- 粉丝: 6w+
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功