|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
convert function from VB.6 to VB.NET' DECLARATIONS Private Const BMP_MAGIC_COOKIE As Short = 19778 Private Structure BITMAPFILEHEADER '14 bytes Dim bfType As Short Dim bfSize As Integer Dim bfReserved1 As Short Dim bfReserved2 As Short Dim bfOffBits As Integer End Structure Private Structure BITMAPINFOHEADER '40 bytes Dim biSize As Integer Dim biWidth As Integer Dim biHeight As Integer Dim biPlanes As Short Dim biBitCount As Short Dim biCompression As Integer Dim biSizeImage As Integer Dim biXPelsPerMeter As Integer Dim biYPelsPerMeter As Integer Dim biClrUsed As Integer Dim biClrImportant As Integer End Structure Private Structure RGBQUAD Dim Red As Byte Dim Green As Byte Dim Blue As Byte Dim Reserved As Byte End Structure Private Structure BITMAP Dim bmType As Integer Dim bmWidth As Integer Dim bmHeight As Integer Dim bmWidthBytes As Integer Dim bmPlanes As Short Dim bmBitsPixel As Short Dim bmBits As Integer End Structure Private Const BI_RGB As Integer = 0 Private Declare Function GetProcessHeap Lib "kernel32.dll" () As Integer 'handle Private Declare Function HeapAlloc Lib "kernel32.dll" (ByVal hHeap As Integer, ByVal dwFlags As Integer, ByVal dwBytes As Integer) As Integer Private Declare Function HeapFree Lib "kernel32.dll" (ByVal hHeap As Integer, ByVal dwFlags As Integer, ByVal lpMem As Integer) As Integer Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef dest As IntPtr, ByVal fromAddress As String, ByVal bytesToCopy As Long) Private Const HEAP_ZERO_MEMORY As Integer = &H8S Private m_memBits() As Byte Private m_memBitmapInfo() As Byte Private m_bih As BITMAPINFOHEADER Private m_bfh As BITMAPFILEHEADER 'FUNCTION Public Function CreateFromPackedDIBPointer(ByRef pDIB As Long) As Boolean Debug.Assert pDIB <> 0 'Creates a full-color (no palette) DIB from a pointer to a full-color memory DIB 'get the BitmapInfoHeader Call CopyMemory(ByVal VarPtr(m_bih.biSize), ByVal pDIB, Len(m_bih)) If m_bih.biBitCount < 16 Then Debug.Print "Error! DIB was less than 16 colors." Exit Function 'only supports high-color or full-color dibs End If 'now get the bitmap bits If m_bih.biSizeImage < 1 Then Exit Function 'return False ReDim m_memBits(0 To m_bih.biSizeImage - 1) Call CopyMemory(m_memBits(0), ByVal pDIB + 40, m_bih.biSizeImage) 'and BitmapInfo variable-length UDT ReDim m_memBitmapInfo(0 To 39) 'don't need first 14 bytes (fileinfo) Call CopyMemory(m_memBitmapInfo(0), m_bih, Len(m_bih)) 'create a file header With m_bfh .bfType = BMP_MAGIC_COOKIE .bfSize = 55 + m_bih.biSizeImage 'size of file as written to disk .bfReserved1 = 0& .bfReserved2 = 0& .bfOffBits = 54 'BitmapInfoHeader + BitmapFileHeader End With 'and return True CreateFromPackedDIBPointer = True End Function "Joao Tomas" <x*@xx.com> wrote in news:ecs7kl$fgr$1@news.datemas.de: Which part are you having trouble with?> Please, can someone help me to translate this single function to VB.NET ? "Spam Catcher" <spamhoneypot@rogers.com> wrote in message CopyMemorynews:Xns982CC7B887412usenethoneypotrogers@127.0.0.1... > "Joao Tomas" <x*@xx.com> wrote in news:ecs7kl$fgr$1@news.datemas.de: > >> Please, can someone help me to translate this single function to VB.NET ? > > Which part are you having trouble with? VB.net doesn't support it anymore vb.net is bad for memory pointers Joao,
I am not a VB6 guy, however why do you need, it or in other words do you known the memorystream? http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemiomemorystreamclasstopic.asp I hope this helps, Cor Show quoteHide quote >
Show quote
Hide quote
On Mon, 28 Aug 2006 05:13:47 +0100, "Joao Tomas" <x*@xx.com> wrote: Maybe this might be helpful.> >"Spam Catcher" <spamhoneypot@rogers.com> wrote in message >news:Xns982CC7B887412usenethoneypotrogers@127.0.0.1... >> "Joao Tomas" <x*@xx.com> wrote in news:ecs7kl$fgr$1@news.datemas.de: >> >>> Please, can someone help me to translate this single function to VB.NET ? >> >> Which part are you having trouble with? > > >CopyMemory > >VB.net doesn't support it anymore > >vb.net is bad for memory pointers > (VB2005) I have an app that uses this declare for CopyMemory: Public Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" _ (ByVal Destination As Byte(), ByVal Source As Int32, ByVal Length As Int32) I use it in conjunction with the API's "GlobalLock", "GlobalSize", "GlobalFree", "GlobalUnlock" Dim bBlob() As Byte Dim hBuffer As System.Int32 = sHandle 'handle to a memory buffer Dim bData As Int32 = GlobalLock(hBuffer) Dim bSize As Int32 = GlobalSize(hBuffer) ReDim bBlob(bSize) CopyMemory(bBlob, bData, bSize) GlobalUnlock(bData) GlobalFree(bData) Gene
How can I use a dll with several programs?
What exactly does this message mean? vb2005 and ce net 4.2 DatagridView Column Headers books for vb.net Binding Data to Dataset or Table API found in C# but not VB? How to find out current Screen resolution? vb.net aggregation question disable/enable menu items |
|||||||||||||||||||||||