成都创新互联网站制作重庆分公司

vb.net实现图片翻转的简单介绍

vb中,怎么可以把一张图片旋转起来

这个问题不是小问题。如果只是90度转,vb.net的picture控件有RotateFlip方法。

创新互联主营卫辉网站建设的网络公司,主营网站建设方案,成都App制作,卫辉h5微信小程序定制开发搭建,卫辉网站营销推广欢迎卫辉等地区企业咨询

任意角度,可以参考这个

;cs-lang=csharp

图片的变换涉及坐标处理,要自己算。

还有可以用Windows Presentation Foundation (WPF) 编程,里面的image控件好像也能旋转图片。

如果是VB6,恐怕只能用API函数了,百度一下“vb 旋转图片” “VB api函数”了解一下

vb.net 怎么来回切换图片?

vb.net 怎么来回切换图片?1、添加控件Picturebox1和控件Timer1,将Timer1的Interval属性改为1000(即1秒),Enabled属性改为True

2、假设你要循环切换4张图片,你可以添加如下代码即可实现:

Dim a As Integer = 0

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

If a = 4 Then

a = 0

Else

a = a + 1

End If

If a = 0 Then Me.PictureBox1.Image = Image.FromFile("1.jpg")

If a = 1 Then Me.PictureBox1.Image = Image.FromFile("2.jpg")

If a = 2 Then Me.PictureBox1.Image = Image.FromFile("3.jpg")

If a = 3 Then Me.PictureBox1.Image = Image.FromFile("4.jpg")

End Sub

怎样用vb编写程序实现图片的水平翻转?

直接反转的没有,改用PictureBox 的绘图方法是可以的,只是稍为繁琐点。

如:

Picture1.PaintPicture LoadPicture("C:\Users\Administrator\Desktop\09.jpg"), Picture1.ScaleWidth, 0, -Picture1.ScaleWidth

就是只要把宽度或高度参数变为负值,就会返转换过来。左右反转的话,x轴的起点在图片框右边。纵向反转,Y轴上的起点在下边。

怎么用vb实现图形的旋转?

启动vb6建立一个标准exe工程,首先添加两个图片框(picture1和picture2),添加三个命令按钮command1(caption=“正常显示”)、command2(caption=“180度倒立”)、command3(caption=“45度旋转”),双击窗体,写入以下代码:

PrivateConstSRCCOPY=HCC0020

PrivateConstPi=3.14

PrivateDeclareFunctionSetPixelLib"gdi32"(ByValhdcAsLong, ByValxAsLong,ByValyAsLong,ByValcrColorAsLong)AsLong

PrivateDeclareFunctionGetPixelLib"gdi32"(ByValhdcAsLong, ByValxAsLong,ByValyAsLong)AsLong

PrivateDeclareFunctionStretchBltLib"gdi32"(ByValhdcAsLong, ByValxAsLong,ByValyAsLong,ByValnWidthAsLong,ByValnHeightAsLong, ByValhSrcDCAsLong,ByValxSrcAsLong,ByValySrcAsLong,ByValnSrcWidth AsLong,ByValnSrcHeightAsLong,ByValdwRopAsLong)AsLong

privateSubbmp_rotate(pic1AsPictureBox,pic2AsPictureBox,ByValtheta)‘45度旋转

Dimc1xAsInteger,c1yAsInteger

Dimc2xAsInteger,c2yAsInteger

DimaAsSingle

Dimp1xAsInteger,p1yAsInteger

Dimp2xAsInteger,p2yAsInteger

DimnAsInteger,rAsInteger

c1x=pic1.ScaleWidth\2

c1y=pic1.ScaleHeight\2

c2x=pic2.ScaleWidth\2

c2y=pic2.ScaleHeight\2

Ifc2x$#@60;c2yThenn=c2yElsen=c2x

n=n-1

pic1hDC=pic1.hdc

pic2hDC=pic2.hdc

Forp2x=0Ton

Forp2y=0Ton

Ifp2x=0Thena=Pi/2Elsea=Atn(p2y/p2x)

r=Sqr(1*p2x*p2x+1*p2y*p2y)

p1x=r*Cos(a+theta)

p1y=r*Sin(a+theta)

c0=GetPixel(pic1hDC,c1x+p1x,c1y+p1y)

c1=GetPixel(pic1hDC,c1x-p1x,c1y-p1y)

c2=GetPixel(pic1hDC,c1x+p1y,c1y-p1x)

c3=GetPixel(pic1hDC,c1x-p1y,c1y+p1x)

Ifc0$#@60;$#@62;-1ThenSetPixelpic2hDC,c2x+p2x,c2y+p2y,c0

Ifc1$#@60;$#@62;-1ThenSetPixelpic2hDC,c2x-p2x,c2y-p2y,c1

Ifc2$#@60;$#@62;-1ThenSetPi pic2hDC,c2x+p2y,c2y-p2x,c2

Ifc3$#@60;$#@62;-1ThenSetPixelpic2hDC,c2x-p2y,c2y+p2x,c3

Next

Next

EndSub

PrivateSubCommand1_Click()‘正常复制

Picture2.Cls

px=Picture1.ScaleWidth

py=Picture1.ScaleHeight

StretchBltPicture2.hdc,px,0,-px,py,Picture1.hdc,0,0,px,py,SRCCOPY

EndSub

PrivateSubCommand2_Click()‘180度倒立

Picture2.Cls

px=Picture1.ScaleWidth

py=Picture1.ScaleHeight

StretchBltPicture2.hdc,0,py,px,-py,Picture1.hdc,0,0,px,py,SRCCOPY

EndSub

PrivateSubCommand3_Click()‘45旋转

Picture2.Cls

Callbmp_rotate(Picture1,Picture2,3.14/4)

EndSub

PrivateSubForm_Load()

OnErrorResumeNext

Me.Caption=App.Title"添加应用程序标题

Me.Left=(Screen.Width-Me.Width)/2

Me.Top=(Screen.Height-Me.Height)/2"窗体具中

Picture1.ScaleMode=3

Picture2.ScaleMode=3

EndSub


标题名称:vb.net实现图片翻转的简单介绍
链接URL:http://cxhlcq.com/article/dopsdho.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部