Question

I am trying to port the GraphicEx component library (for PNG files) from my Delphi 2006 to XE3 (Finally got it) when correcting the basic errors, I got stuck in this error:

"TPNGGraphic.IsChunk" invalid type cast

At lines:

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;

Does anyone know what should I do to correct it?

Was it helpful?

Solution

TChunkType is defined as

type
  TChunkType = array[0..3] of Char;

So the compiler can't cast the TChunkType type into a Cardinal.

Try changing the definition to

type
  TChunkType = array[0..3] of AnsiChar;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top