C#: Flip image horizontally

☆樱花仙子☆ 提交于 2019-12-21 12:19:11

问题


What I'm trying to do is, to flip image horizontally on radio button click.

private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
    arrow.Image.RotateFlip(RotateFlipType.RotateNoneFlipX);
}

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
    arrow.Image.RotateFlip(RotateFlipType.RotateNoneFlipX);
}

The code above doesn't flip image: image stays as it is. What am I missing?


回答1:


You need to cause it to redraw, you can force this manually by doing

 private void radioButton1_CheckedChanged(object sender, EventArgs e)
 {
     arrow.Image.RotateFlip(RotateFlipType.RotateNoneFlipX);
     arrow.Invalidate() ;
 }

You should also only have this on one of the radio buttons, not both, otherwise they'll negate each other, so replace your current stuff with the above. Just verified it works under vs2005, don't have vs2010 handy



来源:https://stackoverflow.com/questions/11318134/c-flip-image-horizontally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!