zoukankan      html  css  js  c++  java
  • Delphi判断一个文件是不是JPG图片

    判断头几个字节:

    function IsJpegFile(FileName: string): Boolean;
    const
    RightBuf : array[0..3] of Byte = ($FF,$D8,$FF,$D9);
    var
    Buf: array[0..3] of Byte;
    begin
    FillChar(Buf, 4, 0);
    with TFileStream.Create(FileName, 0) do begin
    Position := 0;
    ReadBuffer(Buf[0], 2);
    Position := Size-2;
    ReadBuffer(Buf[2], 2);
    Free;
    end;
    Result := CompareMem(@RightBuf[0], @Buf[0], 4);
    end;

    procedure TForm1.Button1Click(Sender: TObject);//测试
    begin
    if Self.OpenDialog1.Execute then
    if IsJpegFile(Self.OpenDialog1.FileName) then
    Showmessage('Is Jpg File');
    end;

    http://blog.csdn.net/diligentcatrich/article/details/6367077

  • 相关阅读:
    ubuntu下使用golang、qml与ubuntu sdk开发桌面应用 (简单示例)
    Go Revel 学习指南
    Go Revel
    Go Revel
    Go Revel
    Go Revel
    Go Revel
    Go Revel
    Go Revel
    Go Revel
  • 原文地址:https://www.cnblogs.com/yzryc/p/6282898.html
Copyright © 2011-2022 走看看