Qt5,Qt6: Small optimization by avoid deep copy when using QImage::bits(), better use const overload QImage::constBits().

This commit is contained in:
Željan Rikalo 2023-09-17 18:47:13 +02:00
parent 674d4ebae9
commit 92b006ccaa
6 changed files with 6 additions and 6 deletions

View File

@ -757,7 +757,7 @@ var
begin
ARawImage.DataSize := QImage_numBytes(AImage);
ARawImage.Data := GetMem(ARawImage.DataSize);
Move(QImage_bits(AImage)^, ARawImage.Data^, ARawImage.DataSize);
Move(QImage_constBits(AImage)^, ARawImage.Data^, ARawImage.DataSize);
ARawImage.Mask := nil;
end;

View File

@ -1430,7 +1430,7 @@ end;
------------------------------------------------------------------------------}
function TQtImage.bits: PByte;
begin
Result := QImage_bits(FHandle);
Result := QImage_constBits(FHandle);
end;
{------------------------------------------------------------------------------

View File

@ -2499,7 +2499,7 @@ begin
if Count < Result then
Result := Count;
if Result > 0 then
Move(QImage_bits(Image)^, Bits^, Result);
Move(QImage_constBits(Image)^, Bits^, Result);
finally
QImage_destroy(Image);
end;

View File

@ -778,7 +778,7 @@ var
begin
ARawImage.DataSize := QImage_numBytes(AImage);
ARawImage.Data := GetMem(ARawImage.DataSize);
Move(QImage_bits(AImage)^, ARawImage.Data^, ARawImage.DataSize);
Move(QImage_constBits(AImage)^, ARawImage.Data^, ARawImage.DataSize);
ARawImage.Mask := nil;
end;

View File

@ -1466,7 +1466,7 @@ end;
------------------------------------------------------------------------------}
function TQtImage.bits: PByte;
begin
Result := QImage_bits(FHandle);
Result := QImage_constBits(FHandle);
end;
{------------------------------------------------------------------------------

View File

@ -2496,7 +2496,7 @@ begin
if Count < Result then
Result := Count;
if Result > 0 then
Move(QImage_bits(Image)^, Bits^, Result);
Move(QImage_constBits(Image)^, Bits^, Result);
finally
QImage_destroy(Image);
end;