代码:
private void button
_Click(object sender
EventArgs e)
{
try
{
int width = thispictureBoxWidth; //图像宽度
int height = thispictureBoxHeight; //图像高度
Graphics g = thispanelCreateGraphics();
gClear(ColorGray);
Bitmap bitmap = new Bitmap(width height);
int x = ;
while (x <= height / )
{
for (int i = ; i <= width ; i++)
{
bitmapSetPixel(i x MyBitmapGetPixel(i x));
}
for (int i = ; i <= width ; i++)
{
bitmapSetPixel(i height x MyBitmapGetPixel(i height x ));
}
x++;
thispanelRefresh();
gDrawImage (bitmap);
SystemThreadingThreadSleep();
}
}
catch (Exception ex)
{
MessageBoxShow(exMessage 信息提示);
}
}
三 以四周扩散的方式显示图像
原理: 首先设置图像显示的位置 然后按高度和宽度的比例循环输出 直到高度和宽度为原始大小
代码:
private void button
_Click(object sender
EventArgs e)
{
try
{
int width = thisMyBitmapWidth; //图像宽度
int height = thisMyBitmapHeight; //图像高度
//取得Graphics对象
Graphics g = thispanelCreateGraphics();
gClear(ColorGray); //初始为全灰色
for (int i = ; i <= width / ; i++)
{
int j = ConvertToInt (i*(ConvertToSingle(height) / ConvertToSingle(width)));
Rectangle DestRect = new Rectangle(width / i height/j * i *j);
Rectangle SrcRect = new Rectangle( MyBitmapWidth MyBitmapHeight);
gDrawImage(MyBitmap DestRect SrcRect GraphicsUnitPixel);
SystemThreadingThreadSleep();
}
}
catch (Exception ex)
{
MessageBoxShow(exMessage 信息提示);
}
}
[] [] [] [] [] [] [] [] [] []