Q: Transparent image on a form

C

Cor Ligthert

Herfried,
I assume the OP wants to create a region from a bitmap.

And did you give him a sample from that, because I have more the idea that
he wants to use a bitmap as a region.

Cor
 
C

Cor Ligthert

Geoff
Yes, that's right.

I don't know what I did that you ignore me in this way, however when you
don't want my help than be so polite to answer that in an answer to me.

I will try to remember this in future and not bother you anymore.

Cor
 
H

Herfried K. Wagner [MVP]

Cor,

Cor Ligthert said:
And did you give him a sample from that, because I have more the idea that
he wants to use a bitmap as a region.

As always, there is no guarantee that I provide sample code.
 
H

Herfried K. Wagner [MVP]

Geoff,

Geoff Jones said:
Thanks for looking at this for me Herfried. Here is my VB version:

Very quick and dirty, but seems to work:

\\\
Private Function GetRegion( _
ByVal _img As Bitmap, _
ByVal color As Color _
) As Region
Dim _matchColor As Color = _
color.FromArgb(color.R, color.G, color.B)
Dim rgn As System.Drawing.Region = New Region
rgn.MakeEmpty()
Dim rc As Rectangle = New Rectangle(0, 0, 0, 0)
Dim inimage As Boolean = False
Dim x As Integer
Dim y As Integer
For y = 0 To _img.Height - 1
For x = 0 To _img.Width - 1
If Not (inimage) Then
If _
Not color.op_Equality(_img.GetPixel(x, y), _matchColor)
_
Then
inimage = True
rc.X = x
rc.Y = y
rc.Height = 1
End If
Else
inimage = False
rc.Width = _img.Width - rc.X
rgn.Union(rc)
End If
Next
If inimage Then
inimage = False
rc.Width = _img.Width - rc.X
rgn.Union(rc)
End If
Next
Return rgn
End Function
///
 
G

Geoff Jones

Hi Cor

I'm afraid I don't know what I've done to upset you. I haven't been ignoring
you! I don't mean to be rude but sometimes I don't fully understand what you
are trying to explain to me. Is it possible that you are also
misunderstanding what I am asking.

I'm sorry again and if you re-read any of my posts you will see that I have
not written anything in a rude manner or indeed ignored you!

Geoff
 
G

Geoff Jones

Many thanks Herfried, I will try your code (but first I'll try and
understand it - we live and learn eh?)

Many thanks

Geoff
 
H

Herfried K. Wagner [MVP]

Geoff Jones said:
Many thanks Herfried, I will try your code (but first I'll try and
understand it - we live and learn eh?)

Feel free to ask if something is not clear.
 
C

Cor Ligthert

Geoff,

You got from me very early a sample, that combined with the sample on MSDN
and that combined with the code Peter was providing you is in my opinion
more than you got now at least from Herfried.

See this thread at a certain moment you are only answering Herfried. Not
Peter, not Zhang, not me.

Therefore spending time for you is a little bit out of sense at least for
me.

Cor
 
G

Geoff Jones

Cor

Well, again I apologise but to "ignore" you was not intentional. As you can
see, the thread is large with branches in many areas. It also takes me a
long time to read through the code and understand what is going on.

Sadly it appears that even my earlier apology for not thanking you for the
code you sent has not been accepted. I have, in an earlier post, stated
"With your, and others help (ta Peter), it now works :)" BUT I shall now
thank, including yourself, for all your help in this matter. I'm very
grateful for the help I get on the steep learning code of learning VB.NET,
so again many thanks to:

Cor
Peter
Zhang
Herfried

and anybody else that takes up valueable time to help.

Geoff
 
G

Geoff Jones

Hi Herfried

Many thanks for the code Herfried. I've managed to get the application
working as I expected. The code did the trick.

Many thanks for your help.

Geoff
 
R

Ravichandran J.V.

For WindowsXP and Windows 2000 Go to the Control Panel and change the
Settings(to less than 32). Only then it will work.I assume that you have
set the FormTransparency Key property.

with regards,


J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com
 
G

Geoff Jones

Thank you Ravichandran. It does indeed work if you set the colour depth to,
for example, 16. However, as you'll see in the other posts there is a
"better" way using regions. Several users have kindly given code which shows
how this can be done.

Geoff
 
C

Cor Ligthert

Geoff,


It has nothing to do with "thank you",



You did not tell why the approaches we offered you did not fit.



While Peter's last message was in my opinion directly a correct one, did you
directly go on with communicating with Herfried when he came in this thread
and left us alone and even not react on the sample from Peter. At the end
you got an answer from Herfried basicly the same as Peters.



When you had answered me directly on my question "if you had tried my
sample", than I had as well directly told to take the approach of MSDN
sample, combined with mine, and in that the part of Peter.



However next time I will leave you for Herfried to answer your questions,
than this will not happen again. Our answers seem not good enough for you.



In addition, that has nothing to do with thank you.



Cor
 
G

Geoff Jones

Cor

I've looked through the tree again and accept what you are saying. I didn't
reply to Peter or yourself and for that I can only apologise. No excuse!
But, as I have so obviously offended you I'll try not to write to this
newsgroup again.

Geoff
 
C

Cor Ligthert

Geoff,

I am glad that you understand what I was writting, so I forget it and answer
your following questions again normally, I only wanted to show you that this
is not nice for people who wants to help.

Cor
 
H

Herfried K. Wagner [MVP]

Ravichandran J.V. said:
For WindowsXP and Windows 2000 Go to the Control Panel and change the
Settings(to less than 32). Only then it will work.I assume that you have
set the FormTransparency Key property.

There are thousands of users who don't run their machine with the required
color depth, so using 'TransparencyKey' for arbitrary shaped forms is not a
good idea.
 
H

Herfried K. Wagner [MVP]

Cor Ligthert said:
You got from me very early a sample, that combined with the sample on MSDN
and that combined with the code Peter was providing you is in my opinion
more than you got now at least from Herfried.

Your sample doesn't show how to create an arbitrary shaped form from a
bitmap/mask.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top