Mega Code Archive

 
Categories / Delphi / Examples
 

Invertbitmapcolours

only works with bitmaps where PixelFormat := pf8bit; procedure InvertCursorBitMapColours; const increment = 64; var //row: array of byte; row: PByteArray; i, j: Integer; redValue: Integer; greenValue: Integer; blueValue: Integer; newRed: Integer; newGreen: Integer; newBlue: Integer; begin for i := 0 to (cursorBitMap.Height - 1) do begin row := cursorBitmap.ScanLine[i]; for j := 0 to (cursorBitMap.Width - 1) do begin redValue := GetRValue(row[j]); greenValue := GetGValue(row[j]); blueValue := GetBValue(row[j]); //invert the colour //(ie make it 'negative') newRed := (255 - redValue); newGreen := (255 - greenValue); newBlue := (255 - blueValue); row[j] := RGB(newRed, newGreen, newBlue); end; end; end;