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
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
Comment