1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
Const LR_LOADFROMFILE = &H10
Const IMAGE_BITMAP = 0
Const IMAGE_ICON = 1
Const IMAGE_CURSOR = 2
Const IMAGE_ENHMETAFILE = 3
Const CF_BITMAP = 2
Const CF_DIB = 8
Const clRed = &HFF&
Const clGreen = &H8000&
Const clBlue = &HFF0000
Const clPurple = &H800080
Const clMaroon = &H4080&
Private Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal dwImageType As Long, ByVal dwDesiredWidth As Long, ByVal dwDesiredHeight As Long, ByVal dwFlags As Long) As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function EmptyClipboard Lib "user32" () As Long
Private Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As Long
Private Declare Function IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Long) As Long
Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal lpvDest As Long, ByVal lpvSource As Long, ByVal cbCopy As Long)
Private Declare Function GetObjectApi Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Private Declare Function SetDIBits Lib "gdi32" (ByVal hdc As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO, ByVal wUsage As Long) As Long
Private Declare Function GetDIBits Lib "gdi32" (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO, ByVal wUsage As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) 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
Private Declare Function CreateDCAsNull Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, lpDeviceName As Any, lpOutput As Any, lpInitData As Any) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth _
As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As _
Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function StretchDIBits Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal dx As Long, ByVal dy As Long, ByVal SrcX As Long, ByVal SrcY As Long, ByVal wSrcWidth As Long, ByVal wSrcHeight As Long, ByVal lpBits As Long, lpBitsInfo As BITMAPINFO, ByVal wUsage As Long, ByVal dwRop As Long) 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
Private Type BITMAPINFOHEADER
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Private Type BITMAPFILEHEADER
bfType As Integer
bfSize As Long
bfReserved1 As Integer
bfReserved2 As Integer
bfOffBits As Long
End Type
Private Type RGBQUAD
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
End Type
Private Type BITMAPINFO
bmiHeader As BITMAPINFOHEADER
bmiColors(0 To 255) As RGBQUAD
End Type
Private Sub OCX3002_OnScanMemory(ByVal Msecs As Long, ByVal NumSeq As Long, ByVal Track As String, ByVal BmpFront As Long, ByVal sizeBmpFront As Long, ByVal BmpRear As Long, ByVal sizeBmpRear As Long, ByVal JpegFront As Long, ByVal sizeJpegFront As Long, ByVal JpegRear As Long, ByVal sizeJpegRear As Long, ByVal TiffFront As Long, ByVal sizeTiffFront As Long, ByVal TiffRear As Long, ByVal sizeTiffRear As Long)
Dim Src_hDc As Long
Dim hDCScn As Long
Dim OldObj As Long
Dim Width As Long
Dim Height As Long
Dim Buffer() As Byte
Dim BMPINFO As BITMAPINFO
Dim BMPINFOH As BITMAPINFOHEADER
Dim bmfBitmapFileHeader As BITMAPFILEHEADER
Dim PicInfo As BITMAP
Dim ff As Long
'open the clipboard
OpenClipboard imgCheque.hwnd
'Clear the clipboard
EmptyClipboard
'Put our bitmap onto the clipboard
SetClipboardData CF_BITMAP, BmpFront
'Check if there's a bitmap on the clipboard
If IsClipboardFormatAvailable(CF_BITMAP) = 0 Then
MsgBox "There was an error while pasting the bitmap to the clipboard!"
End If
'Close the clipboard
CloseClipboard
'Get the picture from the clipboard
imgCheque.ScaleMode = 3 'Pixel
imgCheque.Picture = Clipboard.GetData(vbCFBitmap)
imgCheque.Picture = imgCheque.Image
'SavePicture imgCheque.Picture, "F:\Projets Borland Studio\DLL\BIN\images\FBig" + Str(NumSeq) + ".bmp"
GetObjectApi BmpFront, Len(PicInfo), PicInfo
Width = PicInfo.bmWidthBytes
Height = PicInfo.bmHeight
hDCScn = CreateDCAsNull("DISPLAY", ByVal 0&, ByVal 0&, ByVal 0&)
Src_hDc = CreateCompatibleDC(hDCScn)
OldObj = SelectObject(Src_hDc, BmpFront)
ReDim Buffer(0 To Height - 1, 0 To Width - 1)
sizeData2 = sizeBmpFront - Len(BMPINFO) - Len(bmfBitmapFileHeader)
With BMPINFOH
.biBitCount = PicInfo.bmBitsPixel
.biHeight = Height
.biWidth = Width
.biPlanes = PicInfo.bmPlanes
.biClrUsed = 256
.biSize = Len(BMPINFOH)
.biSizeImage = Height * Width * PicInfo.bmBitsPixel / 8
End With
BMPINFO.bmiHeader = BMPINFOH
GetDIBits Src_hDc, BmpFront, 0, Height, Buffer(0, 0), BMPINFO, 0
'Crée l 'entête du fichier bmp
With bmfBitmapFileHeader
.bfType = &H4D42&
.bfOffBits = Len(bmfBitmapFileHeader) + Len(BMPINFO)
.bfSize = sizeBmpFront
End With
BMPINFO.bmiHeader.biClrUsed = 256
BMPINFO.bmiHeader.biXPelsPerMeter = 200
BMPINFO.bmiHeader.biYPelsPerMeter = 200
ff = FreeFile
FileName = "F:\Projets Borland Studio\DLL\BIN\images\F" + Str(NumSeq) + ".bmp"
Open FileName For Binary As #ff
Put #ff, , bmfBitmapFileHeader
'Ecrit les informations du bitmap
Put #ff, , BMPINFO
Put #ff, , Buffer
Close #ff
End Sub |
Partager