[Lazarus] Slow pointer assignments

leledumbo leledumbo_cool at yahoo.co.id
Thu Apr 18 17:48:11 CEST 2013


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; 




--
View this message in context: http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Slow-pointer-assignments-tp4030759p4030762.html
Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com.




More information about the Lazarus mailing list