很奇怪, 百思不得其解.
代码如下
Public Type BITMAPFILEHEADER
bfType As Integer 'must be 19778 = "BM"
bfSize As Long 'size of file in bytes LOF(%bf)
bfReserved1 As Integer 'Reserved must be set to zero
bfReserved2 As Integer 'Reserved must be set to zero
bfOffBits As Long 'the begining of the actual bmp data
End TypePrivate m_bfh As BITMAPFILEHEADER
CopyMemory m_bfh, Stream(0), Len(m_bfh) 'stream是图像的数据流结果m_bfh.bfReserved2的数据是bfOffBits的.我看了下m_bfh的内存, 发现如果用Get #1,,m_bfh得到的数据是
42 4D 00 00 36 5A 09 00 00 00 00 00 36 00 00 00 ; BM..6Z......6...
占用了16位也! 当然len得出来是14.
而且m_bfh.bfSize的指针也确实指向36 5A而从stream CopyMemory 进去的是
42 4D 36 5A 09 00 00 00 00 00 36 00 00 00 ; BM6Z......6...
这才是正确的源图像文件数据啊...好像只有这个自定义类型有这种问题, 请问发生的原因和解决方法?
先谢了.
代码如下
Public Type BITMAPFILEHEADER
bfType As Integer 'must be 19778 = "BM"
bfSize As Long 'size of file in bytes LOF(%bf)
bfReserved1 As Integer 'Reserved must be set to zero
bfReserved2 As Integer 'Reserved must be set to zero
bfOffBits As Long 'the begining of the actual bmp data
End TypePrivate m_bfh As BITMAPFILEHEADER
CopyMemory m_bfh, Stream(0), Len(m_bfh) 'stream是图像的数据流结果m_bfh.bfReserved2的数据是bfOffBits的.我看了下m_bfh的内存, 发现如果用Get #1,,m_bfh得到的数据是
42 4D 00 00 36 5A 09 00 00 00 00 00 36 00 00 00 ; BM..6Z......6...
占用了16位也! 当然len得出来是14.
而且m_bfh.bfSize的指针也确实指向36 5A而从stream CopyMemory 进去的是
42 4D 36 5A 09 00 00 00 00 00 36 00 00 00 ; BM6Z......6...
这才是正确的源图像文件数据啊...好像只有这个自定义类型有这种问题, 请问发生的原因和解决方法?
先谢了.
解决方案 »
- VISUAL BASIC 与 SQL SERVER 权威指南(第6版) 书附光盘
- MSHFlexGrid中单击某一行变色,如何实现
- MsHFlexGrid的.CellAlignment = flexAlignCenterCenter问题
- 求助一个简单的VB问题
- 奇怪~~~有2个窗体MDIForm1和Form1,Form1设置为它的子窗体,但检测到Form1的父句柄却不是MDIForm1的句柄,为什么呀?
- (乞讨!!!!)我的可用分才23分了,走过的路过的大哥给点分我,开个贴,我去拿!
- 请问为什么在98下无法显示表格中的内容?
- 100分,急!谢谢~~vb 报表,data report 里面的打印按钮为何不能用阿?
- 想得头痛的问题!
- 怎么判断一个文本文件是否打开?
- 请问如何编程读注册表,找出串行口的个数?
- CRYSTAL控件中的打印问题
知道是2字节, 但内存中看下来当中多出了2个字节, 不知道原因....
定义成long不但get数据出错, copy更不对了, 而且还不能显示图像.to lk_cool
而后面的几个integer类型没有问题.
bfType As Integer 'must be 19778 = "BM"
bfSize As Long 'size of file in bytes LOF(%bf)
bfReserved1 As Integer 'Reserved must be set to zero
bfReserved2 As Integer 'Reserved must be set to zero
bfOffBits As Long 'the space between this struct and the begining of the actual bmp data
End TypePrivate Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpDst As Any, lpSrc As Any, ByVal Length As Long)Dim bmfh As BITMAPFILEHEADERPrivate Sub Form_Load()
Dim A(13) As ByteA(0) = 0
A(1) = 1A(2) = 0
A(3) = 0
A(4) = 0
A(5) = 1A(6) = 0
A(7) = 1A(8) = 0
A(9) = 1A(10) = 0
A(11) = 0
A(12) = 0
A(13) = 1CopyMemory bmfh, A(0), Len(bmfh)
Debug.Print Hex(VarPtr(bmfh)) '获得指针Debug.Print bmfh.bfType
Debug.Print bmfh.bfSize
Debug.Print bmfh.bfReserved1
Debug.Print bmfh.bfReserved2
Debug.Print bmfh.bfOffBitsEnd Sub我的结果:
1CC14C
256
16777472
256
0
256
大感激!
只好一个个copy了..
另外:
//CopyMemory m_bfh, Stream(0), Len(m_bfh) 'stream是图像的数据流
图像的数据流是什么意思?既然,你定义了:
Private m_bfh As BITMAPFILEHEADER那么Stream中包含文件头信息吗,Stream又是如何获得的?请详细说明一下。