Autor Beitrag
Herr Bananerama
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 130



BeitragVerfasst: Do 14.02.08 20:31 
Hallo erstmal

Ich weiß das Thema gabs hier schonmal aber es wurde nicht wirklich geklärt. Und bei mir tritt jetzt das gleiche Problem auf!!!

Hier mein Code:
ausblenden Delphi-Quelltext
1:
 if   (Canvas.Pixels[k,l]) <> clWhite then  begin Result := false;  exit end					


Wenn Zur Laufzeit Zeigt Pixels immer -1 an !!!
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Do 14.02.08 20:36 
Was für ein Canvas?

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Do 14.02.08 20:38 
Ist k eine Laufvariable? Wie schaut Dein Bild aus? Etwas mehr Infos wären recht angebracht.

edit: Das ist ja ein "L" und keine Eins. Dein Bild ist nicht vollständig weiß? Hatte den Code erst aus Müdigkeit falsch interpretiert. :?


Zuletzt bearbeitet von Marc. am Do 14.02.08 20:46, insgesamt 3-mal bearbeitet
Herr Bananerama Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 130



BeitragVerfasst: Do 14.02.08 20:45 
Ouh Schuldigung hab die Details vergessen:


Das Canvas ist von einem TImage und auf diesem wurde gezeichnet. k und l sind lokale Integer Variablen. Ich möchte damit prüfen ob der Pixel[k,l] nicht die Farbe clWhite hat.
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Do 14.02.08 20:46 
Teste mal

ausblenden Delphi-Quelltext
1:
Image.Picture.Bitmap.Canvas[...]					

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Herr Bananerama Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 130



BeitragVerfasst: Do 14.02.08 20:56 
user profile iconKroko hat folgendes geschrieben:
Teste mal

ausblenden Delphi-Quelltext
1:
Image.Picture.Bitmap.Canvas[...]					


Danach klappt es immernoch nicht.
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Do 14.02.08 20:57 
Der Canvas des Images ist immer abhängig davon, ob dein Fenster gerade angezeigt wird. Diese Zeichenfläche solltest du deshalb lieber nicht abfragen, sondern - wie user profile iconKroko bereits erwähnte - etwas weiter reingehen.

Es reicht aber, wenn du auf Image1.Picture.Graphic zugreifst, diese Grafik ist auch verfügbar, wenn du keine Bitmap hast.
Herr Bananerama Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 130



BeitragVerfasst: Do 14.02.08 21:15 
user profile iconYogu hat folgendes geschrieben:
Der Canvas des Images ist immer abhängig davon, ob dein Fenster gerade angezeigt wird. Diese Zeichenfläche solltest du deshalb lieber nicht abfragen, sondern - wie user profile iconKroko bereits erwähnte - etwas weiter reingehen.

Es reicht aber, wenn du auf Image1.Picture.Graphic zugreifst, diese Grafik ist auch verfügbar, wenn du keine Bitmap hast.


Wenn ich Image1.Picture.Graphic.Canvas.Pixels mache dann meckert der Compiler und beschimpft Canvas und Pixels als undefinierten Bezeichner. Oder habe ich das falsch verstanden???
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Do 14.02.08 21:16 
(a) Graphic hat imho keine Canvas
(b) Was hast Du denn für ein Bildformat geladen (bmp jpg etc)?

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Herr Bananerama Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 130



BeitragVerfasst: Do 14.02.08 21:28 
user profile iconKroko hat folgendes geschrieben:
(a) Graphic hat imho keine Canvas
(b) Was hast Du denn für ein Bildformat geladen (bmp jpg etc)?



Wie gesagt ich hab auf das Image gezeichnet mit LineTo und so !!! Kein Bild!!! Sorry wenn das nicht klar geworden ist, aber ich dachte wenn ich sage zeichnen ... naja tut mir leid
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Do 14.02.08 21:31 
Dann erstelle eine Bitmap
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
var
  B: TBitmap;
begin
  B := TBitmap.Create;
  B.Width := 400;
  B.Height := 300;
  B.PixelFormat := pf24Bit;
  //
  // zeichnen
  //
  Image1.Picture.bitmap.Assign(B);
  //
  // test mit B.Canvas.Pixels
  B.Free;
end;

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Herr Bananerama Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 130



BeitragVerfasst: Do 14.02.08 21:44 
Ich hab das zeichnen in anderen proceduren und das muss auch in anderen proceduren sein ... und zwar in mehreren. Wenn ich in jeder das mache was du geschrieben hast sieht man nurnoch ein Weißes Image auf dem eigentlich ein Auto zu sehen sein sollte. ;)

Zeichnen muss man auf das Canvas von der Bitmap also b.Canvas? Also so hab ichs gemacht.
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Do 14.02.08 21:47 
(a) entweder zu zeigst mehr Quellen oder
(b) erstelle das Bitmap als Variable der Form, dann kannst in allen Form-Prozeduren auf das Bitmap zugreifen

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Herr Bananerama Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 130



BeitragVerfasst: Do 14.02.08 21:57 
Ist doch kein weißes Bild mehr ... hatte einen kleinen unwichitigen Fehler. Ich könnte Hier kaum den ganzen Code eingeben weil der Recht Umfangreich ist aber hier mal zumindest die ganze procedure:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
function TAuto.VorneFreiImg;
var i,j,k,l: Integer;
begin
  Result := true;
  if (Top < ( H.Top + H.Height ))
     and (( Top + Height) > H.Top )
     and (( Left + Width) > H.Left )
     and ( Left < ( H.Left + H.Width )) then
      For i := h.Top To (h.Top + h.Height) do
        For j := h.Left to (h.Left + h.Width) do
          For k :=  Left to (Left + Width) do
            For l := Top To (Top + Height) do
              if (i = l) and (k = j) then
                if  ( Picture.Bitmap.Canvas.Pixels[ k,l]) <>  clwhite then begin 
                  Result  := false;   exit end
end;


ist eine Prozedure um zu gucken ob sich ein Hindernis vor hinter oder neben dem Auto befindet. TAuto ist abgeleite von TFahrzeug. TFahrzeug von TImage. Übrigens Danke das ihr/du vorallem Kroko eu so bemüht!
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Do 14.02.08 22:02 
Überdenke mal Dein Konzept, sonst bekommst Du Geschwindigkeitsprobleme und anderes ohne Ende, die Proc ist der Hammer, :wink:

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Freiberger
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

WIN XP
Delphi 7
BeitragVerfasst: Do 14.02.08 22:12 
schonmal mit scanline versucht ? ist wesentlich schneller...
Herr Bananerama Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 130



BeitragVerfasst: Do 14.02.08 22:12 
user profile iconKroko hat folgendes geschrieben:
Überdenke mal Dein Konzept, sonst bekommst Du Geschwindigkeitsprobleme und anderes ohne Ende, die Proc ist der Hammer, :wink:


Ich hatte hier schonmal gefragt wie das anders geht aber es kam kein vorschlag außer irgendwelche wo man nur die Rects auf Kolision prüft. Aber ich hab in dem image ein Auto das sich dreht deswegen kann ich das nicht gebrauchen ;). Übrigens das Problem ist immernoch da. dat is zum Kotzen ^^ :puke:
Herr Bananerama Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 130



BeitragVerfasst: Do 14.02.08 22:18 
user profile iconFreiberger hat folgendes geschrieben:
schonmal mit scanline versucht ? ist wesentlich schneller...


Wie meinst du das mit Scanline?
Freiberger
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

WIN XP
Delphi 7
BeitragVerfasst: Do 14.02.08 22:22 
suche mal im Forum nach scanline.
damit wird das Bild über einen Pointer abgefragt.

Mit scanline mach man schnelle Grafikroutinen, zb spiegeln, in Graustufen umwandeln oä.

Damit kannst du auch sehr schnell die Farbe eines Pixels abfragen
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Do 14.02.08 22:22 
Delphi-Online-Hilfe:


ScanLine (Eigenschaft von TBitmap)

Die Eigenschaft ScanLine ermöglicht einen indizierten, zeilenweisen Zugriff auf Pixel.

Delphi-Syntax:
property ScanLine[Row: Integer]: Pointer;

Beschreibung
ScanLine wird nur bei DIBs (Device Independent Bitmaps) für Bildbearbeitungsprogramme verwendet, die Low-Level-Operationen auf Pixelebene durchführen.