473,659 Members | 2,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transparent Bitmap Drawn onto Transparent control

Hi there,

I have a usercontrol that inherits from Windows.Forms.B utton.

In the OnCreateControl method I set the style of the control so that it supports transparent backcolor and set the background color to transparent.

.....

Protected Overrides Sub OnCreateControl ()

MyBase.OnCreate Control()

Call SetStyle(Contro lStyles.Support sTransparentBac kColor, True)

BackColor = Color.Transpare nt

End Sub

.....

I have an image with magenta sections which I remove using Bitmap.MakeTran sparent(Color.M agenta). Unfortunately when I draw this image onto the form the parts that were previously magenta, get drawn as black.

My question is, how do I draw this image with the magenta parts as transparent?

Many thanks in advance.

Nick.

Jul 10 '07 #1
3 4865
Hi again,

I've changed the transparent initialisation and moved it to the
CreateParams override,

Protected Overrides ReadOnly Property CreateParams() As
System.Windows. Forms.CreatePar ams
Get
Dim pCPsParams As CreateParams = MyBase.CreatePa rams()
pCPsParams.ExSt yle = pCPsParams.ExSt yle Or &H20
Return (pCPsParams)
End Get
End Property

I am also overriding OnPaintBackgrou nd so that no background is drawn.
Unfortunately I still get black bits...

Nick.

"NickP" <a@a.comwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Hi there,

I have a usercontrol that inherits from Windows.Forms.B utton.

In the OnCreateControl method I set the style of the control so that it
supports transparent backcolor and set the background color to transparent.

.....

Protected Overrides Sub OnCreateControl ()
MyBase.OnCreate Control()
Call SetStyle(Contro lStyles.Support sTransparentBac kColor, True)
BackColor = Color.Transpare nt
End Sub
.....

I have an image with magenta sections which I remove using
Bitmap.MakeTran sparent(Color.M agenta). Unfortunately when I draw this image
onto the form the parts that were previously magenta, get drawn as black.
My question is, how do I draw this image with the magenta parts as
transparent?
Many thanks in advance.
Nick.
Jul 11 '07 #2
I have changed my image to a PNG with the transparent parts in already.
Unfortunately I am getting the same issues,

My drawing routine contains the following code,

Call pevent.Graphics .Clear(Color.Fr omArgb(255, 0, 0, 0))

Call pevent.Graphics .DrawImage(butt onMap, _
New Rectangle(0, 0, Width, Height), _
getCurrentFrame SourceRect(), _
GraphicsUnit.Pi xel)

It seems that there is no way to clear the surface before redrawing as it
just comes out as black. How do I completely remove all colour information
from the back before redrawing? Ideally |I want to do this all to a back
buffer then redraw that, but at current I can't get it working either way.

Thanks for any help in advance.

Nick.
"NickP" <a@a.comwrote in message
news:ef******** ******@TK2MSFTN GP02.phx.gbl...
Hi again,

I've changed the transparent initialisation and moved it to the
CreateParams override,

Protected Overrides ReadOnly Property CreateParams() As
System.Windows. Forms.CreatePar ams
Get
Dim pCPsParams As CreateParams = MyBase.CreatePa rams()
pCPsParams.ExSt yle = pCPsParams.ExSt yle Or &H20
Return (pCPsParams)
End Get
End Property

I am also overriding OnPaintBackgrou nd so that no background is drawn.
Unfortunately I still get black bits...

Nick.

"NickP" <a@a.comwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Hi there,

I have a usercontrol that inherits from Windows.Forms.B utton.

In the OnCreateControl method I set the style of the control so that it
supports transparent backcolor and set the background color to
transparent.

....

Protected Overrides Sub OnCreateControl ()
MyBase.OnCreate Control()
Call SetStyle(Contro lStyles.Support sTransparentBac kColor, True)
BackColor = Color.Transpare nt
End Sub
....

I have an image with magenta sections which I remove using
Bitmap.MakeTran sparent(Color.M agenta). Unfortunately when I draw this
image onto the form the parts that were previously magenta, get drawn as
black.
My question is, how do I draw this image with the magenta parts as
transparent?
Many thanks in advance.
Nick.

Jul 11 '07 #3
Hi again,

Okay I finally have it drawing correctly, but by inheriting from Panel
rather than Button, so it's not ideal tbh...

Nick.

"NickP" <a@a.comwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
>I have changed my image to a PNG with the transparent parts in already.
Unfortunatel y I am getting the same issues,

My drawing routine contains the following code,

Call pevent.Graphics .Clear(Color.Fr omArgb(255, 0, 0, 0))

Call pevent.Graphics .DrawImage(butt onMap, _
New Rectangle(0, 0, Width, Height), _
getCurrentFrame SourceRect(), _
GraphicsUnit.Pi xel)

It seems that there is no way to clear the surface before redrawing as it
just comes out as black. How do I completely remove all colour
information from the back before redrawing? Ideally |I want to do this
all to a back buffer then redraw that, but at current I can't get it
working either way.

Thanks for any help in advance.

Nick.
"NickP" <a@a.comwrote in message
news:ef******** ******@TK2MSFTN GP02.phx.gbl...
>Hi again,

I've changed the transparent initialisation and moved it to the
CreateParams override,

Protected Overrides ReadOnly Property CreateParams() As
System.Windows .Forms.CreatePa rams
Get
Dim pCPsParams As CreateParams = MyBase.CreatePa rams()
pCPsParams.ExSt yle = pCPsParams.ExSt yle Or &H20
Return (pCPsParams)
End Get
End Property

I am also overriding OnPaintBackgrou nd so that no background is drawn.
Unfortunatel y I still get black bits...

Nick.

"NickP" <a@a.comwrote in message
news:%2******* *********@TK2MS FTNGP02.phx.gbl ...
Hi there,

I have a usercontrol that inherits from Windows.Forms.B utton.

In the OnCreateControl method I set the style of the control so that
it supports transparent backcolor and set the background color to
transparent.

....

Protected Overrides Sub OnCreateControl ()
MyBase.OnCreate Control()
Call SetStyle(Contro lStyles.Support sTransparentBac kColor, True)
BackColor = Color.Transpare nt
End Sub
....

I have an image with magenta sections which I remove using
Bitmap.MakeTra nsparent(Color. Magenta). Unfortunately when I draw this
image onto the form the parts that were previously magenta, get drawn as
black.
My question is, how do I draw this image with the magenta parts as
transparent?
Many thanks in advance.
Nick.


Jul 11 '07 #4

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

Similar topics

2
8302
by: Jaikumar | last post by:
Hi, 1) I have created one windows application, In the main form ( form1) i have added one usercontrol (usercontrol1), In that user control i am drawing one image. 2) In the UserControl1 i am showing one transparent form (form3) when ever user preseed left mouse button. 3) The form3 has one transparent user control (usercontrol2) that paints circles. That measn the circles will show on top the usercontrol1 image. 4) The form3 border style...
3
3099
by: Steve Koon | last post by:
Any thoughts on getting this project to work or suggesting another method would be appreciated. Steve ========================================== Project: A Windows Form which acts as a Whiteboard. The Form contains 3
7
3576
by: Peter Oliphant | last post by:
Using MakeTransparent one can supposedly turn a color used in a Bitmap to transparent. But, it looks to me like all it does it set these pixels to the color BackColor of the Control it's attached to. Thus, when I set White to the transparent color of a Bitmap stored in the Image of a PictureBox and placed the PictureBox on a Form which has a BackColor of black, it turned the white pixels of the bitmap image to black, but these black pixels...
5
6456
by: Mark Deibert | last post by:
I'm a former VB6 coder. Quit a few years ago. Now I'm back and trying to teach myself VB.NET. I don't remember having this much difficulty learning VB6. I'm totally stuck on something and need your expert guidance. I just want to load a GIF with a transparent background into a container with a transparent background. So I can move the GIFs over and under each other. You know, as in basic game stuff. I can load the transparent GIF no...
4
2757
by: Brian Henry | last post by:
I have an icon I want to draw onto the screen, but I want to streatch it out to be about 256x256 and make it about 75% transparent how would I go about this? do i need to convert it to a bitmap first then paint it larger? and how would i make the entire image transparent at 75% transparency (25% opaque) thanks!
7
20202
by: Martin | last post by:
I'm using the code show below (in VB.Net 2003) to create an image. I want to save this image to a .PNG file such that when I subsequently display it as part of a web page, the background of the image will be transparent. This test/learning code simply draws a diagonal green line across a square box. When I display the resulting file on a web page, I want only the line itself to be visible but what is happening is that the entire "box"...
5
23895
by: Dale | last post by:
When I create a System.Drawing.Bitmap and save it as ImageType.GIF, how can I set the transparency so that the background is transparent. In my application, the Bitmap that I am working with has several transparent GIFs drawn on it and the transparency of each of them works within the bitmap, but the bitmap overall gets saved with a black background. Any help is greatly appreciated.
8
10162
by: Brian Ward | last post by:
I am looking for a simple way to set the image transparency in a PictureBox. I have a moving PictureBox containing a graphic image .. moving by incrementing its Left property. The background however shows white as the PictureBox moves but I want it to be transparent. The PictureBox BackColor is set to Transparent .. but no affect. I have used PhotoShop to make the image background transparent .. again no affect. If I make the image a...
0
2863
by: MasterOfTheDark | last post by:
This one's a hairy one to explain. What I've got is a class called "VistaGroupBox" that I put some nice-looking Vista-style gradients in the background and made to look like the ribbon categories you see in Office 2007. I got it working great, and created a few more controls, including a "VistaButton", which is primarily transparent when the cursor does not hover over it. However, when I added a standard Panel in the VistaGroupBox and put my...
0
8427
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8746
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8525
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.