重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
'把图像读取到字节数组中进行处理:
创新互联公司专注为客户提供全方位的互联网综合服务,包含不限于成都网站建设、做网站、磴口网络推广、成都小程序开发、磴口网络营销、磴口企业策划、磴口品牌公关、搜索引擎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
这个问题不是小问题。如果只是90度转,vb点虐 的picture控件有RotateFlip方法。
任意角度,可以参考这个
;cs-lang=csharp
图片的变换涉及坐标处理,要自己算。
还有可以用Windows Presentation Foundation (WPF) 编程,里面的image控件好像也能旋转图片。
如果是VB6,恐怕只能用API函数了,百度一下“vb 旋转图片” “VB api函数”了解一下
直接反转的没有,改用PictureBox 的绘图方法是可以的,只是稍为繁琐点。
如:
Picture1.PaintPicture LoadPicture("C:\Users\Administrator\Desktop\09.jpg"), Picture1.ScaleWidth, 0, -Picture1.ScaleWidth
就是只要把宽度或高度参数变为负值,就会返转换过来。左右反转的话,x轴的起点在图片框右边。纵向反转,Y轴上的起点在下边。