#pas procedure Threshold(Bitmap: TBitmap; Value: Byte; Color1, Color2: TColor); var x, y: Word; C1, C2: TRGB; Dest: pRGB; begin Bitmap.PixelFormat := pf24Bit; C1 := ColorToRGB(Color1); C2 := ColorToRGB(Color2); for y := 0 to Bitmap.Height - 1 do begin Dest := Bitmap.ScanLine[y]; for x := 0 to Bitmap.Width - 1 do begin if (Dest^.r + Dest^.g + Dest^.b) / 3 > Value then Dest^ := C1 else Dest^ := C2; Inc(Dest); end; end; end;