本文整理汇总了C#中System.Drawing.Graphics.DrawImageUnscaled方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.DrawImageUnscaled方法的具体用法?C# Graphics.DrawImageUnscaled怎么用?C# Graphics.DrawImageUnscaled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.DrawImageUnscaled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawBackgroundStyle
public static void DrawBackgroundStyle(Graphics g, Point location, Size size, Background background)
{
// draw background color
g.FillRectangle(
new SolidBrush(System.Drawing.Color.FromKnownColor(background.Color)),
location.X,
location.Y,
size.Width,
size.Height);
// draw background image
if (background.Image != null)
{
Image bg = background.Image; // Image.FromFile(this.Background.Image);
switch (background.Repeat)
{
case BackgroundRepeat.Undefined:
case BackgroundRepeat.Tile:
for (int i = 0; i < size.Width / bg.Width; i++)
for (int j = 0; j < size.Height / bg.Height; j++)
g.DrawImageUnscaled(bg, location.X + i * bg.Width, location.Y + j * bg.Height);
break;
case BackgroundRepeat.Strech:
g.DrawImage(bg, location.X, location.Y, size.Width, size.Height);
break;
case BackgroundRepeat.Center:
int posX = location.X + size.Width / 2 - bg.Width / 2;
int posY = location.Y + size.Height / 2 - bg.Height / 2;
g.DrawImageUnscaled(bg, posX, posY);
break;
default:
break;
}
}
}
示例2: Draw
public void Draw(int i, int j, Graphics g)
{
if (this.Orientation == 1)
triImage = Properties.Resources.t1;
if (this.Orientation == 2)
triImage = Properties.Resources.t2;
if (this.Orientation == 3)
triImage = Properties.Resources.t3;
if (this.Orientation == 4)
triImage = Properties.Resources.t4;
if (this.Orientation == 5)
triImage = Properties.Resources.yellow;
if (this.Orientation == 6)
triImage = Properties.Resources.red;
if (this.Orientation == 0)
triImage = Properties.Resources.cleared;
if (triImage != null)
{
if (this.Orientation != 0)
g.DrawImageUnscaled(Properties.Resources.cleared, new Point(8 + 17 * i + i * triImage.Width, 6 + 17 * j + j * triImage.Height));
g.DrawImageUnscaled(triImage, new Point(8 + 17 * i + i * triImage.Width, 6 + 17 * j + j * triImage.Height));
}
}
示例3: Draw
public void Draw(Graphics e)
{
kolizija = new Bitmap(ozadje);
e.Clear(Color.Black);
e.DrawImageUnscaled(ozadje, 0, 0);
e.DrawImageUnscaled(igralci, 0, 0);
}
示例4: OnRender
public override void OnRender(Graphics g)
{
#if !PocketPC
if(!Bearing.HasValue)
{
g.DrawImageUnscaled(Resources.shadow50, LocalPosition.X, LocalPosition.Y);
}
g.TranslateTransform(ToolTipPosition.X, ToolTipPosition.Y);
if(Bearing.HasValue)
{
g.RotateTransform(Bearing.Value - Overlay.Control.Bearing);
g.FillPolygon(Brushes.Lime, Arrow);
}
g.ResetTransform();
if(!Bearing.HasValue)
{
g.DrawImageUnscaled(Resources.bigMarkerGreen, LocalPosition.X, LocalPosition.Y);
}
#else
DrawImageUnscaled(g, Resources.shadow50, LocalPosition.X, LocalPosition.Y);
DrawImageUnscaled(g, Resources.marker, LocalPosition.X, LocalPosition.Y);
#endif
}
示例5: OnRender
public override void OnRender(Graphics g)
{
if (shotBellowMinInterval)
g.DrawImageUnscaled(localcache2, LocalPosition.X, LocalPosition.Y);
else
g.DrawImageUnscaled(localcache1, LocalPosition.X, LocalPosition.Y);
if (drawfootprint || IsMouseOver)
{
Overlay.Control.UpdatePolygonLocalPosition(footprintpoly);
footprintpoly.OnRender(g);
}
}
示例6: ShowHouses
/// <summary>
/// Shows houses or hotels.
/// </summary>
public override void ShowHouses(Graphics g, int numberOfHouses)
{
if(numberOfHouses == 5)
{
g.DrawImageUnscaled(HotelVertical, Left, Top + 6);
}
else if(numberOfHouses >= 1 && numberOfHouses <= 4)
{
for (int i = 0; i < numberOfHouses; ++i)
{
g.DrawImageUnscaled(HouseVertical, Left, Bottom - i * 10 - 13);
}
}
}
示例7: draw
/*
* @param graphics
*/
public override void draw(Graphics graphics)
{
if (turnRight)
{
// this is just a sample draw routine. It needs to be overrided by the child object
Bitmap bitmap = elements[((int)getTicks() * speed % (360 / TURN_ANGLE))];
graphics.DrawImageUnscaled(bitmap, getX(), getY(), bitmap.Width, bitmap.Height);
}
else
{
// this is just a sample draw routine. It needs to be overrided by the child object
Bitmap bitmap = elements[((360 / TURN_ANGLE) - ((int)getTicks() * speed % (360 / TURN_ANGLE)) - 1)];
graphics.DrawImageUnscaled(bitmap, getX(), getY(), bitmap.Width, bitmap.Height);
}
}
示例8: Render
public override void Render(Graphics graphics, IRender render)
{
byte opacity = 100;
if (Table != null) opacity = Table.Opacity;
//Draw indent
SolidBrush brush = new SolidBrush(render.AdjustColor(Backcolor,1,opacity));
brush.Color = Color.FromArgb(brush.Color.A /2, brush.Color);
graphics.FillRectangle(brush,0,Rectangle.Top,Indent,Rectangle.Height);
//Draw image
float imageWidth = 0;
if (Image != null)
{
System.Drawing.Image bitmap = Image.Bitmap;
//Work out position of image
float imageTop = (Rectangle.Height - bitmap.Height) / 2;
if (imageTop < 0) imageTop = 0;
imageWidth = bitmap.Width;
graphics.DrawImageUnscaled(bitmap,Convert.ToInt32(Indent),Convert.ToInt32(Rectangle.Top+imageTop));
}
//Draw text
RectangleF textRectangle = new RectangleF(Indent+imageWidth+4,Rectangle.Top,Rectangle.Width - Indent -4,Rectangle.Height);
brush = new SolidBrush(render.AdjustColor(Forecolor,1,opacity));
StringFormat format = new StringFormat();
format.LineAlignment = StringAlignment.Center;
format.FormatFlags = StringFormatFlags.NoWrap;
graphics.DrawString(Text,Component.Instance.GetFont(FontName,FontSize,FontStyle),brush,textRectangle,format);
}
示例9: RefreshInRect
internal void RefreshInRect(Graphics eg, Rectangle rect) {
if (!gbRefresh) return;
Random rnd = new Random();
if (rect.Width <= 0 || rect.Height <= 0) return;
//using (Graphics eg = base.CreateGraphics()) {
using (Bitmap Bmp = new Bitmap(rect.Width, rect.Height)) {
using (Graphics g = Graphics.FromImage(Bmp)) {
g.Clear(Color.White);
//发送绘制消息
PaintMessage m = new PaintMessage(g, rect);
gManager.SendMessage(m);
}
if (eg != null) {
eg.DrawImageUnscaled(Bmp, rect.X, rect.Y);
} else {
try {
using (Graphics g = this.CreateGraphics()) {
g.DrawImageUnscaled(Bmp, rect.X, rect.Y);
//System.Diagnostics.Debug.WriteLine("GPanel\\>RefreshInRect" + rect.ToString());
}
} catch { }
}
}
}
示例10: Draw
public void Draw(Graphics g, int animationCell, bool gameOver)
{
g.FillRectangle(Brushes.Black, boundaries);
stars.Draw(g);
playerShip.Draw(g);
foreach (Invader invader in invaders)
invader.Draw(g, animationCell);
foreach (Shot shot in playerShots)
shot.Draw(g);
foreach (Shot shot in invaderShots)
shot.Draw(g);
using (Font font = new Font("Arial", 24, FontStyle.Bold))
g.DrawString(score.ToString(), font, Brushes.Red, boundaries.X + 20, boundaries.Y + 20);
g.DrawImageUnscaled(Properties.Resources.player,
new Point(boundaries.Right - 110, boundaries.Top + 10));
using (Font font = new Font("Arial", 20))
g.DrawString("X " + livesLeft, font, Brushes.Yellow, boundaries.Right - 50, boundaries.Top + 10);
if (gameOver)
{
using (Font font = new Font("Arial", 40))
g.DrawString("Game Over", font, Brushes.Purple,
(boundaries.Width / 3), boundaries.Height / 3);
using (Font font = new Font("Arial", 20))
g.DrawString("Press 'Q' to quit\nor 'S' to restart", font, Brushes.Purple,
boundaries.Width / 3 + 45, boundaries.Height / 3 + 50);
}
}
示例11: DrawBitmapInto
public void DrawBitmapInto(Graphics g, Point TLPoint, Size ViewPortSize, int squareS, bool isBichrom, bool forcePrecomputing = false)
{
// squareSize has changed OR no map has been loaded so far
if (cachedBitmap == null ||
squareSize != squareS ||
cachedBitmapTLPoint.X > TLPoint.X || cachedBitmapTLPoint.Y > TLPoint.Y ||
(cachedBitmapTLPoint.X + cachedBitmap.Width < getMapPixelSize().Width &&
cachedBitmapTLPoint.X + cachedBitmap.Width < TLPoint.X + ViewPortSize.Width) ||
(cachedBitmapTLPoint.Y + cachedBitmap.Height < getMapPixelSize().Height &&
cachedBitmapTLPoint.Y + cachedBitmap.Height < TLPoint.Y + ViewPortSize.Height) ||
isBichrom != isBichromatic ||
forcePrecomputing
)
{
//System.Windows.Forms.MessageBox.Show("cachedBitmap == null");
squareSize = squareS;
isBichromatic = isBichrom;
PrecomputeBitmap(TLPoint, ViewPortSize);
}
// Draw it on the buffered bitmap
bufferedBitmapGraphics.Clear(Color.White);
Point relativeTLPoint = new Point(cachedBitmapTLPoint.X - TLPoint.X, cachedBitmapTLPoint.Y - TLPoint.Y);
Rectangle rect = new Rectangle(relativeTLPoint, ViewPortSize);
bufferedBitmapGraphics.DrawImageUnscaled(cachedBitmap, rect);
g.DrawImageUnscaled(bufferedBitmap, 0, 0);
}
示例12: DrawString
public void DrawString(string text, Graphics graphics, int x, int y,
int? maxWidth = null, int extraGap = 0)
{
int lineGap = baseLineGap + extraGap;
foreach (char ch in text) {
if (ch == '\r')
continue;
// If a new line char, go to next line.
if (ch == '\n') {
x = 0;
y += lineGap;
continue;
}
// Get glyph, if not found, take the deafault char.
var glyph = font.SearchGlyphByChar(ch) ?? defaultChar;
// If we are over the max width, go to next line.
if (maxWidth.HasValue && x + glyph.Width.Advance > maxWidth) {
x = 0;
y += lineGap;
}
x += glyph.Width.BearingX;
graphics.DrawImageUnscaled(glyph.ToImage(1, true), x, y);
x += glyph.Width.Advance - glyph.Width.BearingX;
}
}
示例13: ProcessLabelItem
private static void ProcessLabelItem(LabelItem labelItem, Graphics g, PrintLabelSettings settings)
{
switch (labelItem.LabelType)
{
case LabelTypesEnum.Label:
g.DrawString(labelItem.LabelText,
new Font(labelItem.FontName ?? "Arial", labelItem.FontSize, (labelItem.IsBold ? FontStyle.Bold : FontStyle.Regular) | (labelItem.IsItalic ? FontStyle.Italic : FontStyle.Regular)),
Brushes.Black, labelItem.StartX, labelItem.StartY);
break;
case LabelTypesEnum.BarCode:
var content = labelItem.LabelText;
var writer = new BarcodeWriter
{
Format = BarcodeFormat.CODE_128,
Options = new ZXing.QrCode.QrCodeEncodingOptions
{
ErrorCorrection = ZXing.QrCode.Internal.ErrorCorrectionLevel.H,
Width = settings.BarCodeMaxWidth,
Height = settings.BarCodeHeight,
PureBarcode = true,
}
};
var barCodeBmp = writer.Write(content);
g.DrawImageUnscaled(barCodeBmp, labelItem.StartX, labelItem.StartY);
break;
case LabelTypesEnum.Stamp:
var pen = new Pen(Color.Black, 2);
g.DrawEllipse(pen, labelItem.StartX, labelItem.StartY, settings.StampDiameter, settings.StampDiameter);
g.DrawString(labelItem.LabelText,
new Font(labelItem.FontName ?? "Arial", labelItem.FontSize, (labelItem.IsBold ? FontStyle.Bold : FontStyle.Regular) | (labelItem.IsItalic ? FontStyle.Italic : FontStyle.Regular)),
Brushes.Black, labelItem.StartX + 2, labelItem.StartY + 11);
break;
}
}
示例14: DrawFormBackgroud
public void DrawFormBackgroud(Graphics g, Rectangle r)
{
drawing = new Bitmap(this.Width, this.Height, g);
gg = Graphics.FromImage(drawing);
Rectangle shadowRect = new Rectangle(r.X, r.Y, r.Width, 10);
Rectangle gradRect = new Rectangle(r.X, r.Y + 9, r.Width, 42);
//LinearGradientBrush shadow = new LinearGradientBrush(shadowRect, Color.FromArgb(30, 41, 61), Color.FromArgb(47, 64, 94), LinearGradientMode.Vertical);
LinearGradientBrush shadow = new LinearGradientBrush(shadowRect, Color.FromArgb(30, 61, 41), Color.FromArgb(47, colorR, 64), LinearGradientMode.Vertical);
//LinearGradientBrush grad = new LinearGradientBrush(gradRect, Color.FromArgb(47, 64, 94), Color.FromArgb(49, 66, 95), LinearGradientMode.Vertical);
LinearGradientBrush grad = new LinearGradientBrush(gradRect, Color.Green, Color.DarkGreen, LinearGradientMode.Vertical);
ColorBlend blend = new ColorBlend();
// Set multi-color gradient
blend.Positions = new[] { 0.0f, 0.35f, 0.5f, 0.65f, 1.0f };
//blend.Colors = new[] { Color.FromArgb(47, 64, 94), Color.FromArgb(64, 88, 126), Color.FromArgb(66, 90, 129), Color.FromArgb(64, 88, 126), Color.FromArgb(49, 66, 95) };
blend.Colors = new[] { Color.FromArgb(47,colorR, 64), Color.FromArgb(64, colorR+32, 88), Color.FromArgb(66, colorR+35, 90), Color.FromArgb(64, colorR+32, 88), Color.FromArgb(49, colorR+1, 66) };
grad.InterpolationColors = blend;
Font myf=new System.Drawing.Font(this.Font.FontFamily,16);
// Draw basic gradient and shadow
//gg.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
gg.FillRectangle(grad, gradRect);
gg.FillRectangle(shadow, shadowRect);
gg.DrawString("Добавить один ПК", myf, Brushes.GhostWhite, new PointF(55, 15));
gg.DrawImage(Properties.Resources.singleAdd1.ToBitmap(), 10, 10,32,32);
g.DrawImageUnscaled(drawing, 0, 0);
gg.Dispose();
// Draw checkers
//g.FillRectangle(checkers, r);
}
示例15: DrawFormBackgroud
public void DrawFormBackgroud(Graphics g, Rectangle r)
{
drawing = new Bitmap(this.Width, AnimSize, g);
gg = Graphics.FromImage(drawing);
Rectangle shadowRect = new Rectangle(r.X, r.Y, r.Width, 10);
Rectangle gradRect = new Rectangle(r.X, r.Y + 9, r.Width, AnimSize-9);
LinearGradientBrush shadow = new LinearGradientBrush(shadowRect, Color.FromArgb(30, 61, 61), Color.FromArgb(47, colorR, colorR), LinearGradientMode.Vertical);
//LinearGradientBrush shadow = new LinearGradientBrush(shadowRect, Color.FromArgb(30, 61, 41), Color.FromArgb(47, colorR, 64), LinearGradientMode.Vertical);
LinearGradientBrush grad = new LinearGradientBrush(gradRect, Color.FromArgb(47, 64, 94), Color.FromArgb(49, 66, 95), LinearGradientMode.Vertical);
//LinearGradientBrush grad = new LinearGradientBrush(gradRect, Color.Green, Color.DarkGreen, LinearGradientMode.Vertical);
ColorBlend blend = new ColorBlend();
// Set multi-color gradient
blend.Positions = new[] { 0.0f, 0.35f, 0.5f, 0.65f, 0.95f,1f };
blend.Colors = new[] { Color.FromArgb(47, colorR, colorR), Color.FromArgb(64, colorR + 22, colorR + 32), Color.FromArgb(66, colorR + 20, colorR + 35), Color.FromArgb(64, colorR + 20, colorR + 32), Color.FromArgb(49, colorR, colorR + 1), SystemColors.Control };
//blend.Colors = new[] { Color.FromArgb(47, colorR, 64), Color.FromArgb(64, colorR + 32, 88), Color.FromArgb(66, colorR + 35, 90), Color.FromArgb(64, colorR + 32, 88), Color.FromArgb(49, colorR + 1, 66),SystemColors.Control };
grad.InterpolationColors = blend;
Font myf = new System.Drawing.Font(this.Font.FontFamily, 16);
// Draw basic gradient and shadow
//gg.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
gg.FillRectangle(grad, gradRect);
gg.FillRectangle(shadow, shadowRect);
gg.TextRenderingHint = TextRenderingHint.AntiAlias;
gg.DrawString("Поиск по ресурсам сети", myf, Brushes.GhostWhite, new PointF(55, 15));
gg.DrawImage(Properties.Resources.search1.ToBitmap(), 10, 10,32,32);
g.DrawImageUnscaled(drawing, 0, 0);
gg.Dispose();
// Draw checkers
//g.FillRectangle(checkers, r);
}