Changeset 77 for trunk/Packages/Common
- Timestamp:
- May 19, 2021, 11:30:41 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/UPixelPointer.pas
r76 r77 53 53 procedure BitmapSwapRedBlue(Bitmap:TRasterImage); 54 54 procedure BitmapInvert(Bitmap: TRasterImage); 55 procedure BitmapBlendColor(Bitmap: TRasterImage; Color: TColor32); 56 function Color32(A, R, G, B: Byte): TColor32; 57 function Color32ToPixel32(Color: TColor32): TPixel32; 58 function Pixel32ToColor32(Color: TPixel32): TColor32; 55 59 56 60 implementation … … 237 241 end; 238 242 243 procedure BitmapBlendColor(Bitmap: TRasterImage; Color: TColor32); 244 var 245 X, Y: Integer; 246 Ptr: TPixelPointer; 247 A, R, G, B: Word; 248 Pixel: TPixel32; 249 begin 250 Pixel := Color32ToPixel32(Color); 251 Bitmap.BeginUpdate(True); 252 Ptr := PixelPointer(Bitmap); 253 for Y := 0 to Bitmap.Height - 1 do begin 254 for X := 0 to Bitmap.Width - 1 do begin 255 A := Ptr.Pixel^.A; //(Ptr.Pixel^.A + Pixel.A) shr 1; 256 R := (Ptr.Pixel^.R + Pixel.R) shr 1; 257 G := (Ptr.Pixel^.G + Pixel.G) shr 1; 258 B := (Ptr.Pixel^.B + Pixel.B) shr 1; 259 Ptr.Pixel^.ARGB := Color32(A, R, G, B); 260 Ptr.NextPixel; 261 end; 262 Ptr.NextLine; 263 end; 264 Bitmap.EndUpdate; 265 end; 266 267 function Color32(A, R, G, B: Byte): TColor32; 268 begin 269 Result := ((A and $ff) shl 24) or ((R and $ff) shl 16) or 270 ((G and $ff) shl 8) or ((B and $ff) shl 0); 271 end; 272 273 function Color32ToPixel32(Color: TColor32): TPixel32; 274 begin 275 Result.ARGB := Color; 276 end; 277 278 function Pixel32ToColor32(Color: TPixel32): TColor32; 279 begin 280 Result := Color.ARGB; 281 end; 282 239 283 function PixelPointer(Bitmap: TRasterImage; BaseX: Integer; 240 284 BaseY: Integer): TPixelPointer;
Note:
See TracChangeset
for help on using the changeset viewer.