vb点虐 图片水平翻转 vb怎么把图片左右移动

vb 图片翻转(水平和竖直)函数代码

'把图像读取到字节数组中进行处理:

创新互联公司专注为客户提供全方位的互联网综合服务,包含不限于成都网站建设、做网站、磴口网络推广、成都小程序开发、磴口网络营销、磴口企业策划、磴口品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联公司为所有大学生创业者提供磴口建站搭建服务,24小时服务热线:13518219792,官方网址:www.cdcxhl.com

Private Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long

Private Declare Function SetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long

Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long

Private Type Bitmap

bmType As Long

bmWidth As Long

bmHeight As Long

bmWidthBytes As Long

bmPlanes As Integer

bmBitsPixel As Integer

bmBits As Long

End Type

Sub ReverseImage(img As StdPicture, Optional UpDownOrLeftRight As Boolean = False)

With img

Dim BmpInfo As Bitmap

GetObject .Handle, Len(BmpInfo), BmpInfo

Dim BytesPixel As Integer

BytesPixel = BmpInfo.bmBitsPixel / 8

Dim Bits() As Byte

ReDim Bits(BmpInfo.bmWidthBytes - 1, BmpInfo.bmHeight - 1)

GetBitmapBits .Handle, BmpInfo.bmWidthBytes * BmpInfo.bmHeight, Bits(0, 0)

Dim rBits() As Byte

ReDim rBits(BmpInfo.bmWidthBytes - 1, BmpInfo.bmHeight - 1)

Dim Y As Integer, X As Integer

Dim p As Integer

If UpDownOrLeftRight Then

Dim rR As Integer, sR As Integer

For Y = BmpInfo.bmHeight - 1 To 0 Step -1

rR = BmpInfo.bmHeight - 1 - Y

For X = 0 To BmpInfo.bmWidthBytes - 1

rBits(X, rR) = Bits(X, Y)

Next X

Next Y

Else

Dim rIndex As Integer

Dim sIndex As Integer

For Y = 0 To BmpInfo.bmHeight - 1

For X = BmpInfo.bmWidth - 1 To 0 Step -1

sIndex = X * BytesPixel

rIndex = (BmpInfo.bmWidth - 1 - X) * BytesPixel

For p = sIndex To sIndex + 2

rBits(rIndex, Y) = Bits(p, Y)

rIndex = rIndex + 1

Next

Next X

Next Y

End If

Call SetBitmapBits(.Handle, BmpInfo.bmWidthBytes * BmpInfo.bmHeight, rBits(0, 0))

End With

End Sub

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

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

任意角度,可以参考这个

;cs-lang=csharp

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

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

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

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

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

如:

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

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

当前文章:vb点虐 图片水平翻转 vb怎么把图片左右移动
本文网址:https://www.cdcxhl.com/article44/ddgcjhe.html

成都网站建设公司_创新互联,为您提供虚拟主机软件开发响应式网站定制开发网站策划

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

外贸网站建设