包含vb.net位图能旋转吗的词条

VB怎样使图形或控件按角度旋转?

如果是控件,暂时没有这个功能;如果是图片的话,就目前来说,需要使用Point方法和PSet方法。通过坐标变换自己手动写代码,很麻烦,而且效率很低,除非你用其他语言写一个DLL,直接通过Bitmap绘制,这样会比较快一点。

成都创新互联专业为企业提供福山网站建设、福山做网站、福山网站设计、福山网站制作等企业网站建设、网页设计与制作、福山企业网站模板建站服务,10余年福山做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

VB 如何旋转图片

你的“旋转”操作的用途是什么?

这个很重要的问题,居然只字未提……

如果是想把图片旋转后进行绘制(输出),可以用API函数PlgBlt( )来完成。

 用它可以任意角度旋转(也支持透明的)后绘制。

如果你要把图片文件旋转后,形成另一个图片文件,这个我就不清楚如何处理了。

(当然不透明还是好办,但要保持原来的透明部分仍然透明,我还真没把握)

怎么用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中怎样实现image图像框的90,180,270度旋转,不是图形框picturebox哦,希望用简单点方式

image图像框只是如实反映图像,要旋转图像才行。

先把img的图像存到pic,旋转后再........。

下面是旋转pic的,原图image=》picMMM,

处理后=》picAAA,再=》image

Public Sub bbsXuanZhuan(RorV As Integer) '旋转or镜像

''模块级声明 用于旋转位图

'Declare Function PlgBlt Lib "gdi32" (ByVal hdcDest As Long, lpPoint As POINTAPI, ByVal hdcSrc As Long, ByVal nXSrc As Long, ByVal nYSrc As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hbmMask As Long, ByVal xMask As Long, ByVal yMask As Long) As Long

'Private Type POINTAPI

' X As Long

' Y As Long

'End Type

'Const pt = 15 '1 像素 = 15 pix

Dim MyPoint(2) As POINTAPI

Select Case RorV

Case 1 '90

MyPoint(0).X = 0

MyPoint(0).Y = picMMM.Width / pt

MyPoint(1).X = 0

MyPoint(1).Y = 0

MyPoint(2).X = picMMM.Height / pt

MyPoint(2).Y = picMMM.Width / pt

picAAA.Width = picMMM.Height

picAAA.Height = picMMM.Width

Case 2 '180

MyPoint(0).X = picMMM.Width / pt

MyPoint(0).Y = picMMM.Height / pt

MyPoint(1).X = 0

MyPoint(1).Y = picMMM.Height / pt

MyPoint(2).X = picMMM.Width / pt

MyPoint(2).Y = 0

picAAA.Width = picMMM.Width

picAAA.Height = picMMM.Height

Case 0 '270

MyPoint(0).X = picMMM.Height / pt

MyPoint(0).Y = 0

MyPoint(1).X = picMMM.Height / pt

MyPoint(1).Y = picMMM.Width / pt

MyPoint(2).X = 0

MyPoint(2).Y = 0

picAAA.Width = picMMM.Height

picAAA.Height = picMMM.Width

Case 4 '垂直

MyPoint(0).X = 0

MyPoint(0).Y = picMMM.Height / pt

MyPoint(1).X = picMMM.Width / pt

MyPoint(1).Y = picMMM.Height / pt

MyPoint(2).X = 0

MyPoint(2).Y = 0

picAAA.Width = picMMM.Width

picAAA.Height = picMMM.Height

Case 3 '水平

MyPoint(0).X = picMMM.Width / pt

MyPoint(0).Y = 0

MyPoint(1).X = 0

MyPoint(1).Y = 0

MyPoint(2).X = picMMM.Width / pt

MyPoint(2).Y = picMMM.Height / pt

picAAA.Width = picMMM.Width

picAAA.Height = picMMM.Height

Case Else

Exit Sub

End Select

'旋转位图

PlgBlt picAAA.hdc, MyPoint(0), picMMM.hdc, 0, 0, picMMM.Width / pt, picMMM.Height / pt, 0, 0, 0

End Sub

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

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

任意角度,可以参考这个

;cs-lang=csharp

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

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

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


网站标题:包含vb.net位图能旋转吗的词条
文章起源:http://azwzsj.com/article/hepdpj.html