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

Home Posts Topics Members FAQ

Transparency problem drawing bitmap

I am creating a custom user control and I am having problems with setting
the transparent color of the bitmap. Here is my code...

protected override void OnPaint( PaintEventArgs e )

{

System.Drawing. Imaging.ImageAt tributes imageAttributes = new
System.Drawing. Imaging.ImageAt tributes();

imageAttributes .SetColorKey(Co lor.FromArgb(23 1, 231, 231),
Color.FromArgb( 231, 231, 231), ColorAdjustType .Bitmap);

Point ulCorner1 = new Point(0, 0);

Point urCorner1 = new Point(GetBitmap Size().Width, 0);

Point llCorner1 = new Point(0, GetBitmapSize() .Height);

Point[] destPara1 = {ulCorner1, urCorner1, llCorner1};

Rectangle srcRect = new Rectangle( 0, 0, GetBitmapSize() .Width,
GetBitmapSize() .Height);

e.Graphics.Smoo thingMode = SmoothingMode.H ighQuality;

e.Graphics.Inte rpolationMode = InterpolationMo de.HighQualityB icubic;

e.Graphics.Pixe lOffsetMode = PixelOffsetMode .HighQuality;

e.Graphics.Draw Image(m_Selecte dImage, destPara1, srcRect,
GraphicsUnit.Pi xel, imageAttributes );

}

I want the specified RGB color (231, 231, 231) to be transparent, but it
isn't. What am I doing wrong? I thought imageAttributes .SetColorKey() was
supposed to do this.

-dh
Nov 15 '05 #1
1 4929
100
Hi David,
Your code works for me. Are you sure about the rgb components of the color
you want to make transparent.
Do you have such a color in your image.

B\rgds
100

"David Hoffer" <dh************ @xrite.remove.c om> wrote in message
news:ux******** ******@tk2msftn gp13.phx.gbl...
I am creating a custom user control and I am having problems with setting
the transparent color of the bitmap. Here is my code...

protected override void OnPaint( PaintEventArgs e )

{

System.Drawing. Imaging.ImageAt tributes imageAttributes = new
System.Drawing. Imaging.ImageAt tributes();

imageAttributes .SetColorKey(Co lor.FromArgb(23 1, 231, 231),
Color.FromArgb( 231, 231, 231), ColorAdjustType .Bitmap);

Point ulCorner1 = new Point(0, 0);

Point urCorner1 = new Point(GetBitmap Size().Width, 0);

Point llCorner1 = new Point(0, GetBitmapSize() .Height);

Point[] destPara1 = {ulCorner1, urCorner1, llCorner1};

Rectangle srcRect = new Rectangle( 0, 0, GetBitmapSize() .Width,
GetBitmapSize() .Height);

e.Graphics.Smoo thingMode = SmoothingMode.H ighQuality;

e.Graphics.Inte rpolationMode = InterpolationMo de.HighQualityB icubic;

e.Graphics.Pixe lOffsetMode = PixelOffsetMode .HighQuality;

e.Graphics.Draw Image(m_Selecte dImage, destPara1, srcRect,
GraphicsUnit.Pi xel, imageAttributes );

}

I want the specified RGB color (231, 231, 231) to be transparent, but it
isn't. What am I doing wrong? I thought imageAttributes .SetColorKey() was supposed to do this.

-dh

Nov 15 '05 #2

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

Similar topics

1
2393
by: news.microsoft.com | last post by:
Hello group, My goal is to attach an image over another image. Top image should be transparent so the back image is visible through the top one. Bellow is a test code in VB.NET. You need to create a form, a button (Button1) and an Picture Box (picBox). "watermark.jpg" is any jpg image, "beispiel.tif" is a multipage TIFF image with the...
20
4493
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 that is completely transparent in certain areas (so that the web page background shows through)? I save my graphics as gif files. I would appreciate,...
6
3645
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 purpose to improve it. Frankly, I am not clear about the exact meaning of some pixel format (max, gdi, etc.) and I hope I have put them under the...
0
7924
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. ...
0
8130
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...
1
7677
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...
0
7979
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...
0
6284
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...
1
5514
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...
0
5219
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...
1
2115
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
0
940
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...

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.