Java implementation read Flash's SWF file properties

Source: Internet
Author: User
/**
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 file wide and high position is not fixed, divided into 8 kinds, according to the value of 9th, to determine the current Flash file specific width and height position
16 in-System 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;
}
private static byte[] ReadFromFile (String fileName) throws IOException
{
Picsmodel model = NULL;
FileInputStream fin = new FileInputStream (fileName);
byte [] buf = new byte[fin.available ()];
Fin.read (BUF);
Fin.close ();
return buf;
}
}
/*
Image1.java
*/
Package picattrib;

public class Image1 {
private int width;
private int hight;
private int Leng;
Public Image1 () {
try {
Jbinit ();
catch (Exception ex) {
Ex.printstacktrace ();
}
}

public static void Main (string[] args) {
Image1 image1 = new Image1 ();
}

private void Jbinit () throws Exception {
}

public void setwidth (int width) {
This.width = width;
}

public void sethight (int hight) {
This.hight = hight;
}

public void Setleng (int leng) {
This.leng = Leng;
}

public int getwidth () {
return width;
}

public int gethight () {
return hight;
}

public int Getleng () {
Return Leng;
}
}
Please contact qq:43714802 If you have any unidentified persons.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.