Home > Back-end >  How to convert PByteArray -> PChar?
How to convert PByteArray -> PChar?

Time:11-11

Everybody is good, I was in an old book, image processing, has the following a period of error source, as follows:

Procedure TForm1. RotateMethod2 (aBitmap: TBitmap);
Var aScnLnBuffer: PChar;
AScanLine: PByteArray;
.
For I:=0 to do nMultiplier - 1
Byte (aScnLnBuffer [nOfs +] I) :=aScanLine [nIdx + I];

1) first of all, the original source is out of the question

Byte (aScnLnBuffer [nOfs +] I) :=aScanLine [nIdx + I];

Compile the wrong also E2064 Left side always be assigned to

On the left side of the Byte () should be wrong? Should go is to convert the value of the right aScanLine aScnLnBuffer!!!!!!

2) so I rewrite
AScnLnBuffer [nOfs +] I) :=pChar (aScanLine [nIdx +] I);

But get error message
E2010 Incompatible types: 'Char' and 'PwideChar'

I know that the Internet, the original Delphi pChar before 2007, 2009 pChar are changed after usage,

In Delphi 2007 and earlier, PChar is an alias for PAnsiChar. Delphi In 2009 and later, PChar is an alias for PWideChar.
The PChar is an alias of PAnsiChar in Delphi 6 and stands for a PWideChar in Delphi XE8.

Excuse me everybody I should how to modify this line of code, to compile and run the normal?

CodePudding user response:

Var aScnLnBuffer: PAnsiChar;
AScanLine: PByteArray;
.
For I:=0 to do nMultiplier - 1
AScnLnBuffer [I] nOfs + :=AnsiChar (aScanLine [nIdx +] I);

CodePudding user response:

In Delphi 2007 and earlier, PChar is an alias for PAnsiChar. Delphi In 2009 and later, PChar is an alias for PWideChar.
The PChar is an alias of PAnsiChar in Delphi 6 and stands for a PWideChar in Delphi XE8.

Compatible with the old version should be put the PChar instead PAnsiChar
Put all in XE8 PChar PAnsiChar instead

CodePudding user response:

AScnLnBuffer: PChar;
Will this PChar into PAnsiChar should be ok
  • Related