Ignore:
Timestamp:
Jan 15, 2017, 11:47:01 AM (7 years ago)
Author:
chronos
Message:
  • Modified: Unified direct pixel access using TPixelPointer.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/CityScreen.pas

    r71 r72  
    438438    XX, YY: Integer;
    439439    Gray: Integer;
    440     PixelPtr: PPixel32;
    441     LinePtr: PPixel32;
     440    PixelPtr: TPixelPointer;
    442441  begin
    443442    Offscreen.BeginUpdate;
    444     LinePtr := GetBitmapPixelPtr(Offscreen, X, Y);
     443    PixelPtr.Init(Offscreen, X, Y);
    445444    for YY := 0 to h - 1 do begin
    446       PixelPtr := LinePtr;
    447445      for XX := 0 to w - 1 do begin
    448         Gray := (Integer(PixelPtr^.B) + Integer(PixelPtr^.G) + Integer(PixelPtr^.R)
    449           ) * 85 shr 8;
    450         PixelPtr^.B := 0;
    451         PixelPtr^.G := 0;
    452         PixelPtr^.R := Gray; // 255-(255-gray) div 2;
    453         PixelPtr := Pointer(PixelPtr) + (Offscreen.RawImage.Description.BitsPerPixel shr 3);
     446        Gray := (Integer(PixelPtr.Pixel^.B) + Integer(PixelPtr.Pixel^.G) +
     447        Integer(PixelPtr.Pixel^.R)) * 85 shr 8;
     448        PixelPtr.Pixel^.B := 0;
     449        PixelPtr.Pixel^.G := 0;
     450        PixelPtr.Pixel^.R := Gray; // 255-(255-gray) div 2;
     451        PixelPtr.NextPixel;
    454452      end;
    455       LinePtr := Pointer(LinePtr) + Offscreen.RawImage.Description.BytesPerLine;
     453      PixelPtr.NextLine;
    456454    end;
    457455    Offscreen.EndUpdate;
Note: See TracChangeset for help on using the changeset viewer.