Изучаю пример работы с GetBitmapBits и все достаточно прозрачно за исключением битового сдвига. Привожу полный листинг:
- Код: Выделить всё
- Option Explicit
 
 'Create a new project, add a command button and a picture box to the project, load a picture into the picture box.
 'Paste this code into Form1
 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
 Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
 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
 Dim PicBits() As Byte, PicInfo As BITMAP '14b
 Dim Cnt As Long, BytesPerLine As Long
 
 
 Private Sub Command1_Click()
 'KPD-Team 1999
 'URL: http://www.allapi.net/
 'E-Mail: KPDTeam@Allapi.net
 'Get information (such as height and width) about the picturebox
 
 GetObject Picture1.Image, Len(PicInfo), PicInfo
 'reallocate storage space
 
 BytesPerLine = (PicInfo.bmWidth * 3 + 3) And &HFFFFFFFC
 
 ReDim PicBits(1 To BytesPerLine * PicInfo.bmHeight * 3) As Byte
 
 'Copy the bitmapbits to the array
 
 GetBitmapBits Picture1.Image, UBound(PicBits), PicBits(1)
 
 'Invert the bits
 For Cnt = 1 To UBound(PicBits)
 PicBits(Cnt) = 255 - PicBits(Cnt)
 Next Cnt
 'Set the bits back to the picture
 SetBitmapBits Picture1.Image, UBound(PicBits), PicBits(1)
 'refresh
 Picture1.Refresh
 
 End Sub
- Код: Выделить всё
- BytesPerLine = (PicInfo.bmWidth * 3 + 3) And &HFFFFFFFC
 
 ReDim PicBits(1 To BytesPerLine * PicInfo.bmHeight * 3) As Byte
зачем PicInfo.bmWidth умножают на 3 и прибавляют... и откуда взято значение &HFFFFFFFC,
Заранее спасибо!
VB-Constructor







 








