Autor Beitrag
huuuuuh
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Sa 06.11.10 00:22 
ich möchte in meiner anwendung eine png-Grafik bearbeiten, z.b. andere Grafiken hineinzeichnen oder Striche bzw. Schrift. da ich soetwas aber noch nie gemacht hab, hab ich keine Ahnung wie das geht. hab jetz damit angefangen, ein Objekt vom Typ Image zu erstellen, die grafik hineinzuladen und dann wieder abzuspeichern. das klappt soweit, aber beim bearbeiten läuft nix. hoffe, ihr könnt mir da helfen...
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 06.11.10 00:31 
Bearbeiten sollte eigentlich mit der Graphics-Klasse gehen. Instanzieren über Graphics.FromImage musst Du dann, IIRC.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
huuuuuh Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Sa 06.11.10 00:47 
war auch mein gedanke. das problem dabei ist allerdings das "zurückkonvertieren", welches ich zur zeit so mache:
ausblenden C#-Quelltext
1:
2:
Image Bild = new Bitmap(800,140, Grafik);
Bild.Save(sved.FileName);

das öffnen des Bildes mache ich so:
ausblenden C#-Quelltext
1:
2:
Bild = Image.FromFile(bgcd.FileName);
Grafik = Graphics.FromImage(Bild);

(Grafik : Graphics, Bild : Image, sved und bgcd sind SaveFileDialog- bzw. OpenFileDialog)
Bei dieser Methode wird nur eine transparente Fläche abgespeichert...
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 06.11.10 10:58 
Normalerweise musst Du bei der Benutzung von Graphics nichts zurückkonvertieren, sondern Du änderst das Bild, welches Du der Graphics-Klasse übergeben hast. Aber bitte die Using-Klausel bei Verwendung von Graphics, Image und Bitmap nicht vergessen ;-)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".

Für diesen Beitrag haben gedankt: huuuuuh
huuuuuh Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Sa 06.11.10 12:00 
ah. ohne das zurückkonvertieren gehts... zumindest bei dem einfügen von grafiken. was nich geht, ist das ändern der größe.also dass alles, was zu groß is, abgeschnitten wird. die gespeicherte grafik hat immer ihre ursprüngliche größe.
habs mit Graphics.SetClip(new Rectangle(00800140)); versucht, das scheint aber nix zu machen...
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Sa 06.11.10 12:26 
Erzeuge ein neues Bitmap-Objekt in der gewünschten Größe und kopiere das Image über Graphics.DrawImage dort hinein.

_________________
>λ=

Für diesen Beitrag haben gedankt: huuuuuh
huuuuuh Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Sa 06.11.10 13:49 
aber dann wird skaliert, nicht abgeschnitten. und eben das soll nicht passieren...
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4764
Erhaltene Danke: 1052

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Sa 06.11.10 14:12 
Hallo,

erstens gibt es auch diverse Überladungen von DrawImage, außerdem gibt es auch noch die beiden Methoden DrawImageUnscaled und DrawImageUnscaledAndClipped... da sollte wohl das passende für dich dabei sein -)

Für diesen Beitrag haben gedankt: huuuuuh
huuuuuh Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: Sa 06.11.10 17:33 
Vielen Dank bis jetz. Das Bild wird geladen, verkleinert und bearbeitet und das Endprodukt kann gespeichert werden... nur das bearbeiten funktioniert nicht richtig. alles, was ich zur Grafik hinzufüge, wird vergrössert...
IsNull
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 97
Erhaltene Danke: 11


VS 2010, C#, AHK
BeitragVerfasst: Mo 15.11.10 12:37 
ausblenden C#-Quelltext
1:
alles, was ich zur Grafik hinzufüge, wird vergrössert...					

Ohne Code deinerseits ist das eine ziemlich laue Aussage... wie soll man dir so helfen können?