D
David Hoffer
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.ImageAttributes imageAttributes = new
System.Drawing.Imaging.ImageAttributes();
imageAttributes.SetColorKey(Color.FromArgb(231, 231, 231),
Color.FromArgb(231, 231, 231), ColorAdjustType.Bitmap);
Point ulCorner1 = new Point(0, 0);
Point urCorner1 = new Point(GetBitmapSize().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.SmoothingMode = SmoothingMode.HighQuality;
e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
e.Graphics.DrawImage(m_SelectedImage, destPara1, srcRect,
GraphicsUnit.Pixel, 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.ImageAttributes imageAttributes = new
System.Drawing.Imaging.ImageAttributes();
imageAttributes.SetColorKey(Color.FromArgb(231, 231, 231),
Color.FromArgb(231, 231, 231), ColorAdjustType.Bitmap);
Point ulCorner1 = new Point(0, 0);
Point urCorner1 = new Point(GetBitmapSize().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.SmoothingMode = SmoothingMode.HighQuality;
e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
e.Graphics.DrawImage(m_SelectedImage, destPara1, srcRect,
GraphicsUnit.Pixel, 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