• swf文件头和tag结构解析


    unit Unit1;
    interface
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ComCtrls;
    type
      TForm1 = class(TForm)
        Edit1: TEdit;
        Button1: TButton;
        OpenDialog1: TOpenDialog;
        Edit2: TEdit;
        Edit3: TEdit;
        Edit4: TEdit;
        Edit5: TEdit;
        Edit6: TEdit;
        Edit7: TEdit;
        Edit8: TEdit;
        ListView1: TListView;
        Button2: TButton;
        Edit9: TEdit;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    var
      Form1: TForm1;
    implementation
    {$R *.dfm}
    type    Tbuff=record
            F:byte;
            W:byte;
            S:byte;
            version:byte;
            File_length:cardinal;
            end;
    var    buff:Tbuff;
           dt:array of byte;
    procedure TForm1.Button1Click(Sender: TObject);
    var
        Filename:string;
        Fileid:cardinal;
        Fileinfo:OFSTRUCT;
        nbits:integer;
        vbitpos:integer;
        vbyte:integer;
        nBytesRead:cardinal;
        xmin,xmax,ymin,ymax:longword;
        id,length,_from,_to:word;
        _tlist:tlistitem;
        function getbitval:longword;
        var vvsam:longword;
        begin
            vvsam:=dt[vbyte]*$1000000+dt[vbyte+1]*$10000+dt[vbyte+2]*$100+dt[vbyte+3];    //取数
            result:=longword(vvsam shl vbitpos) shr (32-nbits);                           //移位取值
            inc(vbitpos,nbits);                                                           //移位
            inc(vbyte,vbitpos div 8);                                                     //移字节 定新字节
            vbitpos:=vbitpos mod 8;                                                       //定新位
        end;
    begin
    if OpenDialog1.Execute then
        Filename:=OpenDialog1.FileName;
    Fileid:=openfile(pchar(Filename),Fileinfo,OF_READ);
    readfile(Fileid,buff,8,nBytesRead,nil);
    setlength(dt,buff.File_length);
    readfile(Fileid,dt[0],buff.File_length,nBytesRead,nil);               //已有8个字节读入buff中,不算在dt内
    setlength(dt,nBytesRead);
          edit1.Text:='F='+inttostr(buff.F);
          edit2.Text:='W='+inttostr(buff.W);
          edit3.Text:='S='+inttostr(buff.S);
          edit4.Text:='version='+inttostr(buff.version);
          edit5.Text:='File_length='+inttostr(buff.File_length);
    nbits:=byte(dt[0] shr 3);
    edit8.Text:='nbits='+inttostr(nbits);
    vbyte:=0;
    vbitpos:=5;
    xmin:=getbitval;
    xmax:=getbitval div 20;
    ymin:=getbitval;
    ymax:=getbitval div 20;
    edit9.Text:=('xmin='+inttostr(xmin)+' , '+
                  'xmax='+inttostr(xmax)+' , '+
                  'ymin='+inttostr(ymin)+' , '+
                  'ymax='+inttostr(ymax)       ) ;
    if vbitpos>0 then inc(vbyte);
    edit6.Text:='rate='+inttostr(dt[vbyte+1]);
    edit7.Text:='count='+inttostr(word((@dt[vbyte+2])^));
    //-----------------------------------------------------------------------SWF文件头
    _from:=vbyte+4;
        while (_from<=nBytesRead-1) do  begin
           _tlist:=listview1.Items.Add;            //生成对象,对象存在才能给其赋值
           id:=word((@dt[_from])^);
           length:=id and $3f;
           if length=$3f then length:=longword((@dt[_from+2])^)+4;
           inc(length,2);
           id:=id shr 6;
           _to:=_from+length;

           _tlist.Caption:=inttostr(id);
           _tlist.SubItems.Add(inttostr(length));
           _tlist.SubItems.Add(inttostr(_from));
           _tlist.SubItems.Add(inttostr(_to));
           _from:=_to;
        end;
    //----------------------------------------------------------------------Tag=length+Tag头(2或者6);
    end;
  • 相关阅读:
    第1章 数据类型 第1节 JavaScript中的几个重要概念
    第1章 数据类型 第3节 JavaScript数值类型(2)
    第1章 数据类型 第4节 JavaScript字符类型
    GDI编程框架代码
    linux清空日志文件内容 比如log日志
    快速点对点批量向员工推送企业微信消息的方法
    在EasySQLMAIL中实现表格的行列转置
    快速信息分发技巧:按员工手机号通过企业微信点对点分发信息
    网络
    【odoo】【相识篇】一、Odoo VS SAP?
  • 原文地址:https://www.cnblogs.com/smallmuda/p/1438105.html
Copyright © 2020-2023  润新知