Jump to content

Recommended Posts

Posted

É evidente que a aparência de um programa é muito favorável para sua divulgação, sem entrar no mérito de "eficiência" pois sabemos que esse é o fator principal para para a sua utilização.

Gostaria de saber passos para se inserir uma imagem, a qual não seja "retangular", igual a imagem padrão dada de ponto inicial como "form1".

        System.Drawing.Bitmap Img = new System.Drawing.Bitmap(@"C:\...\SpongeBob.bmp") The color at Pixel(1,1) is rendered as transparent for the complete background.
    Img.MakeTransparent(Img.GetPixel(1,1))
    this.BackgroundImage = Img   
    this.TransparencyKey = Img.GetPixel(1,1)

Public Class Form1


End Class

Esse código permite que você crie uma forma irregular a partir de qualquer imagem bitmap.

'Fonte: TheScarms.com

Tentei inseri-lo mais ocorreu erros do tipo "Declaration expected", se alguem souber o motivo, ou novas maneiras de criar formas irregulares agradeço.

Posted

Boas

Se meteres o código dentro de um evento, se calhar funciona, não??  🙂 :)

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                System.Drawing.Bitmap Img =  new System.Drawing.Bitmap(@"C:\...\SpongeBob.bmp") The color at Pixel(1,1)  is rendered as transparent for the complete background.
        Img.MakeTransparent(Img.GetPixel(1, 1))
        this.BackgroundImage = Img
        this.TransparencyKey = Img.GetPixel(1, 1)
    End Sub

End Class

A informática chegou para resolver problemas que antes não existiam

Quem ri por último é porque está conectado a 52 Kbs.

Posted

Não, porque é C# 🙂

(e o sub handler do evento não é o evento)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Img As New Bitmap("c:\......\SpongeBob.bmp")

        Img.MakeTransparent(Img.GetPixel(0, 0)) 'supondo que este pixel é da cor que queres tornar transparente
        Me.BackgroundImage = Img
        Me.TransparencyKey = Color.Transparent
End Sub

Sérgio Ribeiro


"Great coders aren't born. They're compiled and released"
"Expert coders do not need a keyboard. They just throw magnets at the RAM chips"

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.