Einzelnen Beitrag anzeigen

Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#24

AW: Prüfung eines Bitmaps auf Transparenz (gehts noch schneller)?

  Alt 22. Feb 2016, 12:34
Hab ne andere Idee:
Delphi-Quellcode:
function HasTransparentRGBAValues (const bm:TBitmap): Boolean;
var
  x, z: Integer;
  pixel: PRGBQuad;
  sum: Cardinal;
begin
  pixel := bm.Scanline[bm.Height-1];
  z := bm.Width * bm.Height;

  sum := 0;
  for x := 0 to z-1 do
  begin
    sum := sum + pixel^.rgbReserved;
    inc(pixel);
  end;

  Result := sum < (z * 255);
end;
Ob das schneller ist, ist natürlich die Frage weil die ganze Schleife durchlaufen muss.
Dafür spart man sich ggf. ne Menge Vergleiche. Ein Versuch ists Wert denke ich.
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."

Geändert von Neutral General (22. Feb 2016 um 12:44 Uhr)
  Mit Zitat antworten Zitat