Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15519

draw a transparented image to form background (vb.net)

$
0
0
Hi
I have a project that I have written about 90% of it.
This project is an image guessing project.
There is a black rectangle in which a circle is moving.
In this circle, a part of an image appears. And every time it moves, another part and so on.
It occurred to me to simplify this game by transparenting the black pixels of the image that correspond to the rectangle and recording the circle somewhere. Each time the circle is moved, I record another transparent image and save all these images on top of each other, and finally, a complete image is drawn, which is the sum of the images of the circles that the desired image is obtained.
The steps I did
1- I transferred the game image to Visual studio via webcam with emgu.cv (the code is inside a timer)
Code:

Imports Emgu.CV
Imports Emgu.CV.UI
Imports Emgu.CV.Structure

Public Class Form1
Dim takepic As New Capture
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
PictureBox1.Image = takepic.QueryFrame.ToBitmap
End Sub
End Class

2- I made the received image transparent.
Code:

       
PictureBox1.Image = takepic.QueryFrame.ToBitmap
Dim bm_label1 As New Bitmap(PictureBox1.Image)
bm_label1.MakeTransparent(Color.FromArgb(24, 53, 73))

3- and printed it in the form through a code I found in Google.
Code:

Dim gameGraphics As System.Drawing.Graphics = Me.CreateGraphics
gameGraphics.DrawImage(bm_lable1, 0, 0, PictureBox1.Image.Width, PictureBox1.Image.Height)

I wanted to use the picture box but I did not use it because the transparency is not printed.

NOW

the problem now is that the final image is not fully printed on the form (Left image (inside photo)). In the correct position, the image on the left and the image on the right should be the same size

Name:  Screenshot 2021-09-12 154940.jpg
Views: 47
Size:  19.1 KB
Attached Images
 

Viewing all articles
Browse latest Browse all 15519

Trending Articles