Hallo.
Ich habe ein kleines halbtransparentes Bitmap mit einem Tool erstellt und an die Button.Image-Eigenschaft zugewiesen. Das Bitmap wure dann auch ganz wie ich wollte, halbtransparent, auf dem Button dargestellt.
Wenn ich aber das Bitmap in einer ImageList speichere und die dann an die Eigenschaft Button.ImageList zuweise wird das Bitmap auch auf dem Button dargestellt aber die Transparenz ist weg.
Kann man überhaupt die Transparenz von Bitmaps in einer ImageList speichern?
Grüß
Hallo irek68,
besser spät als nie: Ich habe das mit einem transparentem GIF-Bild ausprobiert. Dieses blieb sowohl per Image- als auch per ImageList-Eigenschaft transparent. Man kann also "Transparenz" von Bitmaps in einer ImageList speichern.
herbivore
Hallo.
Ich habe es damals mit .png Dateien geschaft.
Mittlerweile mache ich die gleiche Sache in Java. Ist irgendwie besser 😉
Grüß
hallo...
jo, das Thema ist schon etwas länger aus, hab mich zuvor auch noch nie damit auseinander gesetzt, aber ich hab auch versucht mal ein Bild mit Transparenz in ein Form zu legen. Als ganz normale PictureBox ist das kein Problem, verwende ich das aber in einer ImageList, dann schaut das alles merkwürdig aus mit solch einem Blauen Rand.

Hier anbei nur noch mein Code, wobei ich eigentlich nicht viel daran geändert hab:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Grafik
{
/// <summary>
/// Zusammenfassung für Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.PictureBox pictureBox2;
private System.ComponentModel.IContainer components;
public Form1()
{
//
// Erforderlich für die Windows Form-Designerunterstützung
//
InitializeComponent();
pictureBox2.Image = imageList1.Images[0];
//
// TODO: Fügen Sie den Konstruktorcode nach dem Aufruf von InitializeComponent hinzu
//
}
/// <summary>
/// Die verwendeten Ressourcen bereinigen.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(24, 8);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(104, 112);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// imageList1
//
this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
this.imageList1.ImageSize = new System.Drawing.Size(100, 100);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// label1
//
this.label1.Location = new System.Drawing.Point(48, 120);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(64, 16);
this.label1.TabIndex = 2;
this.label1.Text = "pictureBox1";
//
// label2
//
this.label2.Location = new System.Drawing.Point(160, 112);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(128, 16);
this.label2.TabIndex = 3;
this.label2.Text = "pictureBox2/imageList1";
//
// pictureBox2
//
this.pictureBox2.Location = new System.Drawing.Point(160, 136);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(120, 120);
this.pictureBox2.TabIndex = 4;
this.pictureBox2.TabStop = false;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.Color.Firebrick;
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.pictureBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
Weiß einer vielleicht was ich da falsch mache?
Vielen Dank für euer Bemühen 🙂
Gruß
K2k