AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia [FillRect] Geht das schneller ?
Thema durchsuchen
Ansicht
Themen-Optionen

[FillRect] Geht das schneller ?

Ein Thema von EWeiss · begonnen am 3. Jan 2014 · letzter Beitrag vom 3. Jan 2014
 
Benutzerbild von jaenicke
jaenicke

Registriert seit: 10. Jun 2003
Ort: Berlin
9.960 Beiträge
 
Delphi 12 Athens
 
#4

AW: [FillRect] Geht das schneller ?

  Alt 3. Jan 2014, 21:59
Kleines Beispiel, mangels deiner Farbarrays einfach mit Graustufen als Beispielfarben:
Delphi-Quellcode:
var
  Background: TBitmap;
  ARect: TRect;
  CurrentPixelTop, CurrentPixelBottom: PRGBTriple;
  i, MostRightPixel: Integer;
begin
  Background := TBitmap.Create;
  try
    Background.PixelFormat := pf24bit;
    Background.Height := 48;
    Background.Width := 64;
    Background.Canvas.Brush.Style := bsSolid;
    Background.Canvas.Brush.Color := clFuchsia;
    ARect := Background.Canvas.ClipRect;
    Background.Canvas.FillRect(ARect);

    CurrentPixelTop := Background.ScanLine[0];
    CurrentPixelBottom := Background.ScanLine[Background.Height - 1];
    for i := 1 to Background.Width do
    begin
      CurrentPixelTop^.rgbtBlue := i * 4;
      CurrentPixelTop^.rgbtGreen := i * 4;
      CurrentPixelTop^.rgbtRed := i * 4;
      CurrentPixelBottom^ := CurrentPixelTop^;
      Inc(CurrentPixelTop);
      Inc(CurrentPixelBottom);
    end;

    MostRightPixel := Background.Width - 1;
    for i := 0 to Background.Height - 1 do
    begin
      Background.Canvas.Pixels[0, i] := i * 5 shl 16 + i * 5 shl 8 + i * 5;
      Background.Canvas.Pixels[MostRightPixel, i] := i * 5 shl 16 + i * 5 shl 8 + i * 5;
    end;
  finally
    Background.SaveToFile('c:\Temp\Test.bmp');
    Background.Free;
  end;
end;
// EDIT:
Alternativ, wenn du TColor-Werte direkt nutzen willst:
Delphi-Quellcode:
    Background.PixelFormat := pf32bit;
    [...]
    for i := 1 to Background.Width do
    begin
      CurrentPixelTop^ := i * 4 shl 16 + i * 4 shl 8 + i * 4;
      CurrentPixelBottom^ := CurrentPixelTop^;
      Inc(CurrentPixelTop);
      Inc(CurrentPixelBottom);
    end;
Sebastian Jänicke
AppCentral

Geändert von jaenicke ( 3. Jan 2014 um 22:03 Uhr)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:56 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz