dim s$
s = Space(FileLen("c:\1.txt"))
Open "c:\1.txt" For Binary As #1
Get #1, , s
Close #1
s = "BM" & s
Open "c:\1.bmp" For Binary As #1
Put #1, , s
Close #1
Set Form1.picture = LoadPicture("c:\1.bmp")
Private Function GetMinimap&(ByVal fileMiniMap$)
Dim tbuf$, buf() As Byte
Dim bf As BITMAPFILEHEADER, bif As BITMAPINFOHEADER, bi As BITMAPINFO
Dim hb&, bufim&
tbuf = Space(FileLen(fileMiniMap$))
Open fileMiniMap For Binary As #1: Get #1, , tbuf: Close #1
buf = "BM" & tbuf
CopyMemory bf, buf(0), Len(bf)
CopyMemory bif, buf(Len(bf)), Len(bif)
CopyMemory bi.bmiHeader, bif, Len(bif)
hb = CreateDIBSection(0, bi, 0, bufim, 0, 0)
CopyMemory bufim, buf(bf.bfOffBits), 4
GetMinimap = hb
End Function
Option Explicit
Private Type BITMAPFILEHEADER
bfType As Integer
bfSize As Long
bfReserved1 As Integer
bfReserved2 As Integer
bfOffBits 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 RGBQUAD
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
End Type
Private Type BITMAPINFO
bmiHeader As BITMAPINFOHEADER
bmiColors As RGBQUAD
End Type
Private Declare Sub MoveMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
Private Declare Function CreateBitmap Lib "gdi32.dll" (ByVal nWidth As Long, ByVal nHeight As Long, ByVal nPlanes As Long, ByVal nBitCount As Long, ByRef lpBits As Any) As Long
Private Function hBitmapFromFile(ByVal strFileName As String) As Long
Dim bBMPData() As Byte
Dim n As Long
Dim BFH As BITMAPFILEHEADER
Dim BIH As BITMAPINFOHEADER
Dim BI As BITMAPINFO
n = FreeFile
Open strFileName For Binary Access Read As #n
Get #n, 1, BFH
Get #n, 15, BIH
ReDim bBMPData(0 To 2, BIH.biWidth - 1, BIH.biHeight - 1)
Get #n, 55, bBMPData
Close #n
MoveMemory BI.bmiHeader, BIH, Len(BIH)
hBitmapFromFile = CreateBitmap(BI.bmiHeader.biWidth, BI.bmiHeader.biHeight, _
BI.bmiHeader.biPlanes, BI.bmiHeader.biBitCount, bBMPData(0, 0, 0))
End Function
а не мог бы мне разьяснить, в чем я ступил в своем варианте?
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 125