AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi SetPixel - schnellere Variante
Thema durchsuchen
Ansicht
Themen-Optionen

SetPixel - schnellere Variante

Ein Thema von CReber · begonnen am 2. Feb 2005 · letzter Beitrag vom 2. Feb 2005
Antwort Antwort
Benutzerbild von CReber
CReber

Registriert seit: 26. Nov 2003
Ort: Berlin
343 Beiträge
 
Delphi 2006 Professional
 
#1

SetPixel - schnellere Variante

  Alt 2. Feb 2005, 12:07
Delphi-Quellcode:
procedure TSmoothlabel.Paint;
  var LTmpPic : TBitmap;
      LCountX, LCountY : Integer;
      LColor, LFontColor : TColor;
begin
  LTmpPic := TBitmap.Create;
  LTmpPic.PixelFormat := pf8bit;
  LTmpPic.Width := Width * fSmoothFactor;
  LTmpPic.Height := Height * fSmoothFactor;
  LTmpPic.Canvas.Font.Assign(Font);
  //LTmpPic.Canvas.Font.Color := clBlack;
  LTmpPic.Canvas.Font.Height := LTmpPic.Canvas.Font.Height * fSmoothFactor;
  LTmpPic.Canvas.TextOut(0, 0, Caption);
// Antialiasing(LTmpPic.Canvas, Rect(0, 0, LTmpPic.Width, LTmpPic.Height));
  BmpGBlur(LTmpPic, fSmoothFactor);

  // Hier ist die Geschwindigkeitsbremse denke ich ! Das Bild ist ja bereits Smooth aber es wird Pixel für
  // Pixel für Pixel gezeichnet
  LTmpPic.Canvas.StretchDraw(Rect(0, 0, Width, Height), LTmpPic);
  LFontColor := Font.Color;
  for LCountY := 0 to Height - 1 do begin
    for LCountX := 0 to Width - 1 do begin
      LColor := GetBlendColor(LFontColor, GetPixel(Canvas.Handle, LCountX, LCountY), GetRValue(GetPixel(LTmpPic.Canvas.Handle, LCountX, LCountY)));
      SetPixel(Canvas.Handle, LCountX, LCountY, LColor);
    end;
  end;


  LTmpPic.Free;
end;
Ich hab leider nicht wirklich einen Durchblick bei den ganzen BitBlt, MaskBlt, SetPixel Routinen und habe nun versucht, die Routine schneller zu gestalten. Leider hat das bisher kaum was gebracht und ich denke man kann das ganze durch die Verwendung von ScanLines verbessern:

Delphi-Quellcode:
  for LCountY := 0 to Height - 1 do begin
    for LCountX := 0 to Width - 1 do begin
      LColor := GetBlendColor(LFontColor, GetPixel(Canvas.Handle, LCountX, LCountY), GetRValue(GetPixel(LTmpPic.Canvas.Handle, LCountX, LCountY)));
      SetPixel(Canvas.Handle, LCountX, LCountY, LColor);
    end;
  end;

//nach

  for LCountY := 0 Height -1 do begin
    pScanLine := LTmpPic.ScanLine[LCountY];
  // und jetzt irgendwie zeichnen - aber davon hab ich keine Ahnung :/
Würde mich freuen, wenn mir jemand helfen könnte...
Christian Reber
  Mit Zitat antworten Zitat
Benutzerbild von CReber
CReber

Registriert seit: 26. Nov 2003
Ort: Berlin
343 Beiträge
 
Delphi 2006 Professional
 
#2

Re: SetPixel - schnellere Variante

  Alt 2. Feb 2005, 13:27
Also ich suche jetzt schon seid Stunden nach einer Lösung und dachte eigentlich das es hiermit funktionieren müsste, aber nix da Brauche Hilfe!

Delphi-Quellcode:
  LFontColor := Font.Color;
  BitBlt(LTmpPic.Canvas.Handle, // Vom Bitmap
         0,
         0,
         LTmpPic.Width,
         LTmpPic.Height,
         Canvas.Handle, // Auf das Control (TSmootLabel)
         0,
         0,
         SRCCOPY);

  {for LCountY := 0 to Height - 1 do begin
    for LCountX := 0 to Width - 1 do begin
      LColor := GetBlendColor(LFontColor, GetPixel(Canvas.Handle, LCountX, LCountY), GetRValue(GetPixel(LTmpPic.Canvas.Handle, LCountX, LCountY)));
      SetPixel(Canvas.Handle, LCountX, LCountY, LColor);
    end;
  end;}

  LTmpPic.Free;
Christian Reber
  Mit Zitat antworten Zitat
Elite-Koennen
(Gast)

n/a Beiträge
 
#3

Re: SetPixel - schnellere Variante

  Alt 2. Feb 2005, 15:00
Moin'!

Scanline verwende ich folgendermaßen:

[
procedure TForm1.FormClick(Sender: TObject);

type
TPixel = record
B,G,R:Byte;
end;

var
P:^TPixel;
x,y:Integer;

begin
Image1.Picture.Bitmap.LoadFromFile('Dateiname');
for y:=0 to Image1.Height-1 do
begin
P:=Image1.Picture.Bitmap.ScanLine[y];
for x:=0 to Image1.Width-1 do
begin
P.R:=Wert;
P.G:=Wert;
P.B:=Wert;
Inc(P);
end;
end;
end;
]

Hilft das ?
  Mit Zitat antworten Zitat
shmia

Registriert seit: 2. Mär 2004
5.508 Beiträge
 
Delphi 5 Professional
 
#4

Re: SetPixel - schnellere Variante

  Alt 2. Feb 2005, 15:25
Mit Scanline hat man Zugriff auf eine Zeile eines Bitmaps.
Ein Pixel benötigt im Speicher entweder
  • 1 Byte (bei 256 Farben)
  • 2 Byte (bei 65536 Farben)
  • 3 Byte (bei 24 bit Farben)
  • 4 Byte (bei 32 bit Farben)
Je nach Auflösung des Bitmaps muss man nun beim Schreiben & Lesen darauf Rücksicht nehmen.
Bei 256 Farben, kann man die Farbe nicht direkt angeben, sondern nur einen Farbindex in eine Palette.
Bei 65536 Farben ist der Zugriff auf die einzelnen Farbanteile (R,G,B) relativ kompliziert.
24 & 32 bit Farben lassen sich programmtechnisch leicht ansprechen.
Und jetzt lies mal weiter auf: http://www.dsdt.info/tutorials/bitmap/?page=2
Andreas
  Mit Zitat antworten Zitat
Antwort Antwort


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 11:47 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz