Announcement

Collapse
No announcement yet.

Gif mit transparentem Hintergrund speichern

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Gif mit transparentem Hintergrund speichern

    Hallo Experten,<BR><BR>eigentlich dachte ich, dass das eine recht einfache Sache wäre mit Bitmap, Image und Graphics, aber ich bekomme es einfach nicht gebacken!<BR>Ich möchte einfach eine neue Bitmap erstellen, einen Text hineinmalen, den Hintergrund transparent setzen und so als Gif abspeichern. Verlange ich da zuviel? Hat jemand ein kurzes Beispiel? Das wäre Klasse - danke.<BR><BR>Viele Grüße Olaf

  • #2
    Hallo,

    beim folgenden Beispiel erhalte ich eine transpartente Grafik zurück:
    <pre>
    <font color="#003399"><i>// using System.Drawing.Drawing2D;</i></font>
    <font color="#003399"><i>// using System.Drawing.Imaging;</i></font>
    Bitmap aBmp = <b>new</b> Bitmap(100, 100, PixelFormat.Format32bppRgb);
    Graphics aG = Graphics.FromImage(aBmp);
    RectangleF aRect =<b>new</b> RectangleF(0, 0, 100, 100);
    Font aFont = <b>new</b> Font(<font color="#9933CC">&quot;Arial&quot;</font>, 24);
    SolidBrush aBrush = <b>new</b> SolidBrush(Color.Red);
    aG.DrawString(<font color="#9933CC">&quot;Test&quot;</font>, aFont, aBrush, aRect);
    aBmp.MakeTransparent();
    aBmp.Save(@<font color="#9933CC">&quot;C:\Temp\Test.png&quot;</font>);
    </pre&gt

    Comment


    • #3
      Hallo Herr Kosch,<BR><BR>viele Dank für Ihre Mühen. Nun es ist jetzt eine PNG- und keine GIF-Datei, das wäre noch nicht das größte Problem. Wenn ich mir die Grafik z.B. im MS Photo Editor ansehe, dann wird der transparente Hintergrund auch richtig dargestellt, allerdings nicht mehr im Internet Explorer, da hat die Grafik einen grauen Hintergrund und das ist nicht erwünscht - daher eigentlich auch der Wunsch nach GIF...! Aber ich bekomme einfach kein Graphics Object geliefert, wenn ein indiziertes Pixelformat vorliegt!?<BR>GIF geht wirklich nicht?<BR><BR>Vielen Dank Ola

      Comment

      Working...
      X