Einzelnen Beitrag anzeigen

MathiasSimmack
(Gast)

n/a Beiträge
 
#5

Re: Bitmap aus Ressource laden und anzeigen

  Alt 31. Aug 2005, 06:30
Zitat von Chakotay1308:
Hi Olli,
in .NET 2.0 geht das alles.
Endlich mal den Olli sprachlos sehen, das ist doch schon mal was ...

Zitat:
Ist sogar als Beispiel in der Hilfe angegeben (dort wird als Typ "typeof(Button)" verwendet, was aber nicht geht, weil er die Ressource nicht in der Button-Klasse gefunden hat).
Wo ist das Beispiel? Ich habe in der Hilfe mal gesucht. Meinst du das:
Code:
private void ConstructFromResourceSaveAsGif(PaintEventArgs e)
{

    // Construct a bitmap from the button image resource.
    Bitmap bmp1 = new Bitmap(typeof(Button), "Button.bmp");

    // Save the image as a GIF.
    bmp1.Save("c:\\button.gif", System.Drawing.Imaging.ImageFormat.Gif);

    // Construct a new image from the GIF file.
    Bitmap bmp2 = new Bitmap("c:\\button.gif");

    // Draw the two images.
    e.Graphics.DrawImage(bmp1, new Point(10, 10));
    e.Graphics.DrawImage(bmp2, new Point(10, 40));

    // Dispose of the image files.
    bmp1.Dispose();
    bmp2.Dispose();
}
In dem Fall kannst du den oberen Teil wohl beruhigt vergessen, weil es dann darum geht, eine Bitmap als Gif zu speichern. Interessant wird es erst ab
Code:
Bitmap bmp2
und da steht kein "typeof".
  Mit Zitat antworten Zitat