C#/Java读写Flash源文件
用C#怎么读写Flash源文件(即.fla后缀名的文件)或者Flash播放文件(即.swf文件).
用Java读写也行.
------解决方案--------------------不能把
都是不同的语言
------解决方案--------------------sf上有现成的库
------解决方案--------------------读写这些文件你要干什么用?
------解决方案--------------------java实现读取flash的swf文件属性 你可以参考一下
flashattrib.java
*/
package picattrib;
import java.io.IOException;
import java.io.FileInputStream;
public class flashattrib {
public flashattrib() {
}
public static void main(String[] args) {
flashattrib flashattrib = new flashattrib();
byte[] bb=null;
image1 im = null;
try {
bb=flashattrib.readFromFile("d:\\aa.swf");
im = flashattrib.getAttrib(bb);
System.out.println(im.getWidth());
System.out.println(im.getHight());
bb=flashattrib.readFromFile("d:\\bb.swf");
im = flashattrib.getAttrib(bb);
System.out.println(im.getWidth());
System.out.println(im.getHight());
bb=flashattrib.readFromFile("d:\\bb.swf");
im = flashattrib.getAttrib(bb);
System.out.println(im.getWidth());
System.out.println(im.getHight());
} catch (IOException ex1) {
System.out.println(ex1);
}
System.out.println(im.getWidth());
System.out.println(im.getHight());
/*
byte aa=0;
for (int i=0;i<260;i++){
System.out.println(flashattrib.getInt(aa++));
}
*/
}
/**
* @param bb byte[]
* @param start int
* @param leng int
* @return int
*/
public int getWeizhi(int start,int weizhi,int leng,byte[] bb){
int aa=0;
if (weizhi==0) {
aa=getInt(bb[start]);
for (int i=1;i<leng;i++){
aa*=256;
int cc=getInt(bb[start+i]);
aa+=cc;
}
}else{
aa=getInt(bb[start])%16;
aa*=256;
aa+=getInt(bb[start+1]);
aa*=16;
aa+=getInt(bb[start+2])/16;
}
return aa;
}
public image1 getAttrib(byte[] bb){
image1 im=new image1();
//flash文件的宽高位置不固定,分为8种,根据第9位的值,来判断当前flash文件的具体宽高位置
//16进制50,58,60,68,70,78,80,88
switch(bb[8]){
case 80: im.setWidth(getWeizhi(9,0,2,bb)/10);
im.setHight(getWeizhi(11,1,2,bb)/10);
break;
case 88: im.setWidth(getWeizhi(9,1,2,bb)/40);
im.setHight(getWeizhi(12,0,2,bb)/10);
break;
case 96: im.setWidth(getWeizhi(9,1,2,bb)/10);
im.setHight(getWeizhi(12,1,2,bb)/10);
break;
case 104: im.setWidth(getWeizhi(10,0,2,bb)/40);
im.setHight(getWeizhi(13,0,2,bb)/10);
break;
case 112: im.setWidth(getWeizhi(10,0,2,bb)/10);
im.setHight(getWeizhi(13,1,2,bb)/10);
break;
case 120: im.setWidth(getWeizhi(10,1,2,bb)/40);
im.setHight(getWeizhi(14,0,2,bb)/10);
break;
case -128: im.setWidth(getWeizhi(10,1,2,bb)/10);
im.setHight(getWeizhi(14,1,2,bb)/10);
break;
case -120: im.setWidth(getWeizhi(10,0,3,bb)/40);
im.setHight(getWeizhi(15,0,2,bb)/10);
break;
}
return im;
}
public int getInt(byte bb){
if (bb>=0) return bb;
else return 256+bb;