I define the types of graphic files by their headers, for example:
var stream : TFileStream; buff : int64; … stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyRead); stream.Read(buff, sizeof(buff)); stream.Free; case (buff and $FFFFFFFF) of $E0FFD8FF : result := 'JPEG IMAGE'; $E2FFD8FF : result := 'JPEG CANNON EOS JPEG FILE'; … Using http://www.filesignatures.net/index.php?page=all&order=EXT&alpha=P .
But when I substitute the signature for "*. * Png" - $0A1A0A0D474E5089 (in 8 bytes ) in case :
case buff of $0A1A0A0D474E5089 : result := 'PNG'; end I have an error:
Constant expression violates subrange bounds
How to be in this case?