473,440 Members | 1,686 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,440 software developers and data experts.

transparency and .gif files

Hi,
I create a form, then place a picturebox on it.
Then I set the picturebox image to a .gif that I have
edited in GIFConstructionSet to create a transparent
background for. But when I run the code, what should be
transparent is not really transparent. Is there a property in
the picture box I need to tweak? I though the whole idea
was to put the transparency information right in the gif file.
Suggestions, clues, pointers?
Any of the above appreciated.
Thanks,
Al
Nov 23 '05 #1
7 2550
I think you may still need to set the transparency in the picture's properties.
eg
dim b as new bitmap(c:\pic.bmp)
b.maketransparent(b.getpixel(0,0))
Nov 23 '05 #2
Thanks for getting back Andrew.
I've tried the get pixel approach
dim b as new bitmap(c:\pic.bmp)
b.maketransparent(b.getpixel(0,0))
and while it makes it "transparent", I wind up seeing the underlying
form. So it shows up as gray.
Al

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Nov 23 '05 #3
I've had a lot of problems with transparency of forms, with things such as
transparency key not working for me as I would have expected. The below does
work for me, though, to display a small irregularly shaped form over a base
form containing a picturebox:

In the Form constructor:
....
dim DisplayImage as new bitmap(c:\...)
DisplayImage.MakeTransparent(DisplayImage.GetPixel (0,0))
FormBorderStyle = Windows.Forms.FormBorderStyle.None
Toplevel = False
Parent = BaseForm.PictureBox
....

Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
Dim bm As New Bitmap(Me.Width, Me.Height)
Dim g As Graphics = Graphics.FromImage(bm)
g.Clear(DisplayImage.GetPixel(0, 0))
bm.MakeTransparent(DisplayImage.GetPixel(0, 0))
g.Dispose()
BackgroundImage = bm
TransparencyKey = DisplayImage.GetPixel(0, 0)
e.Graphics.DrawImage(DisplayImage, 0, 0, ScaleWidth, ScaleHeight)
MyBase.OnPaint(e)
End Sub
Nov 23 '05 #4
Thanks Andrew, Time for me to watch some football, but will try your
code tomorrow.
Will let you know how I make out.
Al
--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Nov 23 '05 #5
Hi,

The transparent background will let the picture boxes background to
show through. I believe you want to see the form background instead. I
would draw the gif on the form in the forms paint event instead of using a
picturebox.

Ken
--------------
"Al_C" <ac****@bicnet.net> wrote in message
news:O8**************@TK2MSFTNGP09.phx.gbl...
Hi,
I create a form, then place a picturebox on it.
Then I set the picturebox image to a .gif that I have
edited in GIFConstructionSet to create a transparent
background for. But when I run the code, what should be
transparent is not really transparent. Is there a property in
the picture box I need to tweak? I though the whole idea
was to put the transparency information right in the gif file.
Suggestions, clues, pointers?
Any of the above appreciated.
Thanks,
Al

Nov 23 '05 #6
Hi Ken & Andrew,
My ultimate goal is to have an image moving around the screen.
So I need to be able to change its location based on the timer popping.
I was able to establish the transparencykey in the form constructor and
when then when the timer pops -

Me.PictureBox1.Location = New System.Drawing.Point(x, y)

Problem I have is that the transparency key applies to everything
including the form. And that it actually lets me see right through the
whole application all the way to the desktop ;) All I want is for it to
be transparent to the form.

First I can't make things transparent and now they are too transparent!!
;)
Al


--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Nov 23 '05 #7
Hi,
I finally have it almost working.
On program startup I read in the image I want from disk and establish the
transparency color. This works fine as long as I have a background color
for the form. But soon as I change from a background color to a background
image I get a picture box with a control color around my image.

Dim DisplayImage As New Bitmap("c:\b1.gif") 'on startup
outside the form construct

DisplayImage.MakeTransparent(DisplayImage.GetPixel (0, 0))
Me.PictureBox1.Image = CType(DisplayImage, System.Drawing.Image)

For now I have the last two lines hard coded in the form construct.

Then I have a timer_tick event that
x = x + 1
tick = tick + tick + x
y = 200 + Sin(tick) * 100 'just to get a rather up and
down y value
Me.PictureBox1.Location = New System.Drawing.Point(x, y) 'redraw the
picture box.

This works great as long as I don;t have an image as a background on the
form.

Any thoughts?

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uD**************@TK2MSFTNGP12.phx.gbl...
Hi,

The transparent background will let the picture boxes background to
show through. I believe you want to see the form background instead. I
would draw the gif on the form in the forms paint event instead of using a
picturebox.

Ken
--------------
"Al_C" <ac****@bicnet.net> wrote in message
news:O8**************@TK2MSFTNGP09.phx.gbl...
Hi,
I create a form, then place a picturebox on it.
Then I set the picturebox image to a .gif that I have
edited in GIFConstructionSet to create a transparent
background for. But when I run the code, what should be
transparent is not really transparent. Is there a property in
the picture box I need to tweak? I though the whole idea
was to put the transparency information right in the gif file.
Suggestions, clues, pointers?
Any of the above appreciated.
Thanks,
Al


Nov 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

57
by: Piotr Wolski | last post by:
how to make my page that it was correct with every browser standard? for example when i change HTML's table size it has no effect when i see it under mozilla and has effect under Internet...
20
by: Nathan Sokalski | last post by:
I am trying to create graphics with GDI+ that include transparency. However, the transparency never seems to show up, even though my colors have an alpha value of 0. How can I generate a graphic...
6
by: tommaso.gastaldi | last post by:
In a previous post I have been asking about a way to test Alpha Transparency. Bob and Michael have kindly provided some ideas. Here I would like to share the function I have prepared, for the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.