本文整理汇总了C#中System.Drawing.TextureBrush.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# TextureBrush.Dispose方法的具体用法?C# TextureBrush.Dispose怎么用?C# TextureBrush.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.TextureBrush
的用法示例。
在下文中一共展示了TextureBrush.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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(); //释放画刷
}
示例2: RoundImageTransparent
private static void RoundImageTransparent(Image bitmap, int roundedDia)
{
Brush brush = new TextureBrush(bitmap);
Graphics g = Graphics.FromImage(bitmap);
g.Clear(Color.Transparent);
Genetibase.UI.Drawing.Grpahics.FillRoundedRectangle(g, brush, new Rectangle(0, 0, bitmap.Width, bitmap.Height), 30);
g.Dispose();
brush.Dispose();
Rounded = true;
}
示例3: RoundImage
public static Bitmap RoundImage( Image bitmap )
{
Bitmap retImage = new Bitmap(bitmap.Width, bitmap.Height);
Graphics g = Graphics.FromImage(retImage);
g.Clear(Color.Transparent);
Brush brush = new TextureBrush(bitmap);
FillRoundedRectangle(g, new Rectangle(0, 0, bitmap.Width, bitmap.Height), roundedDia, brush);
g.Dispose();
brush.Dispose();
return retImage;
}
示例4: GetImage
public override System.Drawing.Bitmap GetImage()
{
Bitmap bmp = new Bitmap(Width, Height);
Graphics g = Graphics.FromImage(bmp);
using( TextureBrush brush = new TextureBrush(Ultima.Gumps.GetGump(Index)) )
{
g.FillRectangle(brush, new Rectangle(0, 0, Width, Height));
brush.Dispose();
}
g.Dispose();
return bmp;
}
示例5: dropShadow
public static Bitmap dropShadow(Bitmap original)
{
Bitmap dest = new Bitmap(original.Width + shadowSize, original.Height + shadowSize);
Graphics g = Graphics.FromImage(dest);
TextureBrush shadowRightBrush = new TextureBrush(shadowRight, WrapMode.Tile);
TextureBrush shadowDownBrush = new TextureBrush(shadowDown, WrapMode.Tile);
shadowRightBrush.TranslateTransform(original.Width - shadowSize, 0);
shadowDownBrush.TranslateTransform(0, original.Height - shadowSize);
Rectangle shadowDownRectangle = new Rectangle(
shadowSize, // X
original.Height, //- shadowSize, // Y
original.Width - shadowSize,// - (shadowSize * 2 + shadowMargin), // width (stretches)
shadowSize // height
);
Rectangle shadowRightRectangle = new Rectangle(
original.Width,// - shadowSize, // X
shadowSize, // + shadowMargin, // Y
shadowSize, // width
original.Height -shadowSize // - (shadowSize * 2 + shadowMargin) // height (stretches)
);
// And draw the shadow on the right and at the bottom.
g.FillRectangle(shadowDownBrush, shadowDownRectangle);
g.FillRectangle(shadowRightBrush, shadowRightRectangle);
// 隅っこ三つ
g.DrawImage(shadowTopRight, new Rectangle(original.Width, 0, shadowSize, shadowSize));
g.DrawImage(shadowDownRight, new Rectangle(original.Width, original.Height, shadowSize, shadowSize));
g.DrawImage(shadowDownLeft, new Rectangle(0, original.Height, shadowSize, shadowSize));
g.DrawImage(original, new Rectangle(new Point(0, 0), new Size(original.Width, original.Height)));
shadowDownBrush.Dispose();
shadowRightBrush.Dispose();
shadowDownBrush = null;
shadowRightBrush = null;
return dest;
}
示例6: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
{
// get the graphics obj used to paint the panel
Graphics graphic = e.Graphics;
// create a brush with playerColor colored paint
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(playerColor);
// the image is bound to 150*150 size starting from 60,60 top left origin
System.Drawing.TextureBrush myBrush2 = new System.Drawing.TextureBrush(pieceTexture, new Rectangle(60, 60, 150, 150)); // the bounding rectangle of the texture image
myBrush2.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
// scale down the texture from 256,256
myBrush2.Transform = new System.Drawing.Drawing2D.Matrix(35.0f / 256.0f, 0.0f, 0.0f, 35.0f / 256.0f, 0.0f, 0.0f);
// draw a filled elipse with the brush
// TODO: change this to an image
graphic.FillEllipse(myBrush2, new Rectangle(0, 0, this.Height - 1, this.Width - 1)); // the bounding rectangle of the piecePanel
// cleanup the tools
myBrush.Dispose();
myBrush2.Dispose();
graphic.Dispose();
}
}
示例7: OnPaint
/// <summary>
/// 繪畫方法
/// </summary>
/// <param name="e">事件參數</param>
protected override void OnPaint(PaintEventArgs e)
{
//System.Diagnostics.Debug.WriteLine("Paint " + this.Name + " Pos: "+this.Position.ToString());
if (!this.IsDisposed)
{
int mSteepTotal = mSteepWidth + mSteepDistance;
float mUtilWidth = this.Width - 6 + mSteepDistance;
if (mDobleBack == null)
{
mUtilWidth = this.Width - 6 + mSteepDistance;
int mMaxSteeps = (int)(mUtilWidth / mSteepTotal);
this.Width = 6 + mSteepTotal * mMaxSteeps;
mDobleBack = new Bitmap(this.Width, this.Height);
Graphics g2 = Graphics.FromImage(mDobleBack);
CreatePaintElements();
g2.Clear(mColorBackGround);
if (this.BackgroundImage != null)
{
TextureBrush textuBrush = new TextureBrush(this.BackgroundImage, WrapMode.Tile);
g2.FillRectangle(textuBrush, 0, 0, this.Width, this.Height);
textuBrush.Dispose();
}
// g2.DrawImage()
g2.DrawRectangle(mPenOut2, outnnerRect2);
g2.DrawRectangle(mPenOut, outnnerRect);
g2.DrawRectangle(mPenIn, innerRect);
g2.Dispose();
}
Image ima = new Bitmap(mDobleBack);
Graphics gtemp = Graphics.FromImage(ima);
int mCantSteeps = (int)((((float)mValue - mMin) / (mMax - mMin)) * mUtilWidth / mSteepTotal);
for (int i = 0; i < mCantSteeps; i++)
{
DrawSteep(gtemp, i);
}
if (this.Text != String.Empty)
{
gtemp.TextRenderingHint = TextRenderingHint.AntiAlias;
DrawCenterString(gtemp, this.ClientRectangle);
}
e.Graphics.DrawImage(ima, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle, GraphicsUnit.Pixel);
ima.Dispose();
gtemp.Dispose();
}
}
示例8: Form1_Paint
// Create dirty text effect
private void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
Bitmap canvas = Canvas.GenImage(ClientSize.Width, ClientSize.Height);
// Load the dirty image from file
Bitmap canvasDirty = new Bitmap("..\\..\\..\\CommonImages\\dirty-texture.png");
// Text context to store string and font info to be sent as parameter to Canvas methods
TextContext context = new TextContext();
FontFamily fontFamily = new FontFamily("Arial Black");
context.fontFamily = fontFamily;
context.fontStyle = FontStyle.Regular;
context.nfontSize = 48;
context.pszText = "DIRTY";
context.ptDraw = new Point(5, 70);
// Load the texture image from file
Bitmap texture = new Bitmap("..\\..\\..\\CommonImages\\texture_blue.jpg");
Bitmap texture2 = Canvas.GenImage(ClientSize.Width, ClientSize.Height);
// Draw the texture against the red dirty mask onto the 2nd texture
Canvas.ApplyImageToMask(texture, canvasDirty, texture2, MaskColor.Red, false);
TextureBrush textureBrush = new TextureBrush(texture2);
Bitmap textureShadow = Canvas.GenImage(ClientSize.Width, ClientSize.Height);
// Draw the gray color against the red dirty mask onto the shadow texture
Canvas.ApplyColorToMask(Color.FromArgb(0xaa, 0xcc, 0xcc, 0xcc), canvasDirty, textureShadow, MaskColor.Red);
// Create texture brush for the shadow
TextureBrush shadowBrush = new TextureBrush(textureShadow);
// Create strategy for the shadow with the shadow brush
var strategyShadow = Canvas.TextNoOutline(shadowBrush);
Bitmap canvasTemp = Canvas.GenImage(ClientSize.Width, ClientSize.Height);
// Draw the shadow image first onto the temp canvas
Canvas.DrawTextImage(strategyShadow, canvasTemp, new Point(0, 0), context);
// Create strategy for the text body
var strategy = Canvas.TextNoOutline(textureBrush);
// Draw text body
Canvas.DrawTextImage(strategy, canvas, new Point(0,0), context);
// Draw the shadow image (canvasTemp) shifted -3, -3
e.Graphics.DrawImage(canvasTemp, 3, 3, ClientSize.Width - 3, ClientSize.Height - 3);
// Then draw the rendered image onto window
e.Graphics.DrawImage(canvas, 0, 0, ClientSize.Width, ClientSize.Height);
e.Graphics.Dispose();
texture.Dispose();
texture2.Dispose();
textureShadow.Dispose();
canvasDirty.Dispose();
canvas.Dispose();
canvasTemp.Dispose();
strategyShadow.Dispose();
strategy.Dispose();
textureBrush.Dispose();
shadowBrush.Dispose();
}
示例9: Dispose_Image
public void Dispose_Image ()
{
TextureBrush t = new TextureBrush (image);
t.Dispose ();
Assert.IsNotNull (t.Image, "Image");
}
示例10: Wash
public static void Wash(Bitmap b,Color washColor)
{
Rectangle rect = new Rectangle( 0,0,b.Width,b.Height);
Brush backgroundBrush = new TextureBrush(b);
Graphics g = Graphics.FromImage(b);
Brush newBrush = new SolidBrush(Color.FromArgb(128, washColor));
if (!Rounded)
{
g.FillRectangle(backgroundBrush, rect);
g.FillRectangle(newBrush, rect);
}
else
{
Genetibase.UI.NuGenImageWorks.Grpahics.FillRoundedRectangle(g, backgroundBrush, rect, 30);
Genetibase.UI.NuGenImageWorks.Grpahics.FillRoundedRectangle(g, newBrush, rect, 30);
}
newBrush.Dispose();
newBrush = null;
g.Dispose();
backgroundBrush.Dispose();
g = null;
backgroundBrush = null;
}
示例11: ProcessPrintRequest
//.........这里部分代码省略.........
lbTabSquare.Location = new Point(control.Location.X, control.Location.Y);
lbTabSquare.Size = TextRenderer.MeasureText(lbTabSquare.Text, lbTabSquare.Font);
lbTabSquare.Size = new Size(lbTabSquare.Size.Width + lbTabSquare.Padding.Size.Width, lbTabSquare.Size.Height + lbTabSquare.Padding.Size.Height);
lbTabSquare.Tag = "showtab";
lbTabSquare.BringToFront();
printPanel.Controls.Add(lbTabSquare);
}
}
}
}*/
printPanel.BackgroundImageLayout = ImageLayout.None;
if (printPanel.Size.Width > 0 && printPanel.Size.Height > 0)
{
try
{
Bitmap b = new Bitmap(printPanel.Size.Width, printPanel.Size.Height);
Graphics bufferGraphics = Graphics.FromImage(b);
if (!(color.Equals(Color.Empty)))
{
printPanel.BackColor = color;
}
bufferGraphics.Clear(printPanel.BackColor);
if (image != null)
{
Image img = image;
switch (imageLayout.ToUpper())
{
case "TILE":
TextureBrush tileBrush = new TextureBrush(img, System.Drawing.Drawing2D.WrapMode.Tile);
bufferGraphics.FillRectangle(tileBrush, 0, 0, printPanel.Size.Width, printPanel.Size.Height);
tileBrush.Dispose();
break;
case "STRETCH":
bufferGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
bufferGraphics.DrawImage(img, 0, 0, printPanel.Size.Width, printPanel.Size.Height);
bufferGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default;
break;
case "CENTER":
int centerX = (printPanel.Size.Width / 2) - (img.Size.Width / 2);
int centerY = (printPanel.Size.Height / 2) - (img.Size.Height / 2);
bufferGraphics.DrawImage(img, centerX, centerY);
break;
default:
bufferGraphics.DrawImage(img, 0, 0);
break;
}
}
foreach (Control control in pageControls)
{
if (control is DragableGroupBox)
{
Pen pen = new Pen(Color.Black);
Point ul = control.Location;
Point ur = new Point(control.Location.X + control.Width, control.Location.Y);
Point ll = new Point(control.Location.X, control.Location.Y + control.Height);
Point lr = new Point(control.Location.X + control.Width, control.Location.Y + control.Height);
bufferGraphics.DrawLine(pen, ul, ur);
bufferGraphics.DrawLine(pen, ur, lr);
bufferGraphics.DrawLine(pen, lr, ll);
示例12: pBox_Paint
private void pBox_Paint(object sender, PaintEventArgs e)
{
lRed.Text = fRed.ToString();
lGreen.Text = fGreen.ToString();
lBlue.Text = fBlue.ToString();
lRedScale.Text = fRedScale.ToString();
lGreenScale.Text = fGreenScale.ToString();
lBlueScale.Text = fBlueScale.ToString();
Rectangle BaseRectangle =
new Rectangle(0, 0, pBox.Width, pBox.Height);
Image ImageBack = null;
if (imageBackG == null)
{
ImageBack = Properties.Resources.grey;
}
else
{
ImageBack = imageBackG;
}
System.Drawing.Imaging.ImageAttributes imageAttributes = new System.Drawing.Imaging.ImageAttributes();
float[][] colorMatrixElements = {
new float[] {fRedScale, 0, 0, 0, 0}, // red scaling factor
new float[] {0, fGreenScale, 0, 0, 0}, // green scaling factor
new float[] {0, 0, fBlueScale, 0, 0}, // blue scaling factor
new float[] {0, 0, 0, 1, 0}, // alpha scaling factor of 1
new float[] {fRed, fGreen, fBlue, 0, 1}}; //translations
System.Drawing.Imaging.ColorMatrix colorMatrix = new System.Drawing.Imaging.ColorMatrix(colorMatrixElements);
imageAttributes.SetColorMatrix(
colorMatrix,
System.Drawing.Imaging.ColorMatrixFlag.Default,
System.Drawing.Imaging.ColorAdjustType.Bitmap);
int width = ImageBack.Width;
int height = ImageBack.Height;
// what to do when pic is larger than picture box...? I decided to scale it down to picbox width
//if (height > pBox.Height)
//{
// ImageBack.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
// ImageBack.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
// width = (width * pBox.Height) / height;
// height = pBox.Height;
// ImageBack = ImageBack.GetThumbnailImage(width, height, null, IntPtr.Zero);
//}
if (width > pBox.Width)
{
ImageBack.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
ImageBack.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
height = (height * pBox.Width) / width;
width = pBox.Width;
ImageBack = ImageBack.GetThumbnailImage(width, height, null, IntPtr.Zero);
}
if (bBGIFill)
e.Graphics.DrawImage(
ImageBack,
BaseRectangle,
0, 0, // upper-left corner of source rectangle
width, // width of source rectangle
height, // height of source rectangle
GraphicsUnit.Pixel,
imageAttributes);
else
{
imageAttributes.SetWrapMode(System.Drawing.Drawing2D.WrapMode.Tile);
Rectangle brushRect = new Rectangle(0, 0, width, height);
TextureBrush tBrush = new TextureBrush(ImageBack, brushRect, imageAttributes);
e.Graphics.FillRectangle(tBrush, BaseRectangle);
tBrush.Dispose();
}
// ImageBack.Dispose();
}
示例13: SaveSnapshot
private void SaveSnapshot()
{
PagePanel.BackgroundImageLayout = ImageLayout.None;
if (PagePanel.Size.Width > 0 && PagePanel.Size.Height > 0)
{
Bitmap b = new Bitmap(PagePanel.Size.Width, PagePanel.Size.Height);
this.bufferGraphics = Graphics.FromImage(b);
PagePanel.BackColor = makeViewForm.CurrentBackgroundColor;
this.bufferGraphics.Clear(PagePanel.BackColor);
if (makeViewForm.CurrentBackgroundImage != null)
{
Image img = makeViewForm.CurrentBackgroundImage;
switch (makeViewForm.CurrentBackgroundImageLayout.ToUpper())
{
case "TILE":
TextureBrush tileBrush = new TextureBrush(img, System.Drawing.Drawing2D.WrapMode.Tile);
bufferGraphics.FillRectangle(tileBrush, 0, 0, PagePanel.Size.Width, PagePanel.Size.Height);
tileBrush.Dispose();
break;
case "STRETCH":
bufferGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
bufferGraphics.DrawImage(img, 0, 0, PagePanel.Size.Width, PagePanel.Size.Height);
bufferGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default;
break;
case "CENTER":
int centerX = (this.PagePanel.Size.Width - img.Width) / 2;
int centerY = (this.PagePanel.Size.Height - img.Height) / 2;
bufferGraphics.DrawImage(img, centerX, centerY);
break;
default:
bufferGraphics.DrawImage(img, 0, 0);
break;
}
}
if (config.Settings.ShowGrid)
{
this.DrawGrid(b);
}
bufferGraphics.DrawImage(b, 0, 0);
bufferBitmap = b;
PagePanel.BackgroundImage = b;
}
}
示例14: DrawButtonState
protected virtual void DrawButtonState(Graphics g, ImageAttributes ia)
{
TextureBrush tb;
// Draw the left and right endcaps
g.DrawImage(imgLeft, rcLeft, 0, 0,
imgLeft.Width, imgLeft.Height, GraphicsUnit.Pixel, ia);
g.DrawImage(imgRight, rcRight, 0, 0,
imgRight.Width, imgRight.Height, GraphicsUnit.Pixel, ia);
// Draw the middle
tb = new TextureBrush(imgFill,
new Rectangle(0, 0, imgFill.Width, imgFill.Height), ia);
tb.WrapMode = WrapMode.Tile;
g.FillRectangle(tb, imgLeft.Width, 0,
this.Width - (imgLeft.Width + imgRight.Width),
imgFill.Height);
tb.Dispose();
}
示例15: LayeredImage
public LayeredImage(Int32 width, Int32 height)
{
_width = width;
_height = height;
_layers = new Layers(this);
// checker board brush
_checkerboard = new Bitmap(32, 32, PixelFormat.Format24bppRgb);
Color darkgray = Color.FromArgb(102,102,102);
Color lightgray = Color.FromArgb(153,153,153);
for (Int32 i = 0; i < 32; i++)
{
for (Int32 j = 0; j < 32; j++)
{
if ((i < 16 && j < 16) || (i >= 16 && j >= 16))
_checkerboard.SetPixel(j, i, lightgray);
else
_checkerboard.SetPixel(j, i, darkgray);
}
}
// background layer
Layer bglayer = _layers.Add();
Graphics g = Graphics.FromImage(bglayer._bitmap._bitmap);
TextureBrush brush = new TextureBrush(_checkerboard);
g.FillRectangle(brush, 0, 0, _width, _height);
brush.Dispose();
g.Dispose();
}