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



BeitragVerfasst: So 01.02.04 16:53 
Hallo zusammen,
da ich für die Schule an einem eigenen Grafikformat arbeite, muss ich nun mit Delphi einen Encoder programmieren.
Leider bin ich ein kompletter Anfänger und schaffe es nichtmal ein Programm zu erstellen, bei dem man ein Bild (BMP, vielleicht noch JPG) auswählen kann, so dass das Programm dann Zugriss hat und ich meine Algorithmen loslassen kann.

Ich habe schon das ganz forum abgeklappert, aber niemand hatte diese einfache Frage! Oder weiss jemand, wo man ein gutes tutorial dazu findet?

Kann jemand helfen?
Big_Berny
Tomac
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 113

Win XP
D6 Ent
BeitragVerfasst: So 01.02.04 17:34 
Hi!

Lade das Bild einfach mit einem TOpenDialog in ein TImage, und zwar so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
uses jpeg;

{...}

procedure TForm1.Button1Click(Sender: TObject);
begin
if opd.execute then
 image1.Picture.loadfromfile(opd.filename);
end;

#
mfG
Tomac
DJ-DJ
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48

Win 98; Win XP Home
Delphi 6 Personal
BeitragVerfasst: So 01.02.04 17:35 
Tach. Also ein Beispiel:

Du setzt ein TImage[Zusätzlich], einen TButton und ein TOpenImageDialog[Dialoge] (oder OpenPictireDialog,w weiß ich jetzt net so auswendig) auf ein Formular.

In Das on-klick Ereignis des Buttons schreibst du dann
[delphi]If OpenImageDialog1.Execute Then
Image1.Picture.LoadFromFile(OpenImageDialog);
[/delphi]

Dann solltest du das Bild geladen haben (mit SaveToFile kann man speichern)
Dann hat die TImage Komponente noch andere Eigenschaften, wie

Strech: Das Bild wird auf die größe des TImage gestreckt;
AutoSize: Das TImage passt sich mit seiner Größe an die Größe des Bildes an... DAzu ist es besser, eine TScrollbox auf die Form zu setzten und das TImage dann in die Scrollbox, dann hast du Scrollbars, falls das Bild größer iost als die Form.

MFG David[/code]
Big_Berny Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: So 01.02.04 17:55 
Vielen Dank für euer schnelle Antwort!

So sieht der Code nach DJ-DJ aus:
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtDlgs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Image1: TImage;
    OpenPictureDialog1: TOpenPictureDialog;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
If OpenPictureDialog1.Execute Then
Image1.Picture.LoadFromFile(OpenPictureDialog);
end;

end.


In der If-Anweisung erhalte ich aber die Fehlermeldung: Undefinierter Bezeichner "OpenPictureDialog".

Hoffe ihr habt noch mal schnell Zeit...
Big_Berny
Big_Berny Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: So 01.02.04 18:05 
Hurra, habs selber geschafft! (Naja eigentlich hats Tomac schon gesagt :))
Es muss heissen:
Image1.Picture.LoadFromFile(OpenPictureDialog.filename);

Big_Berny