本文整理汇总了C#中System.Drawing.Graphics.DrawImage方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.DrawImage方法的具体用法?C# Graphics.DrawImage怎么用?C# Graphics.DrawImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.DrawImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawImage2FloatRectF
public void DrawImage2FloatRectF(PaintEventArgs e)
{
// Create image.
Image newImage = Image.FromFile("SampImag.jpg");
// Create coordinates for upper-left corner of image.
float x = 100.0F;
float y = 100.0F;
// Create rectangle for source image.
RectangleF srcRect = new RectangleF(50.0F, 50.0F, 150.0F, 150.0F);
GraphicsUnit units = GraphicsUnit.Pixel;
// Draw image to screen.
e.Graphics.DrawImage(newImage, x, y, srcRect, units);
}
示例2: DrawImageCallback6
// Define DrawImageAbort callback method.
private bool DrawImageCallback6(IntPtr callBackData)
{
// Test for call that passes callBackData parameter.
if(callBackData==IntPtr.Zero)
{
// If no callBackData passed, abort DrawImage method.
return true;
}
else
{
// If callBackData passed, continue DrawImage method.
return false;
}
}
private void DrawImageRect4IntAtrribAbortData(PaintEventArgs e)
{
// Create callback method.
Graphics.DrawImageAbort imageCallback
= new Graphics.DrawImageAbort(DrawImageCallback6);
IntPtr imageCallbackData = new IntPtr(1);
// Create image.
Image newImage = Image.FromFile("SampImag.jpg");
// Create rectangle for displaying original image.
Rectangle destRect1 = new Rectangle(100, 25, 450, 150);
// Create coordinates of rectangle for source image.
int x = 50;
int y = 50;
int width = 150;
int height = 150;
GraphicsUnit units = GraphicsUnit.Pixel;
// Draw original image to screen.
e.Graphics.DrawImage(newImage, destRect1, x, y, width, height, units);
// Create rectangle for adjusted image.
Rectangle destRect2 = new Rectangle(100, 175, 450, 150);
// Create image attributes and set large gamma.
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetGamma(4.0F);
try
{
checked
{
// Draw adjusted image to screen.
e.Graphics.DrawImage(
newImage,
destRect2,
x, y,
width, height,
units,
imageAttr,
imageCallback,
imageCallbackData);
}
}
catch (Exception ex)
{
e.Graphics.DrawString(
ex.ToString(),
new Font("Arial", 8),
Brushes.Black,
new PointF(0, 0));
}
}
示例3: DrawImageCallback8
// Define DrawImageAbort callback method.
private bool DrawImageCallback8(IntPtr callBackData)
{
// Test for call that passes callBackData parameter.
if(callBackData==IntPtr.Zero)
{
// If no callBackData passed, abort DrawImage method.
return true;
}
else
{
// If callBackData passed, continue DrawImage method.
return false;
}
}
public void DrawImageRect4FloatAttribAbortData(PaintEventArgs e)
{
// Create callback method.
Graphics.DrawImageAbort imageCallback
= new Graphics.DrawImageAbort(DrawImageCallback8);
IntPtr imageCallbackData = new IntPtr(1);
// Create image.
Image newImage = Image.FromFile("SampImag.jpg");
// Create rectangle for displaying original image.
Rectangle destRect1 = new Rectangle(100, 25, 450, 150);
// Create coordinates of rectangle for source image.
float x = 50.0F;
float y = 50.0F;
float width = 150.0F;
float height = 150.0F;
GraphicsUnit units = GraphicsUnit.Pixel;
// Draw original image to screen.
e.Graphics.DrawImage(newImage, destRect1, x, y, width, height, units);
// Create rectangle for adjusted image.
Rectangle destRect2 = new Rectangle(100, 175, 450, 150);
// Create image attributes and set large gamma.
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetGamma(4.0F);
// Draw adjusted image to screen.
try
{
checked
{
// Draw adjusted image to screen.
e.Graphics.DrawImage(
newImage,
destRect2,
x, y,
width, height,
units,
imageAttr,
imageCallback,
imageCallbackData);
}
}
catch (Exception ex)
{
e.Graphics.DrawString(
ex.ToString(),
new Font("Arial", 8),
Brushes.Black,
new PointF(0, 0));
}
}
示例4: DrawImageCallback5
// Define DrawImageAbort callback method.
private bool DrawImageCallback5(IntPtr callBackData)
{
// Test for call that passes callBackData parameter.
if(callBackData==IntPtr.Zero)
{
// If no callBackData passed, abort DrawImage method.
return true;
}
else
{
// If callBackData passed, continue DrawImage method.
return false;
}
}
private void DrawImageRect4IntAtrribAbort(PaintEventArgs e)
{
// Create callback method.
Graphics.DrawImageAbort imageCallback
= new Graphics.DrawImageAbort(DrawImageCallback5);
// Create image.
Image newImage = Image.FromFile("SampImag.jpg");
// Create rectangle for displaying original image.
Rectangle destRect1 = new Rectangle(100, 25, 450, 150);
// Create coordinates of rectangle for source image.
int x = 50;
int y = 50;
int width = 150;
int height = 150;
GraphicsUnit units = GraphicsUnit.Pixel;
// Draw original image to screen.
e.Graphics.DrawImage(newImage, destRect1, x, y, width, height, units);
// Create rectangle for adjusted image.
Rectangle destRect2 = new Rectangle(100, 175, 450, 150);
// Create image attributes and set large gamma.
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetGamma(4.0F);
try
{
checked
{
// Draw adjusted image to screen.
e.Graphics.DrawImage(
newImage,
destRect2,
x, y,
width, height,
units,
imageAttr,
imageCallback);
}
}
catch (Exception ex)
{
e.Graphics.DrawString(
ex.ToString(),
new Font("Arial", 8),
Brushes.Black,
new PointF(0, 0));
}
}
示例5: DrawImageCallback7
// Define DrawImageAbort callback method.
private bool DrawImageCallback7(IntPtr callBackData)
{
// Test for call that passes callBackData parameter.
if(callBackData==IntPtr.Zero)
{
// If no callBackData passed, abort DrawImage method.
return true;
}
else
{
// If callBackData passed, continue DrawImage method.
return false;
}
}
private void DrawImageRect4FloatAttribAbort(PaintEventArgs e)
{
// Create callback method.
Graphics.DrawImageAbort imageCallback
= new Graphics.DrawImageAbort(DrawImageCallback7);
// Create image.
Image newImage = Image.FromFile("SampImag.jpg");
// Create rectangle for displaying original image.
Rectangle destRect1 = new Rectangle(100, 25, 450, 150);
// Create coordinates of rectangle for source image.
float x = 50.0F;
float y = 50.0F;
float width = 150.0F;
float height = 150.0F;
GraphicsUnit units = GraphicsUnit.Pixel;
// Draw original image to screen.
e.Graphics.DrawImage(newImage, destRect1, x, y, width, height, units);
// Create rectangle for adjusted image.
Rectangle destRect2 = new Rectangle(100, 175, 450, 150);
// Create image attributes and set large gamma.
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetGamma(4.0F);
try
{
checked
{
// Draw adjusted image to screen.
e.Graphics.DrawImage(
newImage,
destRect2,
x, y,
width, height,
units,
imageAttr,
imageCallback);
}
}
catch (Exception ex)
{
e.Graphics.DrawString(
ex.ToString(),
new Font("Arial", 8),
Brushes.Black,
new PointF(0, 0));
}
}
示例6: DrawImageRect4FloatAttrib
private void DrawImageRect4FloatAttrib(PaintEventArgs e)
{
// Create image.
Image newImage = Image.FromFile("SampImag.jpg");
// Create rectangle for displaying original image.
Rectangle destRect1 = new Rectangle(100, 25, 450, 150);
// Create coordinates of rectangle for source image.
float x = 50.0F;
float y = 50.0F;
float width = 150.0F;
float height = 150.0F;
GraphicsUnit units = GraphicsUnit.Pixel;
// Draw original image to screen.
e.Graphics.DrawImage(newImage, destRect1, x, y, width, height, units);
// Create rectangle for adjusted image.
Rectangle destRect2 = new Rectangle(100, 175, 450, 150);
// Create image attributes and set large gamma.
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetGamma(4.0F);
// Draw adjusted image to screen.
e.Graphics.DrawImage(newImage, destRect2, x, y, width, height, units, imageAttr);
}
示例7: DrawImageRect4IntAtrrib
private void DrawImageRect4IntAtrrib(PaintEventArgs e)
{
// Create image.
Image newImage = Image.FromFile("SampImag.jpg");
// Create rectangle for displaying original image.
Rectangle destRect1 = new Rectangle(100, 25, 450, 150);
// Create coordinates of rectangle for source image.
int x = 50;
int y = 50;
int width = 150;
int height = 150;
GraphicsUnit units = GraphicsUnit.Pixel;
// Draw original image to screen.
e.Graphics.DrawImage(newImage, destRect1, x, y, width, height, units);
// Create rectangle for adjusted image.
Rectangle destRect2 = new Rectangle(100, 175, 450, 150);
// Create image attributes and set large gamma.
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetGamma(4.0F);
// Draw adjusted image to screen.
e.Graphics.DrawImage(newImage, destRect2, x, y, width, height, units, imageAttr);
}
示例8: DrawImageRect4Float
private void DrawImageRect4Float(PaintEventArgs e)
{
// Create image.
Image newImage = Image.FromFile("SampImag.jpg");
// Create rectangle for displaying image.
Rectangle destRect = new Rectangle(100, 100, 450, 150);
// Create coordinates of rectangle for source image.
float x = 50.0F;
float y = 50.0F;
float width = 150.0F;
float height = 150.0F;
GraphicsUnit units = GraphicsUnit.Pixel;
// Draw image to screen.
e.Graphics.DrawImage(newImage, destRect, x, y, width, height, units);
}
示例9: DrawImageRect4Int
private void DrawImageRect4Int(PaintEventArgs e)
{
// Create image.
Image newImage = Image.FromFile("SampImag.jpg");
// Create rectangle for displaying image.
Rectangle destRect = new Rectangle(100, 100, 450, 150);
// Create coordinates of rectangle for source image.
int x = 50;
int y = 50;
int width = 150;
int height = 150;
GraphicsUnit units = GraphicsUnit.Pixel;
// Draw image to screen.
e.Graphics.DrawImage(newImage, destRect, x, y, width, height, units);
}
示例10: DrawImageCallback4
// Define DrawImageAbort callback method.
private bool DrawImageCallback4(IntPtr callBackData)
{
// Test for call that passes callBackData parameter.
if(callBackData==IntPtr.Zero)
{
// If no callBackData passed, abort DrawImage method.
return true;
}
else
{
// If callBackData passed, continue DrawImage method.
return false;
}
}
private void DrawImageParaFRectAttribAbortData(PaintEventArgs e)
{
// Create callback method.
Graphics.DrawImageAbort imageCallback
= new Graphics.DrawImageAbort(DrawImageCallback4);
int imageCallbackData = 1;
// Create image.
Image newImage = Image.FromFile("SampImag.jpg");
// Create parallelogram for drawing original image.
PointF ulCorner1 = new PointF(100.0F, 100.0F);
PointF urCorner1 = new PointF(325.0F, 100.0F);
PointF llCorner1 = new PointF(150.0F, 250.0F);
PointF[] destPara1 = {ulCorner1, urCorner1, llCorner1};
// Create rectangle for source image.
RectangleF srcRect = new RectangleF(50.0F, 50.0F, 150.0F, 150.0F);
GraphicsUnit units = GraphicsUnit.Pixel;
// Create parallelogram for drawing adjusted image.
PointF ulCorner2 = new PointF(325.0F, 100.0F);
PointF urCorner2 = new PointF(550.0F, 100.0F);
PointF llCorner2 = new PointF(375.0F, 250.0F);
PointF[] destPara2 = {ulCorner2, urCorner2, llCorner2};
// Draw original image to screen.
e.Graphics.DrawImage(newImage, destPara1, srcRect, units);
// Create image attributes and set large gamma.
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetGamma(4.0F);
try
{
checked
{
// Draw adjusted image to screen.
e.Graphics.DrawImage(
newImage,
destPara2,
srcRect,
units,
imageAttr,
imageCallback,
imageCallbackData);
}
}
catch (Exception ex)
{
e.Graphics.DrawString(
ex.ToString(),
new Font("Arial", 8),
Brushes.Black,
new PointF(0, 0));
}
}
示例11: DrawImageCallback2
// Define DrawImageAbort callback method.
private bool DrawImageCallback2(IntPtr callBackData)
{
// Test for call that passes callBackData parameter.
if(callBackData==IntPtr.Zero)
{
// If no callBackData passed, abort DrawImage method.
return true;
}
else
{
// If callBackData passed, continue DrawImage method.
return false;
}
}
private void DrawImageParaRectAttribAbortData(PaintEventArgs e)
{
// Create callback method.
Graphics.DrawImageAbort imageCallback
= new Graphics.DrawImageAbort(DrawImageCallback2);
int imageCallbackData = 1;
// Create image.
Image newImage = Image.FromFile("SampImag.jpg");
// Create parallelogram for drawing original image.
Point ulCorner = new Point(100, 100);
Point urCorner = new Point(550, 100);
Point llCorner = new Point(150, 250);
Point[] destPara1 = {ulCorner, urCorner, llCorner};
// Create rectangle for source image.
Rectangle srcRect = new Rectangle(50, 50, 150, 150);
GraphicsUnit units = GraphicsUnit.Pixel;
// Draw original image to screen.
e.Graphics.DrawImage(newImage, destPara1, srcRect, units);
// Create parallelogram for drawing adjusted image.
Point ulCorner2 = new Point(325, 100);
Point urCorner2 = new Point(550, 100);
Point llCorner2 = new Point(375, 250);
Point[] destPara2 = {ulCorner2, urCorner2, llCorner2};
// Create image attributes and set large gamma.
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetGamma(4.0F);
try
{
checked
{
// Draw image to screen.
e.Graphics.DrawImage(
newImage,
destPara2,
srcRect,
units,
imageAttr,
imageCallback,
imageCallbackData);
}
}
catch (Exception ex)
{
e.Graphics.DrawString(
ex.ToString(),
new Font("Arial", 8),
Brushes.Black,
new PointF(0, 0));
}
}
示例12: DrawImageCallback3
// Define DrawImageAbort callback method.
private bool DrawImageCallback3(IntPtr callBackData)
{
// Test for call that passes callBackData parameter.
if(callBackData==IntPtr.Zero)
{
// If no callBackData passed, abort DrawImage method.
return true;
}
else
{
// If callBackData passed, continue DrawImage method.
return false;
}
}
private void DrawImageParaFRectAttribAbort(PaintEventArgs e)
{
// Create callback method.
Graphics.DrawImageAbort imageCallback
= new Graphics.DrawImageAbort(DrawImageCallback3);
// Create image.
Image newImage = Image.FromFile("SampImag.jpg");
// Create parallelogram for drawing original image.
PointF ulCorner1 = new PointF(100.0F, 100.0F);
PointF urCorner1 = new PointF(325.0F, 100.0F);
PointF llCorner1 = new PointF(150.0F, 250.0F);
PointF[] destPara1 = {ulCorner1, urCorner1, llCorner1};
// Create rectangle for source image.
RectangleF srcRect = new RectangleF(50.0F, 50.0F, 150.0F, 150.0F);
GraphicsUnit units = GraphicsUnit.Pixel;
// Create parallelogram for drawing adjusted image.
PointF ulCorner2 = new PointF(325.0F, 100.0F);
PointF urCorner2 = new PointF(550.0F, 100.0F);
PointF llCorner2 = new PointF(375.0F, 250.0F);
PointF[] destPara2 = {ulCorner2, urCorner2, llCorner2};
// Draw original image to screen.
e.Graphics.DrawImage(newImage, destPara1, srcRect, units);
// Create image attributes and set large gamma.
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetGamma(4.0F);
try
{
checked
{
// Draw adjusted image to screen.
e.Graphics.DrawImage(
newImage,
destPara2,
srcRect,
units,
imageAttr,
imageCallback);
}
}
catch (Exception ex)
{
e.Graphics.DrawString(
ex.ToString(),
new Font("Arial", 8),
Brushes.Black,
new PointF(0, 0));
}
}
示例13: DrawImageCallback1
// Define DrawImageAbort callback method.
private bool DrawImageCallback1(IntPtr callBackData)
{
// Test for call that passes callBackData parameter.
if(callBackData==IntPtr.Zero)
{
// If no callBackData passed, abort DrawImage method.
return true;
}
else
{
// If callBackData passed, continue DrawImage method.
return false;
}
}
private void DrawImageParaRectAttribAbort(PaintEventArgs e)
{
// Create callback method.
Graphics.DrawImageAbort imageCallback
= new Graphics.DrawImageAbort(DrawImageCallback1);
// Create image.
Image newImage = Image.FromFile("SampImag.jpg");
// Create parallelogram for drawing original image.
Point ulCorner = new Point(100, 100);
Point urCorner = new Point(550, 100);
Point llCorner = new Point(150, 250);
Point[] destPara1 = {ulCorner, urCorner, llCorner};
// Create rectangle for source image.
Rectangle srcRect = new Rectangle(50, 50, 150, 150);
GraphicsUnit units = GraphicsUnit.Pixel;
// Draw original image to screen.
e.Graphics.DrawImage(newImage, destPara1, srcRect, units);
// Create parallelogram for drawing adjusted image.
Point ulCorner2 = new Point(325, 100);
Point urCorner2 = new Point(550, 100);
Point llCorner2 = new Point(375, 250);
Point[] destPara2 = {ulCorner2, urCorner2, llCorner2};
// Create image attributes and set large gamma.
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetGamma(4.0F);
try
{
checked
{
// Draw image to screen.
e.Graphics.DrawImage(
newImage,
destPara2,
srcRect,
units,
imageAttr,
imageCallback);
}
}
catch (Exception ex)
{
e.Graphics.DrawString(
ex.ToString(),
new Font("Arial", 8),
Brushes.Black,
new PointF(0, 0));
}
}
示例14: DrawImage4Int
public void DrawImage4Int(PaintEventArgs e)
{
// Create image.
Image newImage = Image.FromFile("SampImag.jpg");
// Create coordinates for upper-left corner.
// of image and for size of image.
int x = 100;
int y = 100;
int width = 450;
int height = 150;
// Draw image to screen.
e.Graphics.DrawImage(newImage, x, y, width, height);
}
示例15: DrawImage4Float
public void DrawImage4Float(PaintEventArgs e)
{
// Create image.
Image newImage = Image.FromFile("SampImag.jpg");
// Create coordinates for upper-left corner.
// of image and for size of image.
float x = 100.0F;
float y = 100.0F;
float width = 450.0F;
float height = 150.0F;
// Draw image to screen.
e.Graphics.DrawImage(newImage, x, y, width, height);
}