[Lazarus] Pointer type handling
Hans-Peter Diettrich
DrDiettrich1 at aol.com
Tue Dec 10 00:32:20 CET 2013
Leonardo M. Ramé schrieb:
> procedure TImageDrawer.Draw(ABuffer: Pointer);
> begin
> ...
> if MyImage.DataType = "Uint16" then
> data = PWord(ABuffer)^
> else
> if MyImage.DataType = "Uint8" then
> data = PByte(ABuffer)^;
> end;
>
> If I do this, the result of PWord(ABuffer) is the same as
> PByte(ABuffer). I'm starting to think PByte is equal to Pointer type.
The address of ABuffer stays the same, the typecasts only affect the
element type (pointed to).
I cannot provide a simpler solution than you found already. You have to
find an type for "data" that allows for both signed and unsigned values
in the range of the values, too, e.g. Int64. When ABuffer contains
multiple values, typecasts also are required when incrementing the pointer.
DoDi
More information about the Lazarus
mailing list