Autor Beitrag
Calyptus
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 386

Win Xp Prof
D3, D6 Pers, D7 Ent
BeitragVerfasst: Fr 09.12.05 22:01 
Hallo,

ich bin gerade dabei einen kleinen Level Editor für mein Spiel zu schreiben. Das Level ist auf einem 2-Dimensionalen Feld aufgebaut. Ich wollte dazu jetzt ein Image nehmen und auf dieses das Raster zeichnen.

Das klappt auch. Ich will jetzt das Image größenabhängig von Form1 machen. Das klappt jetzt nurnoch halbwegs :(

Wenn ich das Programm kleiner mache klappt alles wunderbar, mache ich es aber größer als es beim Starten war dann klapps nichtmehr. Es wird zwar größer (Image1.Width) aber ich sehe nur einen Teil davon (der eben genau so groß ist wie das Image am Anfang war)

Ich weiß wirklich nichtmehr weiter.....


Hier mal der Code:
ausblenden volle Höhe Delphi-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:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
var
  FelderX, FelderY, FelderW, FelderH: Integer;

[...]

procedure TForm1.DrawGrid;
var i: Integer;
begin
 FelderW := (GroupBox1.Width - 16) div FelderX;
 FelderH := (GroupBox1.Height - 24) div FelderY;

 Image1.Width := FelderW * FelderX + 1;
 Image1.Height := FelderH * FelderY + 1;

 Image1.Canvas.Brush.Color := clRed;
 Image1.Canvas.Brush.Style := bsSolid;
 Image1.Canvas.FillRect(Rect(0, 0, Image1.Width, Image1.Height));

 for i := 0 to FelderX do
  begin
   Image1.Canvas.MoveTo(i*FelderW, 0);
   Image1.Canvas.LineTo(i*FelderW, FelderH*FelderY);
  end;

 for i := 0 to FelderY do
  begin
   Image1.Canvas.MoveTo(0, i * FelderH);
   Image1.Canvas.LineTo(FelderW * FelderX, i* FelderH);
  end;

 Form1.Caption := IntToStr(Image1.Width) + ' | ' + IntToStr(Image1.Height);
end;

procedure TForm1.FormResize(Sender: TObject);
begin
 GroupBox2.Left := Form1.Width - GroupBox2.Width - 14;
 GroupBox3.Left := Form1.Width - GroupBox3.Width - 14;
 GroupBox1.Width := Form1.Width - GroupBox2.Width - 32;
 GroupBox1.Height := Form1.Height - 50;
 DrawGrid;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 FelderX := StrToInt(Edit1.Text);
 FelderY := StrToInt(Edit2.Text);
 DrawGrid;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 FelderX := 2;
 FelderY := 3;
end;

_________________
Luft- und Raumfahrtechnik an der Uni Stuttgart
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Fr 09.12.05 23:04 
Hallo,

da gab es hier vor kurzem einen Thread mit dem gleichen Problem :arrow:
Canvas.Width = Image.Width setzen?
soweit ich mich erinnern kann, mit Lösungsmöglichkeiten.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Calyptus Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 386

Win Xp Prof
D3, D6 Pers, D7 Ent
BeitragVerfasst: Fr 09.12.05 23:33 
Danke! Damit gehts :-)

Aber is es nicht ein bischen komisch das
ausblenden Delphi-Quelltext
1:
Image1.Width := 100					

nicht geht aber
ausblenden Delphi-Quelltext
1:
2:
Image1.Width := 100  
Image1.Picture.Bitmap.Width := Image1.Width;

?

Naja hauptsache es geht!

_________________
Luft- und Raumfahrtechnik an der Uni Stuttgart