Java to read the SWF file properties of flash-column of zhangjianwxh-csdnblog

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 = 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; isystem. 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 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 ();
// The width and height of the Flash file are not fixed. There are eight types of files. The specific width and height of the current FLASH file are determined based on the 9th-bit value.
// Hexadecimal values: 50, 58, 60, 68, 70, 78, 80, and 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 (, 2, BB)/40 );
Im. sethight (getweizhi (14,0, 2, BB)/10 );
Break;
Case-128: Im. setwidth (getweizhi (, 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;
}
}

This article is transferred from
Http://blog.csdn.net/zhangjianwxh/archive/2005/06/20/398385.aspx

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.