Autor Beitrag
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: So 02.04.06 17:18 
Hallo,

für mein Vier gewinnt benutze ich 42 Images. Nun will ich dieses "Gestell" darstellen, das wie ein Gitter aussieht. Dazu zeichne ich in jedes Image einen Rahmen. Die obere Leiste habe ich schon, bloß ich komme nicht mit den seitlichen Rahmen klar. (siehe Anhang)
Hier mein Code für die obere Leiste:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
with image1.canvas do
begin
  brush.color:=clskyblue;
  pen.color:=clskyblue;
  rectangle(0,0,image1.Width,10);
end;
Einloggen, um Attachments anzusehen!
_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
ultra2k
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

XP x64
D7 Enterprise
BeitragVerfasst: So 02.04.06 17:27 
Nimm doch ein Rechteck für das ganze Image, nicht nur für jede Seite

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
  with Image1 do
  begin
    Canvas.Pen.Width   := 5;
    Canvas.Pen.Color   := clskyblue;
    Canvas.Brush.Color := clBtnFace;
    Canvas.Rectangle(0,0,width,height);
  end;

Oder versteh ich das grad falsch?

_________________
...wenn NULL besonders groß ist, isses schon fast wie ein bisschen EINS!
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: So 02.04.06 17:34 
user profile iconultra2k hat folgendes geschrieben:
Oder versteh ich das grad falsch?

Nein machst du nicht ;)

Es muss allerdings so heißen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
with image1.canvas do
begin
    Pen.Width   := 10;
    Pen.Color   := clskyblue;
    Brush.Color := clBtnFace;
    Rectangle(0,0,image1.width,image1.height);
end;


Das Problem ist, dass dann zur Laufzeit auch noch Bilder reingeladen werden sollen. Wie verträgt sich das mit dem canvas? Kann man ein Bild laden, ohne dass das Canvas verschwindet?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Danniolo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 693



BeitragVerfasst: So 02.04.06 17:45 
ausblenden Delphi-Quelltext
1:
Image1.Canvas.Draw(x,y,Bild);					

Damit kannst du dein Bild darein zeichnen :roll:
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: So 02.04.06 17:47 
wenn dus mit .LoadFromFile('') machst isses weg, so müsste es da bleiben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var Ebene: TBitmap
begin
  Ebene:= TBitmap.Create;
  Ebene.TransparentColor:= clWhite;
  Ebene.Width:= Breite;
  Ebene.Height:= Breite;
  Ebene.LoadFromFile('bild.bmp');
  Image1.Canvas.Draw (x,y, Ebene);
end;


so wird einfach Ebene über das bestehende Bild drüber gemalt
du musst evtl. noch die transparente Farbe ändern, das sollte die hintergrund farbe des Bildes mit dem Stein sein


Zuletzt bearbeitet von Ironwulf am So 02.04.06 17:54, insgesamt 1-mal bearbeitet
ultra2k
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

XP x64
D7 Enterprise
BeitragVerfasst: So 02.04.06 17:49 
user profile iconMarco D. hat folgendes geschrieben:
Es muss allerdings so heißen:

Nein muss es nicht, das is geschmackssache...

Wenn du neue Bilder reinlädst dann mach dir doch ne Prozedur mit der du dann in dem geänderten bild den Rahmen neu zeichnest...

// EDIT: Oder so wie user profile iconIronwulf sagt... :)

// EDIT2: Oder du machst dir gleich 3 bilder, ein leeres Feld, eins mit nem Roten Stein, eins mit nem Gelben (ka welche Farben du nimmst) und switchst dann nur zwischen den 3 bilder hin und her... dann könntest du es sogar graphisch nochn bissel anspruchsvoller gestalten...
Einloggen, um Attachments anzusehen!
_________________
...wenn NULL besonders groß ist, isses schon fast wie ein bisschen EINS!
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mo 03.04.06 15:39 
Das sieht ja affengeil aus :zustimm:
Wie hast du das hinbekommen? Ist das auch mit canvas möglich?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Danniolo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 693



BeitragVerfasst: Mo 03.04.06 15:49 
Wahrscheinlich net, aber warte einen Moment, dann kann ich dir eine PNG-Datei zauber, die auch so ausieht und die kannst du dann halt mit canvas beliebig oft zeichnen. :wink:
ultra2k
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 82

XP x64
D7 Enterprise
BeitragVerfasst: Do 06.04.06 09:21 
user profile iconMarco D. hat folgendes geschrieben:
Das sieht ja affengeil aus :zustimm:
Wie hast du das hinbekommen? Ist das auch mit canvas möglich?

Ich hab jetz eigentlich gedacht du nimmst für jedes Loch, entweder leer, oder mit rotem bzw. gelben Chip ein Image...

Du kannst aber natürlich auch die informationen beispielsweise in einem 2-dimensionalem Array speichern und dann in ein großes TImage zeichnen, mit sowas in der richtung:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
var
  x, y, i, j: Integer;
  chipleer, chiprot, chipgelb: Bitmap;

{...}

  for i := 0 to 8 do     // breite
    for j:= 0 to 8 do    // höhe
      case daten[i, j] of
        0: Image1.Canvas.Draw(32*i, 32*j, chipleer);
        1: Image1.Canvas.Draw(32*i, 32*j, chiprot);
        2: Image1.Canvas.Draw(32*i, 32*j, chipgelb);
      end;


D.h. du speicherst einfach in einem array, an welcher stelle in deinem kästchensystem welcher chip sitzt und lässt das dann zeichnen. Allerdings musst du halt überprüfen, ob die spalte nich schon voll is, oder wie weit dein chip reinfällt, etc...

Übrigens, das bild von oben, hab ich in 1 minute in Photoshop zusammengeklickt, wenn du die Bitmaps, oder die psd datei haben willst, schreib mir ne PM.

_________________
...wenn NULL besonders groß ist, isses schon fast wie ein bisschen EINS!