try
{
int width = thisMyBitmapWidth; //图像宽度
int height = thisMyBitmapHeight; //图像高度
Graphics g = thispanelCreateGraphics();
gClear(ColorGray); //初始为全灰色
Bitmap bitmap = new Bitmap(width height);
int x = ;
while (x <= width / )
{
for (int i = ; i <= height ; i++)
{
bitmapSetPixel(x i MyBitmapGetPixel(x i));
}
for (int i = ; i <= height ; i++)
{
bitmapSetPixel(width x i
MyBitmapGetPixel(width x i));
}
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 g = thispanelCreateGraphics();
gClear(ColorGray); //初始为全灰色
for (int j = height / ; j <= height / ; j++)
{
gClear(ColorGray); //初始为全灰色
int i = ConvertToInt(j * (ConvertToSingle(width) / ConvertToSingle(height)));
Rectangle DestRect = new Rectangle(width / i * i height);
Rectangle SrcRect = new Rectangle( MyBitmapWidth MyBitmapHeight);
gDrawImage(MyBitmap DestRect SrcRect GraphicsUnitPixel);
SystemThreadingThreadSleep();
}
}
catch (Exception ex)
{
MessageBoxShow(exMessage 信息提示);
}
}
[] [] [] [] [] [] [] [] [] []