Autor Beitrag
Big_Berny
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Di 03.02.04 13:27 
Hallo zusammen,
hab da ne Frage:
Wenn ich in image1 ein JPEG-Bild öffne erscheint bei folgender Zeile
ausblenden Quelltext
1:
a:= getrvalue(colortorgb(image1.Canvas.Pixels[x,y]));					

die Fehlermeldung "Bild kann nur geändert werden, wenn es ein Bitmap enthält." und das Programm beendet sich.

Was muss ich ändern, dass es auch mit JPEG funktioniert? Ich ändere ja eigentlich gar nichts am Bild selbst.

Big_Berny
Simon Joker
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236
Erhaltene Danke: 1



BeitragVerfasst: Di 03.02.04 13:57 
versuchs mal so:
ausblenden Delphi-Quelltext
1:
a:= getrvalue(colortorgb(image1.Picture.Bitmap.Canvas.Pixels[x,y]));					

Greife auf das Bitmap zu, wenn du Bitmapdaten haben willst und nicht auf das Jpeg-Image.
Big_Berny Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Di 03.02.04 14:00 
Danke! Scheint zu funktionieren
Noch eine kleine Frage: Fangen die Bilder bei Pixel[0,0] oder bei Pixel[1,1] and?

Big_Berny
Big_Berny Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Di 03.02.04 14:50 
Funktioniert übrigens doch nicht!

Bei diesem Verfahren bekomme ich bei einem JPG-Bild zwar keine Fehlermeldung mehr, aber a ist immer 0!
ausblenden Delphi-Quelltext
1:
a:= getrvalue(colortorgb(image1.Picture.Bitmap.Canvas.Pixels[x,y]));					


Big_Berny
Simon Joker
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 236
Erhaltene Danke: 1



BeitragVerfasst: Mi 04.02.04 12:35 
Sorry, das mit dem immer null habe ich nicht mit bekommen.

Tues so, diesmal sicher:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure TForm1.BuLoadClick(Sender: TObject);
var
  jp :TJpegImage;
begin
  if OpenPictureDialog1.Execute then begin
    jp :=TJpegImage.Create;
    try
      jp.LoadFromFile(OpenPictureDialog1.FileName);
      jp.DIBNeeded;
      Image1.Picture.Bitmap.Assign(jp);
    finally
      jp.Free;
    end;
  end;
end;

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  ShowMessage(ColorToString(image1.Picture.Bitmap.Canvas.Pixels[x,y]));
end;


Das PixelArray von Bitmaps beginnt Obenlinks mit [0,0]. X ist die Horizontale nach rechts und Y die Vertikale nach unten.