Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi Schwarzanteil eines TImage ermitteln (https://www.delphipraxis.net/126656-schwarzanteil-eines-timage-ermitteln.html)

Landfloh 30. Dez 2008 09:53

Re: Schwarzanteil eines TImage ermitteln
 
Liste der Anhänge anzeigen (Anzahl: 1)
Bei mir bleibt der Wert auf Null.

Quellcode:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  i,j : Integer;
  blackCount: Integer;
begin
  blackCount := 0;
  for i:= 0 to image1.Picture.Bitmap.Height -1 do
    for j:=0 to image1.Picture.Bitmap.Width -1 do
     if image1.Picture.Bitmap.Canvas.Pixels[j,i] = clBlack then
       inc(blackCount);
       Label1.Caption := '';
       Label1.Caption := (IntToStr(blackCount));
end;

Klaus01 30. Dez 2008 09:55

Re: Schwarzanteil eines TImage ermitteln
 
Liste der Anhänge anzeigen (Anzahl: 1)
.. kannst Du das Bild mal anhängen

Grüße
Klaus

Landfloh 30. Dez 2008 09:59

Re: Schwarzanteil eines TImage ermitteln
 
Zitat:

Zitat von Klaus01
.. kannst Du das Bild mal anhängen

Grüße
Klaus

Bei dem Bild was du verwendest funktioniert es.
:wiejetzt:

Landfloh 30. Dez 2008 10:03

Re: Schwarzanteil eines TImage ermitteln
 
Achso.

Das Programm ließt nur den Schwarzanteil von Bitmaps.

Danke für eure Hilfe. Es leuft jetzt. :mrgreen:

Klaus01 30. Dez 2008 10:09

Re: Schwarzanteil eines TImage ermitteln
 
.. noch als Nachschlag:

Wenn ich das jpg lade verschwindet das Bild auch bei mir.
Ich habe den Code dann so angepasst, dann klappe es auch mit jpg.

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  i,j : Integer;
  blackCount: Integer;
  jpg : TJpegImage;
begin
  blackCount := 0;
  jpg := TJpegImage.Create;
  jpg.LoadFromFile('d:\unbenannt.jpg');
  image1.Picture.Bitmap.Assign(jpg);
  jpg.Free;
  for i:= 0 to image1.Picture.Bitmap.Height -1 do
    for j:=0 to image1.Picture.Bitmap.Width -1 do
     if image1.Picture.Bitmap.Canvas.Pixels[j,i] = clBlack then
       inc(blackCount);

  edit1.Text:=FloatToStr(blackCount/((i+1)*(j+1)));
end;
Grüße
Klaus


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:11 Uhr.
Seite 2 von 2     12   

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