On 2013-04-18 20:37:06 +0200, Ludo Brands wrote: > On 04/18/2013 07:53 PM, Leonardo M. Ramé wrote: > > On 2013-04-18 12:49:07 -0300, Leonardo M. Ramé wrote: > >> 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. > >> > > > > Well, it's speed improved, but the image is blue... Do you know why?. > > > The Longword is saved low byte first on a LE arch. You need to change > the order of the colors to > PixelPtr^ := lRed or (lGreen shl 8) or (lBlue shl 16) or ($ff shl 24); > Also make sure lRed, etc are bytes. If not use (lRed and $ff) etc. > > Ludo >
Yes!, now it works. Thank you and Leledumbo, it works pretty fast. -- Leonardo M. Ramé http://leonardorame.blogspot.com -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
