旋转和翻转位图 [英] Rotating and Flipping a bitmap

查看:56
本文介绍了旋转和翻转位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将VB6程序转换为VB.NET。该程序从图形程序中获取符号数据,并在图片框中显示符号,并允许用户选择符号中字母周围的不同点。我正在绘制标志,但当我尝试找到点时,我遇到了问题。由于标志是颠倒绘制然后翻转,因此点不在我点击图片框的位置。你能提供任何帮助吗?当我点击字母上的一个点时,x和y与装载的相同。



谢谢

I am converting a VB6 program to VB.NET. This program takes sign data from graphics programs and displays the sign in a picturebox and allow the user to select the different points around the Letters in the sign. I am drawing the sign but when I try and locate the points is where I am having a problem. Since the sign is drawn upside down and then flipped the points are not where I am clicking on the picture box. Can you provide any help so that when I click on a point on the letter the x and y are the same as what was loaded.

Thanks

推荐答案

假设您必须使用的图像在x轴和y轴上旋转...换句话说,它是一个镜像。



在C#中:按钮'btnFlipXY,以及FormBox'在表单上的pbxImage。 PictureBox的SizeMode属性设置为'AutoSize
Assuming the image you have to work with is rotated on both x- and y- axes ... in other words, it's a "mirror image."

In C#: Button 'btnFlipXY, and PictureBox 'pbxImage on a Form. PictureBox 'SizeMode Property set to 'AutoSize
// required
using System.Drawing;

// Click EventHandler for 'btnFlipXY
private void btnFlipXY_Click(object sender, EventArgs e)
{
   Bitmap theImage = pbxImage.Image as Bitmap;
   theImage.RotateFlip(RotateFlipType.RotateNoneFlipXY);
   pbxImage.Image = theImage;
}

单击按钮一次并选择Points,并将Points存储在您选择的任何数据结构中。再次单击,图像将恢复到原始方向。



在VB.NET WinForms中:

Click the Button once and select the Points, and store the Points in whatever data-structure you've chosen. Click a second time, and the image is restored to its original orientation.

In VB.NET WinForms:

Private Sub btnFlipXY_Click(sender As Object, e As EventArgs) Handles btnFlipXY.Click

    Dim theImage
    theImage = pbxImage.Image

    theImage.RotateFlip(RotateFlipType.RotateNoneFlipXY)
    pbxImage.Image = theImage

End Sub

这是我第一次用VB编写代码,所以我不知道为什么在VB中不需要将PictureBox.Image转换为Type'Bitmap。在网上快速搜索表明这个声明会更好:

This is the first time I have ever coded in VB, so I don't know why a conversion of the PictureBox.Image to Type 'Bitmap is not required in VB. A quick search on the web suggests this declaration would be better:

Dim theImage As New Bitmap(pbxImage.Image)


首先,请参阅我最近的回答,这应该说服你不要使用 PictureBox 在现有位图上添加元素 [ ^ ]。



比尔解决方案1解释了你可以用位图做什么。当然,你可以做更多。 :-)



-SA
First of all, please see my recent answer which should convince you not to use PictureBox: add elements on existing bitmap[^].

And to Solution 1 by Bill explains you what you can do with a bitmap. Of course, you can do a lot more. :-)

—SA


要旋转Image,请在button_click事件中使用此代码:
To rotate Image use this code on a button_click event:
pictureBox1 .Image.RotateFlip(RotateFlipType.Rotate90FlipNone)
pictureBox1.Refresh()


这篇关于旋转和翻转位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆