Einzelnen Beitrag anzeigen

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