/// <summary>
/// 左到右拉伸
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnLeftToRight_Click(object sender, EventArgs e)
{
int iWidth = this.pictureBox1.Width;
int iHeight = this.pictureBox1.Height;
Graphics g = this.pictureBox1.CreateGraphics();
g.Clear(Color.Gray);
for (int x = 0; x <= iWidth; x++)
{
g.DrawImage(bmp, 0, 0, x, iHeight);
}
}
/// <summary>
/// 上到下拉伸
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnUpToDown_Click(object sender, EventArgs e)
{
int iWidth = this.pictureBox1.Width;
int iHeight = this.pictureBox1.Height;
Graphics g = this.pictureBox1.CreateGraphics();
g.Clear(Color.Gray);
for (int y = 0; y <= iHeight; y++)
{
g.DrawImage(bmp, 0, 0, iWidth, y);
}
}
/// <summary>
/// 四周扩散
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnExtend_Click(object sender, EventArgs e)
{
int iWidth = this.pictureBox1.Width;
int iHeight = this.pictureBox1.Height;
Graphics g = this.pictureBox1.CreateGraphics();
g.Clear(Color.Gray); //初始为全灰色
for (int x = 0; x <= iWidth / 2; x++)
{
Rectangle DestRect = new Rectangle(iWidth / 2 - x,iHeight / 2 - x, 2 * x, 2 * x);
Rectangle SrcRect = new Rectangle(0, 0,bmp.Width, bmp.Height);
g.DrawImage(bmp, DestRect, SrcRect,GraphicsUnit.Pixel);
}
}
/// <summary>
/// 反转图像
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnBack_Click(object sender, EventArgs e)
{
int iWidth = this.pictureBox1.Width;
int iHeight = this.pictureBox1.Height;
Graphics g = this.pictureBox1.CreateGraphics();
g.Clear(Color.Gray);
for (int x = -iWidth / 2; x <= iWidth / 2; x++)
{
Rectangle DestRect = new Rectangle(0, iHeight / 2 - x,iWidth, 2 * x);
Rectangle SrcRect = new Rectangle(0, 0, bmp.Width, bmp.Height);
g.DrawImage(bmp, DestRect, SrcRect, GraphicsUnit.Pixel);
}
}
/// <summary>
/// 两边拉伸
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnBothSide_Click(object sender, EventArgs e)
{
int iWidth = this.pictureBox1.Width;
int iHeight = this.pictureBox1.Height;
Graphics g = this.pictureBox1.CreateGraphics();
g.Clear(Color.Gray);
for (int y = 0; y <= iWidth / 2; y++)
{
Rectangle DestRect = new Rectangle(iWidth / 2 - y, 0,2 * y, iHeight);
Rectangle SrcRect = new Rectangle(0, 0, bmp.Width, bmp.Height);
g.DrawImage(bmp, DestRect, SrcRect, GraphicsUnit.Pixel);
}
}
/// <summary>
/// 上下对接
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnUpDownConnect_Click(object sender, EventArgs e)
{
int iWidth = this.pictureBox1.Width;
int iHeight = this.pictureBox1.Height;
Graphics g = this.pictureBox1.CreateGraphics();
g.Clear(Color.Gray);
Bitmap bitmap = new Bitmap(iWidth, iHeight);
int x = 0;
while (x <= iHeight / 2)
{
for (int i = 0; i <= iWidth - 1; i++)
{
bitmap.SetPixel(i, x,bmp.GetPixel(i, x));
}
for (int i = 0; i <= iWidth - 1; i++)
{
bitmap.SetPixel(i, iHeight - x - 1,bmp.GetPixel(i, iHeight - x - 1));
}
x++;
this.pictureBox1.Refresh();
this.pictureBox1.Image = bitmap;
}
}
/// <summary>
/// 左右对接
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnLeftRightConnect_Click(object sender, EventArgs e)
{
int iWidth = this.pictureBox1.Width;
int iHeight = this.pictureBox1.Height;
Graphics g = this.pictureBox1.CreateGraphics();
g.Clear(Color.Gray);
Bitmap bitmap = new Bitmap(iWidth, iHeight);
int x = 0;
while (x <= iWidth / 2)
{
for (int i = 0; i <= iHeight - 1; i++)
{
bitmap.SetPixel(x, i, bmp.GetPixel(x, i));
}
for (int i = 0; i <= iHeight - 1; i++)
{
bitmap.SetPixel(iWidth - x - 1, i,bmp.GetPixel(iWidth - x - 1, i));
}
x++;
this.pictureBox1.Refresh();
this.pictureBox1.Image = bitmap;
}
}
1396

被折叠的 条评论
为什么被折叠?



