本文整理汇总了C#中Bitmap.DrawRectangle方法的典型用法代码示例。如果您正苦于以下问题:C# Bitmap.DrawRectangle方法的具体用法?C# Bitmap.DrawRectangle怎么用?C# Bitmap.DrawRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitmap
的用法示例。
在下文中一共展示了Bitmap.DrawRectangle方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderRectangle
protected internal override void RenderRectangle(Bitmap bmp, Pen pen, int x, int y, int width, int height)
{
Color outlineColor = (pen != null) ? pen.Color : (Color)0x0;
ushort outlineThickness = (pen != null) ? pen.Thickness : (ushort)0;
int x1, y1;
int x2, y2;
switch (MappingMode)
{
case BrushMappingMode.RelativeToBoundingBox:
x1 = x + (int)((long)(width - 1) * StartX / RelativeBoundingBoxSize);
y1 = y + (int)((long)(height - 1) * StartY / RelativeBoundingBoxSize);
x2 = x + (int)((long)(width - 1) * EndX / RelativeBoundingBoxSize);
y2 = y + (int)((long)(height - 1) * EndY / RelativeBoundingBoxSize);
break;
default: //case BrushMappingMode.Absolute:
x1 = StartX;
y1 = StartY;
x2 = EndX;
y2 = EndY;
break;
}
bmp.DrawRectangle(outlineColor, outlineThickness, x, y, width, height, 0, 0,
StartColor, x1, y1, EndColor, x2, y2, Opacity);
}
示例2: RenderRectangle
protected internal override void RenderRectangle(Bitmap bmp, Pen pen, int x, int y, int width, int height)
{
Color outlineColor = (pen != null) ? pen.Color : (Color)0x0;
ushort outlineThickness = (pen != null) ? pen.Thickness : (ushort)0;
bmp.DrawRectangle(outlineColor, outlineThickness, x, y, width, height, 0, 0,
Color, 0, 0, Color, 0, 0, Opacity);
}
示例3: RenderRectangle
protected internal override void RenderRectangle(Bitmap bmp, Pen pen, int x, int y, int width, int height)
{
if (Stretch == Stretch.None)
{
bmp.DrawImage(x, y, BitmapSource, 0, 0, BitmapSource.Width, BitmapSource.Height, Opacity);
}
else if (width == BitmapSource.Width && height == BitmapSource.Height)
{
bmp.DrawImage(x, y, BitmapSource, 0, 0, width, height, Opacity);
}
else
{
bmp.StretchImage(x, y, BitmapSource, width, height, Opacity);
}
if (pen != null && pen.Thickness > 0)
{
bmp.DrawRectangle(pen.Color, pen.Thickness, x, y, width, height, 0, 0,
(Color)0, 0, 0, (Color)0, 0, 0, 0);
}
}
示例4: TileImage
public MFTestResults TileImage()
{
Bitmap screen = new Bitmap(width, height);
Bitmap btn = new Bitmap(WaterFallJpg.WaterFall, Bitmap.BitmapImageType.Jpeg);
screen.DrawRectangle(Color.White, 0, 0, 0, width, height, 0, 0, Color.White, 0, 0, 0, 0, 0, 256);
screen.TileImage( 5, 10, btn, width - 50, height / 2, 256);
screen.Flush();
System.Threading.Thread.Sleep(500);
screen.Dispose();
btn.Dispose();
return MFTestResults.Pass;
}
示例5: Scale9ImageTest
public MFTestResults Scale9ImageTest()
{
Bitmap screen = new Bitmap(width, height);
Bitmap btn = new Bitmap(WaterFallJpg.WaterFall, Bitmap.BitmapImageType.Jpeg);
btn.MakeTransparent(ColorUtility.ColorFromRGB(255, 0, 255));
screen.DrawRectangle(Color.White, 0, 0, 0, width, height, 0, 0, Color.White, 0, 0, 0, 0, 0, 256);
screen.Scale9Image(30, 30, width / 3, height / 3, btn, 6, 6, 6, 6, 256);
screen.Scale9Image(width / 2, height / 2, width / 3, 30, btn, 6, 6, 6, 6, 256);
screen.Scale9Image(30, height / 2, 30, height / 3, btn, 6, 6, 6, 6, 256);
screen.Scale9Image(width / 2, 30, 30, 30, btn, 6, 6, 6, 6, 256);
screen.Flush();
System.Threading.Thread.Sleep(500);
screen.Dispose();
btn.Dispose();
return MFTestResults.Pass;
}
示例6: Init
protected virtual void Init(int left, int top, int width, int height, int borderWidth)
{
_width = width;
_height = height;
_left = left;
_top = top;
_borderWidth = borderWidth;
int x1 = _left;
int y1 = _top;
_bitmap = new Bitmap(_width, _height);
_bitmap.DrawRectangle(Colors.Black, _borderWidth, 0, 0, _width, _height, 0, 0, Colors.White, 0, 0, Colors.White, 0, 0, Bitmap.OpacityOpaque);
if ((x1 < 0) || ((x1 + _width) > SystemMetrics.ScreenWidth) ||
(y1 < 0) || ((y1 + _height) > SystemMetrics.ScreenHeight))
{
throw new ArgumentException("screenlimit");
}
}