[Lazarus] Slow pointer assignments

Leonardo M. Ramé l.rame at griensu.com
Thu Apr 18 17:49:07 CEST 2013


On 2013-04-18 08:48:11 -0700, leledumbo wrote:
> Assign all the RGBA value in one go, that would reduce the inner loop by 4
> times. i.e.:
> 
> var 
>   PixelPtr: PLongWord; 
>   PixelRowPtr: PByte; 
> begin 
>   PixelRowPtr := Fbmp.RawImage.Data; 
>   for Y := 0 to Self.Height - 1 do 
>   begin 
>     PixelPtr := PLongWord(PixelRowPtr); 
>     for X := 0 to (Self.Width - 1) div 4 do 
>     begin 
>       PixelPtr^ := (lRed shl 24) or (lGreen shl 16) or (lBlue shl 8) or 255; 
>       Inc(PixelPtr); 
>     end; 
>     Inc(PixelRowPtr, FBmp.RawImage.Description.BytesPerLine); 
>   end;   
> end; 
> 

Great!, I'll try it.

-- 
Leonardo M. Ramé
http://leonardorame.blogspot.com




More information about the Lazarus mailing list