Görselin Arka Planını ve Formu Transparent Şeffaf Yapma – Visual Studio c#

Tasarım

Forma tasarımına PictureBox ekleyin. İçine görsel olarak arka planı transparent olan animasyonlu gif’de ekleyebilirsiniz. İki buton ekleyin; biri form için diğeri eklenen resmin arka planını şeffaf yapmak için.

Form özelliklerini aşağıdaki gibi değiştirirseniz formunuz her zaman üstte ve tam ekran olacaktır. Eğer ekran koruyucu olarak kullanmak isterseniz uygulamanızı projedeki debug klasörü içindeki projenin *.exe dosyası uzantısını *.scr olarak değiştiriniz. Bu şekilde ekran koruyucu olarak da kullanabilirsiniz. Tabi ki butonları gizlemeyi unutmayın.

FormBorderStyle = None

TopMost = True

WindowState = Maximize

ShowIn TaskBar = False olarak düzenleyebilirsiniz.

Kodlama

    private void button1_Click(object sender, EventArgs e)
    {
      this.BackColor = Color.Green;
      this.TransparencyKey = Color.Green;
    }

    private void button2_Click(object sender, EventArgs e)
    {
      Bitmap bitmap0 = new Bitmap(pictureBox1.Image);
      var bt = MakeTransparent(bitmap0, Color.White, 5);
      pictureBox1.Image = bt;
    }

    private Bitmap MakeTransparent(Bitmap bitmap, Color color, int tolerance)
    {
      Bitmap transparentImage = new Bitmap(bitmap);

      for (int i = transparentImage.Size.Width - 1; i >= 0; i--)
      {
        for (int j = transparentImage.Size.Height - 1; j >= 0; j--)
        {
          var currentColor = transparentImage.GetPixel(i, j);
          if (Math.Abs(color.R - currentColor.R) < tolerance &&
            Math.Abs(color.G - currentColor.G) < tolerance &&
            Math.Abs(color.B - currentColor.B) < tolerance)
            transparentImage.SetPixel(i, j, color);
        }
      }

      transparentImage.MakeTransparent(color);
      return transparentImage;
    }
css.php
This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.