本文整理汇总了C#中System.Drawing.TextureBrush类的典型用法代码示例。如果您正苦于以下问题:C# TextureBrush类的具体用法?C# TextureBrush怎么用?C# TextureBrush使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextureBrush类属于System.Drawing命名空间,在下文中一共展示了TextureBrush类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Bumper
public Bumper()
{
InitializeComponent();
Kontroli = Resources.kontrolii;
flag = false;
zvukON = Resources.soundON;
zvukOFF = Resources.soundOFF;
CarsDoc = new CarsDoc();
LentiDoc = new LentiDoc();
DupkiDoc = new DupkiDoc();
generirajKola = 0;
poeni = 0;
level = 1;
sekundi = 0;
//asvalt
img = Properties.Resources.Road2;
biImg = new Bitmap(img);
tba = new TextureBrush(biImg);
clicked = true;
sounds = new Sounds();
DoubleBuffered = true;
random = new Random();
zgolemiLvl = false;
bestScore = 0;
eksplozija = Properties.Resources.explosion_;
TextReader tr = new StreamReader("highscores.txt");
lbHighScore.Text = tr.ReadLine() + "pts";
}
示例2: BrushesExampleMethod
public static void BrushesExampleMethod(Graphics g)
{
Color pink = Color.FromArgb(241, 105, 190);
SolidBrush sldBrush = new SolidBrush(pink);
g.FillRectangle(sldBrush, 300, 150, 70, 70);
HatchBrush hBrush = new HatchBrush(HatchStyle.NarrowVertical, Color.Pink, Color.Blue);
g.FillRectangle(hBrush, 370, 150, 70, 70);
sldBrush = new SolidBrush(Color.Orchid);
g.FillRectangle(sldBrush, 440, 150, 70, 70);
LinearGradientBrush lgBrush = new LinearGradientBrush(new Rectangle(0, 0, 20, 20), Color.Violet, Color.LightSteelBlue, LinearGradientMode.Vertical);
g.FillRectangle(lgBrush, 300, 220, 70, 70);
g.FillRectangle(Brushes.Indigo, 370, 220, 70, 70);
sldBrush = new SolidBrush(Color.Orange);
g.FillRectangle(sldBrush, 440, 220, 70, 70);
lgBrush = new LinearGradientBrush(new RectangleF(0, 0, 90, 90), Color.BlueViolet, Color.LightPink, LinearGradientMode.BackwardDiagonal);
g.FillRectangle(lgBrush, 300, 290, 70, 70);
TextureBrush tBrush = new TextureBrush(Image.FromFile(@"Images\csharp.jpg"));
g.FillRectangle(tBrush, 370, 290, 70, 70);
tBrush = new TextureBrush(Image.FromFile(@"Images\003.jpg"));
g.FillRectangle(tBrush, 440, 290, 70, 70);
}
示例3: DrawBackgroundImage
public static void DrawBackgroundImage(Graphics g, Image backgroundImage, Color backColor, ImageLayout backgroundImageLayout, Rectangle bounds, Rectangle clipRect, Point scrollOffset, RightToLeft rightToLeft)
{
if (g == null)
{
throw new ArgumentNullException("g");
}
if (backgroundImageLayout == ImageLayout.Tile)
{
using (TextureBrush brush = new TextureBrush(backgroundImage, WrapMode.Tile))
{
if (scrollOffset != Point.Empty)
{
Matrix transform = brush.Transform;
transform.Translate((float) scrollOffset.X, (float) scrollOffset.Y);
brush.Transform = transform;
}
g.FillRectangle(brush, clipRect);
return;
}
}
Rectangle rect = CalculateBackgroundImageRectangle(bounds, backgroundImage, backgroundImageLayout);
if ((rightToLeft == RightToLeft.Yes) && (backgroundImageLayout == ImageLayout.None))
{
rect.X += clipRect.Width - rect.Width;
}
using (SolidBrush brush2 = new SolidBrush(backColor))
{
g.FillRectangle(brush2, clipRect);
}
if (!clipRect.Contains(rect))
{
if ((backgroundImageLayout == ImageLayout.Stretch) || (backgroundImageLayout == ImageLayout.Zoom))
{
rect.Intersect(clipRect);
g.DrawImage(backgroundImage, rect);
}
else if (backgroundImageLayout == ImageLayout.None)
{
rect.Offset(clipRect.Location);
Rectangle destRect = rect;
destRect.Intersect(clipRect);
Rectangle rectangle3 = new Rectangle(Point.Empty, destRect.Size);
g.DrawImage(backgroundImage, destRect, rectangle3.X, rectangle3.Y, rectangle3.Width, rectangle3.Height, GraphicsUnit.Pixel);
}
else
{
Rectangle rectangle4 = rect;
rectangle4.Intersect(clipRect);
Rectangle rectangle5 = new Rectangle(new Point(rectangle4.X - rect.X, rectangle4.Y - rect.Y), rectangle4.Size);
g.DrawImage(backgroundImage, rectangle4, rectangle5.X, rectangle5.Y, rectangle5.Width, rectangle5.Height, GraphicsUnit.Pixel);
}
}
else
{
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetWrapMode(WrapMode.TileFlipXY);
g.DrawImage(backgroundImage, rect, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel, imageAttr);
imageAttr.Dispose();
}
}
示例4: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics G = e.Graphics;
//利用位图作为纹理创建纹理画刷
TextureBrush textureBrush1 = new TextureBrush(Properties.Resources.test);
G.FillRectangle(textureBrush1, 40, 0, 40, 120);
G.FillRectangle(textureBrush1, 0, 40, 120, 40);
//利用位置的指定区域作为纹理创建纹理画刷
TextureBrush textureBrush2 = new TextureBrush(Properties.Resources.test, new Rectangle(10, 10, 28, 28));
G.FillRectangle(textureBrush2, 180, 0, 40, 120);
G.FillRectangle(textureBrush2, 140, 40, 120, 40);
TextureBrush textureBrush3 = new TextureBrush(Properties.Resources.test, new Rectangle(10, 10, 28, 28));
textureBrush3.WrapMode = WrapMode.TileFlipXY; //设置纹理图像的渐变方式
G.FillRectangle(textureBrush3, 30, 140, 60, 120);
G.FillRectangle(textureBrush3, 0, 170, 120, 60);
float[][] newColorMatrix = new float[][]{ //颜色变换矩形
new float[]{0.2f,0,0,0,0}, //红色分量
new float[]{0,0.6f,0,0,0}, //绿色分量
new float[]{0,0,0.2f,0,0}, //蓝色分量
new float[]{0,0,0,0.5f,0}, //透明度分量
new float[]{0,0,0,0,1}}; //始终为1
ColorMatrix colorMatrix = new ColorMatrix(newColorMatrix);
ImageAttributes imageAttributes = new ImageAttributes();
imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
TextureBrush textureBrush4 = new TextureBrush(Properties.Resources.test, new Rectangle(0, 0, 48, 48), imageAttributes);
textureBrush4.WrapMode = WrapMode.TileFlipXY;
G.FillRectangle(textureBrush4, 170, 140, 60, 120);
G.FillRectangle(textureBrush4, 140, 170, 120, 60);
textureBrush1.Dispose(); //释放画刷
textureBrush2.Dispose(); //释放画刷
textureBrush3.Dispose(); //释放画刷
textureBrush4.Dispose(); //释放画刷
}
示例5: OnHtmlLabelHostingPanelPaint
private void OnHtmlLabelHostingPanelPaint(object sender, PaintEventArgs e)
{
using (var b = new TextureBrush(_background, WrapMode.Tile))
{
e.Graphics.FillRectangle(b, _htmlLabelHostingPanel.ClientRectangle);
}
}
示例6: cropAtRect
public static Bitmap cropAtRect(Bitmap bi, int size)
{
Bitmap btm = new Bitmap(bi.Width + 4, bi.Height + 4);
Bitmap btm2 = new Bitmap(size + 5, size + 5);
using (Graphics grf = Graphics.FromImage(bi))
{
using (Brush brsh = new SolidBrush(Color.FromArgb(120, 0, 0, 0)))
{
grf.FillRectangle(brsh, new System.Drawing.Rectangle(0, 0, bi.Width, bi.Height));
}
}
using (Graphics grf = Graphics.FromImage(btm))
{
using (Brush brsh = new SolidBrush(Color.Red))
{
grf.FillEllipse(brsh, 2, 2, bi.Width - 4, bi.Height - 4);
}
using (Brush brsh = new TextureBrush(bi))
{
grf.FillEllipse(brsh, 6, 6, bi.Width - 12, bi.Height - 12);
}
}
using (Graphics grf = Graphics.FromImage(btm2))
{
grf.InterpolationMode = InterpolationMode.High;
grf.CompositingQuality = CompositingQuality.HighQuality;
grf.SmoothingMode = SmoothingMode.AntiAlias;
grf.DrawImage(btm, new System.Drawing.Rectangle(0, 0, size, size));
}
return btm2;
}
示例7: MainForm
public MainForm()
{
InitializeComponent();
this.currentFileData = new GameData(32, 32);
this.currentFileName = null;
this.toolImages = new TextureBrush[7];
for (int i = 0; i < this.toolImages.Length; i++)
{
this.toolImages[i] = new TextureBrush(Image.FromFile("images/" + i + ".png"));
}
this.backgroundImage = new TextureBrush(Image.FromFile("images/checkerboard.png"));
this.selectedTool = 1;
this.graphicsContext = BufferedGraphicsManager.Current;
this.graphics = graphicsContext.Allocate(this.StageEditBoard.CreateGraphics(),
new Rectangle(0, 0, 32 * (int)EDIT_BOARD_SCALING, 32 * (int)EDIT_BOARD_SCALING));
for(int i = 0; i < MainForm.DIRECTIONS.Length; i++)
this.StartDirection.Items.Add(DIRECTIONS[i]);
this.LoadTextureFiles();
this.FileNew(null, null);
}
示例8: GetCircleBitmap
public Image GetCircleBitmap(Size size, Color col)
{
Bitmap bmp2 = new Bitmap(size.Width, size.Height);
using (Bitmap bmp = new Bitmap(size.Width, size.Height))
{
using (Graphics g = Graphics.FromImage(bmp))
{
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.Clear(col);
}
using (TextureBrush t = new TextureBrush(bmp))
{
using (Graphics g = Graphics.FromImage(bmp2))
{
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.FillEllipse(t, 0, 0, bmp2.Width, bmp2.Height);
}
}
}
return bmp2;
}
示例9: CopyIrregularAreaFromBitmap
//Other methods to copy, color fill or filter found objects
public Bitmap CopyIrregularAreaFromBitmap(Bitmap source, List<Point> points, Color bg_color)
{
Bitmap copiedImg = new Bitmap(source);
using (Graphics gr = Graphics.FromImage(copiedImg))
{
// Set the background color.
gr.Clear(bg_color);
// Make a brush out of the original image.
using (Brush br = new TextureBrush(source))
{
// Fill the selected area with the brush.
gr.FillPolygon(br, points.ToArray());
// Find the bounds of the selected area.
Rectangle source_rect = GetPointListBounds(points);
// Make a bitmap that only holds the selected area.
Bitmap result = new Bitmap(
source_rect.Width, source_rect.Height);
// Copy the selected area to the result bitmap.
using (Graphics result_gr = Graphics.FromImage(result))
{
Rectangle dest_rect = new Rectangle(0, 0,
source_rect.Width, source_rect.Height);
result_gr.DrawImage(copiedImg, dest_rect,
source_rect, GraphicsUnit.Pixel);
}
// Return the result.
return result;
}
}
}
示例10: GetBrush
public TextureBrush GetBrush(Matrix matrix)
{
Bitmap bmp;
if (_context2D != null)
{
bmp = _context2D.GetBitmap();
}
else
{
bmp = new Bitmap(_imagePath);
}
WrapMode wm = WrapMode.Tile;
switch (_repetition)
{
case "repeat":
wm = WrapMode.Tile;
break;
case "no-repeat":
wm = WrapMode.Clamp;
break;
case "repeat-x":
wm = WrapMode.TileFlipX;
break;
case "repeat-y":
wm = WrapMode.TileFlipY;
break;
}
var brush = new TextureBrush(bmp, wm);
brush.MultiplyTransform(matrix);
return brush;
}
示例11: Create
public Image Create( string text )
{
var bitmap = (Bitmap) Image.FromFile( "Stone08Small.png" );
using ( var g = Graphics.FromImage( bitmap ) )
{
g.SmoothingMode = SmoothingMode.HighQuality;
g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
using ( var textureBitmap = Image.FromFile( "Stone11Small.png" ) )
{
var textureBrush = new TextureBrush( textureBitmap );
using ( var font = new Font( "Book Antiqua", 84 ) )
{
var textSize = g.MeasureString( text, font );
float x = ( _decalSize - textSize.Width ) / 2;
float y = ( _decalSize - textSize.Height ) / 2;
g.DrawString( text, font, textureBrush, x, y );
}
}
}
return bitmap;
}
示例12: draw
public override void draw(Graphics g)
{
TextureBrush texture = new TextureBrush(image1);
texture.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile;
g.FillEllipse(texture, Rectangle.Round(base.loc));
}
示例13: Form1_Paint
private void Form1_Paint(object sender, PaintEventArgs e)
{
LinearGradientBrush linearBrush = new LinearGradientBrush(drawArea(new Rectangle(5, 35, 30, 100)), Color.Yellow, Color.Yellow, LinearGradientMode.ForwardDiagonal);
graphicsObject(e).FillEllipse(linearBrush, this.Width / 4, 10, 300, 300);
LinearGradientBrush linearBrush2 = new LinearGradientBrush(drawArea(new Rectangle(5, 35, 30, 100)), Color.Black, Color.Black, LinearGradientMode.Horizontal);
graphicsObject(e).FillEllipse(linearBrush2, 190, 60, 100, 100);
LinearGradientBrush linearBrush3 = new LinearGradientBrush(drawArea(new Rectangle(5, 35, 30, 100)), Color.Black, Color.Black, LinearGradientMode.BackwardDiagonal);
graphicsObject(e).FillEllipse(linearBrush3, 330, 60, 100, 100);
LinearGradientBrush linearBrush4 = new LinearGradientBrush(drawArea(new Rectangle(5, 35, 30, 100)), Color.Yellow, Color.Yellow, LinearGradientMode.BackwardDiagonal);
graphicsObject(e).FillEllipse(linearBrush4, 460, 400, 100, 100);
Bitmap textureBitmap = new Bitmap(10, 10);
Graphics graphicsObject2 = Graphics.FromImage(textureBitmap);
SolidBrush solidColorBrush = new SolidBrush(Color.Red);
Pen coloredPen = new Pen(solidColorBrush);
TextureBrush texturedBrush = new TextureBrush(textureBitmap);
graphicsObject(e).FillRectangle(texturedBrush, 155, 30, 75, 100);
coloredPen.Color = Color.Black;
coloredPen.Width = 6;
graphicsObject(e).DrawPie(coloredPen, 205, 220, 205, 10, 100, 100);
}
示例14: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
using (var brush = new TextureBrush(gradient, WrapMode.TileFlipX))
{
e.Graphics.FillRectangle(brush, 0, 0, Width, gradient.Height);
}
}
示例15: Form1_Paint
private void Form1_Paint(object sender, PaintEventArgs e)
{
Image I = Image.FromFile("클로버.jpg");
TextureBrush B = new TextureBrush(I);
//TextureBrush B = new TextureBrush(I, WrapMode.TileFlipX);
//TextureBrush B = new TextureBrush(I, WrapMode.TileFlipY);
e.Graphics.FillRectangle(B, ClientRectangle);
}