Autor Beitrag
Hansi@OMG
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 304

Vista
Delphi 2006 Prof., Lazarus
BeitragVerfasst: Do 20.10.05 19:09 
Hallo,
wie kann ich auf einfachem Wege ein Logo beliebiger Größe und Jpeg in die rechte untere Ecke eines anderen Jpegs einfügen?
Egal auf welchem Weg.
Habs schon probiert das Zielbild in ein TImage zu laden und mit Canvas.draw das Logo aus einem TImage einzufügen, allerdings bringt Delphi dauernd Fehlermeldungen, von Wegen ungültiges Bitmap usw.

Bitte Hilfe!

_________________
Who doesn't know the Micrsoft developer "Mahatma Fatal Error"?
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Do 20.10.05 19:19 
hi das geht nur wenn beide bilder in BNP vorliegen.
sind es beides JPG musst du diese erst in ein BMP umwandeln

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var bmp: tbitmap;
jpg: tjpeg;
begin
  jpg := tjpeg.create;
  jpg.loadfromfile('bla.jpg');
  bmp := tbitmap.create;
  bmp.assign(jpg);
  image1.picture.assign(bmp);
  bmp.free;
  jpg.free;
end;


das selbe mit dem anderen da kannste aber statt picture.assign dann einfach mit BitBlt das image drauf kopieren bzw mit Canvas.draw

möglicherweise gehts auch einfacher ;)

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
Hansi@OMG Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 304

Vista
Delphi 2006 Prof., Lazarus
BeitragVerfasst: Do 20.10.05 19:50 
Das funktioniert nicht so wirklich, hier mein 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:
procedure TForm1.Button3Click(Sender: TObject);
var
i: integer;
logoimg : timage;
jpg,logojpg : tjpegimage;
bmp,logobmp : tbitmap;
begin
  //Logo initialisieren
  logoimg:=timage.Create(self);
  logojpg:=tjpegimage.Create;
  logobmp:=tbitmap.Create;
  logoimg.Picture.Assign(logobmp);



    for i:=0 to listbox1.Items.Count-1 do begin
      //Bild laden
      listbox1.ItemIndex:=i;
      jpg:=tjpegimage.Create;
      jpg.LoadFromFile(listbox1.items[i]);
      bmp:=tbitmap.Create;
      bmp.Assign(jpg);
      image1.Picture.Assign(bmp);
      bmp.free;
      jpg.Free;
      showmessage(inttostr(image1.Picture.Width-logoimg.Picture.Width)+'x'+inttostr(image1.Picture.Height-logoimg.Picture.Height));
      image1.Canvas.Draw((image1.Picture.Width-logoimg.Picture.Width),(image1.Picture.Height-logoimg.Picture.Height),logobmp);
      image1.Picture.SaveToFile(listbox1.Items[i]);
      
    end;
  logobmp.Free;
  logojpg.free;
  logoimg.Free;
end;


Zur Info, das Programm soll per Batch Logos auf Bilder einfügen.
Ich krieg aber immer noch verschiedenste JPEG Fehler von Delphi zurück.

_________________
Who doesn't know the Micrsoft developer "Mahatma Fatal Error"?
Lossy eX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1048
Erhaltene Danke: 4



BeitragVerfasst: Fr 21.10.05 10:17 
Du hast vor so eine Art Consolenanwendung zu schreiben? Warum dann eigentlich mit einem TImage arbeiten? TPicture sollte al deine Wünsche erfüllen. Folgender Code lädt ein Bild, ein Logo. Zeichnet das Logo in das Bild und speichert es als jpeg ab. Und alles ohne zusätzlichen Schnickschnack etc.
Mach was draus. ;-)

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:
procedure TForm1.Button1Click(Sender: TObject);
var
  Pic, Logo: TPicture;
  Jpg: TJPEGImage;
  Bmp: TBitmap;
begin
  // Bild laden
  Pic := TPicture.Create;
  try
    Pic.LoadFromFile('C:\Tools\Bilder\boiler_of_soul_by_Feni_x.jpg');

    // Logo Laden
    Logo := TPicture.Create;
    try
      Logo.LoadFromFile('C:\Tools\Bilder\7a9e8b0f97.jpg');

      // Temporäres Bild erstellen und Logo in Bild zeichnen
      Bmp := TBitmap.Create;
      try
        Bmp.Assign(Pic.Graphic);

        Bmp.Canvas.Draw(10, 10, Logo.Graphic);

        // als JPG Speichern
        Jpg := TJPEGImage.Create;
        try
          Jpg.Assign(Bmp);

          Jpg.SaveToFile('C:\blub.jpg');
        finally
          FreeAndNil(Jpg);
        end;
      finally
        FreeAndNil(Bmp);
      end;
    finally
      FreeAndNil(Logo);
    end;
  finally
    FreeAndNil(Pic);
  end;
end;

_________________
Nur die Menschheit ist arrogant genug, um zu glauben sie sei die einzige intelligente Lebensform im All. Wo nicht mal das nachhaltig bewiesen wurde.
Hansi@OMG Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 304

Vista
Delphi 2006 Prof., Lazarus
BeitragVerfasst: Sa 22.10.05 19:10 
Hat Super funktioniert, dank an alle.

_________________
Who doesn't know the Micrsoft developer "Mahatma Fatal Error"?