PDA

View Full Version : حذف پس زمینه سفید در bitmap - vb.net



msali16
دوشنبه 23 آذر 1394, 11:18 صبح
سلام دوستان عزیز - من یک برنامه دارم مینویسم که نیاز دارم 2 عکس رو روی هم قرار بدم با استفاده از picturebox
الان من این کارو انجام دادم اما موقع ذخیره عکس دومی که روی عکس اول قرار میگیره پس زمینه سفید بهش داده میشه من میخوام این پس زمینه رو بردارم و تصویر بدون پس زمینه ذخیره بشه
اینم کدش
ممنون می شوم کمکم کنید


Private Sub SaveImage_Click(sender As Object, e As EventArgs) Handles SaveImage.Click


Dim iconimg As New Bitmap(PictureBox2.Width, PictureBox2.Height)
Dim Lbl1 As New Bitmap(Label1.Width, Label1.Height)

PictureBox2.DrawToBitmap(iconimg, PictureBox2.ClientRectangle)
Label1.DrawToBitmap(Lbl1, Label1.ClientRectangle)
Dim PB1 As New Bitmap(PictureBox3.Image)
Dim gr1 As Graphics = Graphics.FromImage(PB1)
Dim icg1 As Graphics = Graphics.FromImage(PB1)

icg1.DrawImage(iconimg, PictureBox2.Location.X, PictureBox2.Location.Y)

icg1.Dispose()
gr1.DrawImage(Lbl1, Label1.Location.X - 1, Label1.Location.Y - 1)

If ComboBox2.Text = "png" Then
TextSave.Filter = "PNG Files (*.png)|*.png"
End If
Dim xxx As String
Dim namenumber As Integer
namenumber = 0
xxx = TextBox2.Text
TextSave.FileName = xxx & "_"
If TextSave.ShowDialog = Windows.Forms.DialogResult.OK Then
If ComboBox2.Text = "png" Then
TextSave.Filter = "PNG Files (*.png)|*.png"
PB1.Save(TextSave.FileName(), ImageFormat.Png)
End If
End If
iconimg.Dispose()
Lbl1.Dispose()
PB1.Dispose()

End Sub

boveiryghasem
سه شنبه 24 آذر 1394, 10:44 صبح
اون لینک اول رو ببین حتما دقیقا همین کار رو کرده.

http://www.vb-helper.com/howto_net_drag_image2.html

http://stackoverflow.com/questions/392257/transparency-for-images-in-visual-basic-net
https://social.msdn.microsoft.com/Forums/vstudio/en-US/e097486f-7e53-4177-9f7b-e22437287608/overlapping-transparent-images-in-vbnet?forum=vbgeneral (http://stackoverflow.com/questions/392257/transparency-for-images-in-visual-basic-net https://social.msdn.microsoft.com/Forums/vstudio/en-US/e097486f-7e53-4177-9f7b-e22437287608/overlapping-transparent-images-in-vbnet?forum=vbgeneral http://www.vb-helper.com/howto_net_maketransparent.html)
http://www.vb-helper.com/howto_net_maketransparent.html