473,856 Members | 1,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Grphics: How to draw an image transparent

Hi,

I have an Image that is drawn with Graphics.DrawIm age(..). What I want
to do is drawing it with a given transparency, e.g. at an alpha of only
180 instead of 255.

How am I doing that?!?!?

Regards,
Felix
Nov 16 '05 #1
6 3991
Read the Beginners Guide to GDI+.

Google for it...

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"felix" <fe***@news.com > wrote in message
news:ut******** ******@TK2MSFTN GP15.phx.gbl...
Hi,

I have an Image that is drawn with Graphics.DrawIm age(..). What I want to
do is drawing it with a given transparency, e.g. at an alpha of only 180
instead of 255.

How am I doing that?!?!?

Regards,
Felix

Nov 16 '05 #2
The info you need is actually in the GDI+ FAQ. See the article on Drawing
images.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"felix" <fe***@news.com > wrote in message
news:ut******** ******@TK2MSFTN GP15.phx.gbl...
Hi,

I have an Image that is drawn with Graphics.DrawIm age(..). What I want to
do is drawing it with a given transparency, e.g. at an alpha of only 180
instead of 255.

How am I doing that?!?!?

Regards,
Felix

Nov 16 '05 #3
Actually, I can't find such an information on your website. I know how
to draw an image and I'm also able to draw a transparent gif (well, I
think, GDI+ simply handles the transparency on its own).

What I want is to render the entire image (regardless of its own
transparency) with a specific alpha. Imagine a slider where the user can
modify the alpha value in the range [0,255] and the image will be
rendered accordingly.

I can't find any information about that issue. Thus, I'm really looking
forward for any help I can get.

Regards,
Felix

Bob Powell [MVP] wrote:
The info you need is actually in the GDI+ FAQ. See the article on Drawing
images.

Nov 16 '05 #4
Actually, I can't find such an information on your website. I know how
to draw an image and I'm also able to draw a transparent gif (well, I
think, GDI+ simply handles the transparency on its own).

What I want is to render the entire image (regardless of its own
transparency or file-format / pixel-format) with a specific alpha.
Imagine a slider where the user can modify the alpha value in the range
[0,255] and the image will be rendered accordingly.

I can't find any information about that issue. Thus, I'm really looking
forward for any help I can get.

Regards,
Felix
Bob Powell [MVP] wrote:
The info you need is actually in the GDI+ FAQ. See the article on Drawing
images.

Nov 16 '05 #5
At the bottom of the Drawing An Image article in the GDI+ FAQ it clearly
shows how to draw an image with transparency using the ColorMatrix
structure.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"felix" <fe***@news.com > wrote in message
news:ur******** ******@tk2msftn gp13.phx.gbl...
Actually, I can't find such an information on your website. I know how to
draw an image and I'm also able to draw a transparent gif (well, I think,
GDI+ simply handles the transparency on its own).

What I want is to render the entire image (regardless of its own
transparency or file-format / pixel-format) with a specific alpha. Imagine
a slider where the user can modify the alpha value in the range [0,255]
and the image will be rendered accordingly.

I can't find any information about that issue. Thus, I'm really looking
forward for any help I can get.

Regards,
Felix
Bob Powell [MVP] wrote:
The info you need is actually in the GDI+ FAQ. See the article on Drawing
images.

Nov 16 '05 #6
Oops, I didn't see the very last example. I'm really sorry.

Everything works fine now -- THANK YOU!

Regards,
Felix
Bob Powell [MVP] wrote:
At the bottom of the Drawing An Image article in the GDI+ FAQ it clearly
shows how to draw an image with transparency using the ColorMatrix
structure.

Nov 16 '05 #7

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

Similar topics

21
3086
by: DraguVaso | last post by:
Hi, I have an inherited DataGrid, that does lots of extra stuff. For exemple drawing a backgroundimage in every cell. The problem is that it's taking too much time (using gdi+), so I want to do it using DirectX. I downloaded already the DSK etc, but I can't find how I need to draw an image on a given position. I don't need stuff to write advanced 3D-games, just painting that image. Can anybody help me with this? I'm already looking for...
1
1528
by: Minhua Fu | last post by:
Hi, I have a problem when I draw a transparent gif picture. I have an existing transparent gif picture, i want to modify the gif and save it to reponse.outstream. But the picture always keep black backgroup. Can anyone give me some suggestions? Following is my code. System.Drawing.Image img =
4
2885
by: Adam Clauss | last post by:
I have a completely user-drawn user control in which I enabled transparency (follownig suggestions at http://www.c-sharpcorner.com/UploadFile/Nildo%20Soares%20de%20Araujo/TransparentControls11152005074108AM/TransparentControls.aspx) The user control does not contain any other controls; I manually draw contents in the OnPaint override I created. My problem is that the control does not always draw itself properly. Sometimes NONE of the...
2
6590
by: Niu Kun | last post by:
Dear all, I'm trying to draw many overlapped PNG files with transparent background in imagebox control. But the transparent background in this control is rendered as the main control's background color. So the image formerly drawn is covered by the latter image with unwanted background color. I wonder if I can get really transparent background color.
3
4879
by: NickP | last post by:
Hi there, I have a usercontrol that inherits from Windows.Forms.Button. 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()
8
10185
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
2875
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...
2
3488
by: neovantage | last post by:
Hey all, I have created transparent PNG images from text dynamically. But it edges are pixel-ate or we can say edges are distorted. Here is my LINK which shows my generated transparent PNG image. Can someone help me out to sort out my problem i will be very grateful to him as i am stuck bad with this issue and i am not figuring out how to fix this. Here is my Code which generate transparent PNG images <img...
0
9921
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
9765
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11065
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9536
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
7934
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
7098
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4581
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4177
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.