Click here to Skip to main content
12,298,379 members (44,324 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
Hello Everyone,

This is my first question on this website...probably the first one regarding VB.NET on the internet Big Grin | :-D

I am a newbie and want to learn vb.net.

I have made a couple of programs which handle Photoshop and various apps which crop images, take snapshots etc.

What I now want to do is create an application in which I can manipulate images.
Here is what I want to do exactly:
1) I have a canvas which is is huge like 2048,2048.
2) I would like to have multiple images on it and have a layer system like photoshop.
3) I can do it wil multiple pictureboxes, where I am getting stuck is making the picturebox transparent to show what is beneath it.
4) eg: I have 2 overlapping pictureboxes. I would like to make the upper one transparent to an extent like 50% to see the below one.
5) How to start solving this issue? GDI+? what do I need to refer to?

Thanks and Regards
-Videep
Posted 6-Aug-12 1:29am
Comments
videepmishraa 7-Aug-12 7:20am
   
Thank You Aarti.

I am attaching a code that I just wrote. I have a picture box in the form named and two radio buttons. I ahve'nt changed their names.

What this does is:
with radio button 1 checked, you can draw any number of rectangles on the picturebox.

with radio button 2 checked, you can move the last drawn rectangle.

This process might be too memory consuming according to me as when I am moving the image, I am drawing the rectangles first and then moving the last rectangle on the mouse move event.
I just realised that I can skip the re-drawing of the rectangles when radio button 1 is checked.

What I want to know is if its much memory consuming? as this is only on page1(form1) and I have multiple forms.

And what if I have to edit the first rectangle? Do I need to make a listbox and do a 1 to 1 Marking of the rectangles to the items on the listbox?
Then draw all the rectangles?

-Videep

--CODE--



[code]
<pre lang="vb">Public Class Form1

Dim painting = False
Dim start As New Point(0, 0)
Dim _end As New Point(0, 0)
Dim r As New Rectangle(0, 0, 100, 100)
Dim rectArray As New List(Of Rectangle)
Dim first = True
Dim rec As Rectangle


Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
painting = True
start = e.Location
End Sub

Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If (painting) Then
Dim g As Graphics = PictureBox1.CreateGraphics

If (RadioButton1.Checked) Then
g.Clear(PictureBox1.BackColor)
For i = 0 To rectArray.Count - 1
rec = rectArray.Item(i)
g.FillRectangle(Brushes.RosyBrown, rec)
Next
r.X = start.X
r.Y = start.Y
r.Width = e.Location.X - start.X
r.Height = e.Location.Y - start.Y
g.FillRectangle(Brushes.RosyBrown, r)
Else
g.Clear(PictureBox1.BackColor)
For i = 0 To rectArray.Count - 2
rec = rectArray.Item(i)
g.FillRectangle(Brushes.RosyBrown, rec)
Next

r.X = e.X
r.Y = e.Y
g.FillRectangle(Brushes.RosyBrown, r)
End If
End If
End Sub

Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
painting = False
If (RadioButton1.Checked) Then
rectArray.Add(r)
End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.DoubleBuffered = True
End Sub
End Class</pre>


[/code]
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Img.MakeTransparent(color.Black)

Happy Coding!
Smile | :)
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

to make transparent of image in picture box you should use ALPHA
<pre lang="vb">
 
If b IsNot Nothing Then
                b.Filters.Alpha(CByte((20 / 100) * 255))
                bpImage.BackgroundImage = Nothing
                bpImage.BackgroundImage = b
End If
<b></b></pre>
 
with minor changes in values
where b refers to picture box
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160525.2 | Last Updated 10 Apr 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100