本文整理汇总了C#中System.Drawing.Image.Height属性的典型用法代码示例。如果您正苦于以下问题:C# Image.Height属性的具体用法?C# Image.Height怎么用?C# Image.Height使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Drawing.Image
的用法示例。
在下文中一共展示了Image.Height属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Button1_Click
Bitmap image1;
private void Button1_Click(System.Object sender, System.EventArgs e)
{
try
{
// Retrieve the image.
image1 = new Bitmap(@"C:\Documents and Settings\All Users\"
+ @"Documents\My Music\music.bmp", true);
int x, y;
// Loop through the images pixels to reset color.
for(x=0; x<image1.Width; x++)
{
for(y=0; y<image1.Height; y++)
{
Color pixelColor = image1.GetPixel(x, y);
Color newColor = Color.FromArgb(pixelColor.R, 0, 0);
image1.SetPixel(x, y, newColor);
}
}
// Set the PictureBox to display the image.
PictureBox1.Image = image1;
// Display the pixel format in Label1.
Label1.Text = "Pixel format: "+image1.PixelFormat.ToString();
}
catch(ArgumentException)
{
MessageBox.Show("There was an error." +
"Check the path to the image file.");
}
}
示例2: Main
//引入命名空间
using System;
using System.Drawing;
using System.Windows.Forms;
class CenterPixelSizeImage: Form
{
Image image = Image.FromFile("Color.jpg");
public static void Main()
{
Application.Run(new CenterPixelSizeImage());
}
public CenterPixelSizeImage()
{
ResizeRedraw = true;
}
protected override void OnPaint(PaintEventArgs pea)
{
DoPage(pea.Graphics, ForeColor,ClientSize.Width, ClientSize.Height);
}
protected void DoPage(Graphics grfx, Color clr, int cx, int cy)
{
grfx.DrawImage(image, (cx - image.Width) / 2,
(cy - image.Height) / 2,
image.Width, image.Height);
}
}