Announcement

Collapse
No announcement yet.

Infos zu Scanline

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Infos zu Scanline

    Hallo,

    ich suche möglichst ausführliche Informationen zu TBitmap.Scanline - möglichst etwas Gedrucktes. Muß auch nicht unbedingt zu Delphi sein.
    Danke. Gerhard.

  • #2
    Hallo Gerhard,<br> ich habe zwar nichts Gedrucktes für Dich, aber dafür habe ich einen TBitmap Nachfahren, der den Zugriff auf die Pixels Eigenschaft über Scanline realisiert. Das ist wesentlich schneller als über das Canvas Objekt. Der Code ist nicht von mir. Leider kann ich nicht mehr den Autor angeben, da ich nicht mehr weiß, wo im Internet ich das Ding gefunden habe.<br>
    <pre>
    unit QuickBitmap;

    interface

    Uses SysUtils, Graphics;

    Type
    TQuickBitmap = class(TBitmap)
    private
    FPixelFormat : TPixelFormat;
    protected
    function GetPixel(X,Y : Integer) : TColor;
    procedure SetPixel(X,Y : Integer; Color : TColor);
    public
    constructor Create; override;

    property Pixels[X,Y : Integer] : TColor
    read GetPixel
    write SetPixel;

    published
    property PixelFormat : TPixelFormat
    read FPixelFormat; //Readonly so that it is always pf24Bit
    end;

    implementation

    { TQuickBitmap }
    constructor TQuickBitmap.Create;
    begin
    inherited;
    FPixelFormat := pf24Bit;
    end;

    function TQuickBitmap.GetPixel(X, Y: Integer): TColor;
    var
    Col : TColor;
    ColBytes,
    Bytes : PByteArray;
    begin
    if (X < 0) or (X >= Width) or (Y < 0) or (Y >= Height) then
    raise Exception.Create('No such pixel');

    if inherited PixelFormat <> pf24Bit then inherited PixelFormat := pf24Bit;

    Col := clBlack;
    ColBytes := @Col;
    Bytes := ScanLine[Y];

    ColBytes[2] := Bytes[X*3];
    ColBytes[1] := Bytes[(X*3)+1];
    ColBytes[0] := Bytes[(X*3)+2];

    Result := Col;
    end;

    procedure TQuickBitmap.SetPixel(X, Y: Integer; Color : TColor);
    var
    Col : TColor;
    ColBytes,
    Bytes : PByteArray;
    begin
    if (X < 0) or (X >= Width) or (Y < 0) or (Y >= Height) then
    raise Exception.Create('No such pixel');

    if inherited PixelFormat <> pf24Bit then inherited PixelFormat := pf24Bit;

    Col := Color;
    ColBytes := @Col;
    Bytes := ScanLine[Y];

    Bytes[X*3] := ColBytes[2];
    Bytes[(X*3)+1] := ColBytes[1];
    Bytes[(X*3)+2] := ColBytes[0];
    end;

    end.
    </PRE>
    <BR>
    :-) Jens Schuman

    Comment


    • #3
      Hallo Jens, <p>
      besten Dank für die Info, und Entschuldigung fürs späte Reagieren. Ich hatte schon alle Hoffnung fahren lassen...<p>
      Gerhar

      Comment


      • #4
        Hallo,

        Ausführliche Beispiele zu der ScanLine-Eigenschaft (und Grafikalgorithmen ganz allgemein) in Delphi findest du unter der Webpage <b>http://www.efg2.com/Lab/ImageProcessing/Scanline.htm</b>.

        Gruß,<br>
        Bernhar

        Comment

        Working...
        X