如何更正GraphicEx InChunk()函数?

Ple*_*rds 0 delphi png image delphi-xe3 graphicex

我正在尝试将GraphicEx组件库(用于PNG文件)从我的Delphi 2006移植到XE3(最后得到它),在纠正基本错误时,我遇到了这个错误:

"TPNGGraphic.IsChunk" invalid type cast
Run Code Online (Sandbox Code Playgroud)

在线:

function TPNGGraphic.IsChunk(ChunkType: TChunkType): Boolean;

// determines, independant of the cruxial 5ths bits in each "letter", whether the
// current chunk type in the header is the same as the given chunk type

const
  Mask = not $20202020;

begin
  Result := (Cardinal(FHeader.ChunkType) and Mask) = (Cardinal(ChunkType) and Mask); // <-- this line
end;
Run Code Online (Sandbox Code Playgroud)

有谁知道我该怎么做才能纠正它?

RRU*_*RUZ 6

TChunkType定义为

type
  TChunkType = array[0..3] of Char;
Run Code Online (Sandbox Code Playgroud)

因此编译器无法将TChunkType类型转换为Cardinal.

尝试将定义更改为

type
  TChunkType = array[0..3] of AnsiChar;
Run Code Online (Sandbox Code Playgroud)

  • Woa ...我认为最好将其声明为`byte [0..3] of byte`,因为我怀疑其意图是将_chunk_视为字符数据. (2认同)