本帖最后由 水木子 于 2020-7-2 22:57 编辑
按前辈您说的方法,我写了个测试代码,发现还是有问题。获取到的图片像素数据,不是多了,就是少了。不知问题出在何处呢?图片尺寸越大,错误越明显。#include <Array.au3>
#include <GDIPlus.au3>
_GDIPlus_Startup()
Local $hTimer = TimerInit()
$sBMPData = BitmapGetPixel('图像1.Bmp')
MsgBox(0, TimerDiff($hTimer), $sBMPData)
_GDIPlus_Shutdown()
Func BitmapGetPixel($sFileName)
Local $hImage = _GDIPlus_ImageLoadFromFile($sFileName)
If @error Then
_GDIPlus_Shutdown()
Return False
EndIf
Local $iW = _GDIPlus_ImageGetWidth($hImage)
Local $iH = _GDIPlus_ImageGetHeight($hImage)
Local $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32RGB)
;~ Local $iStride = DllStructGetData($tBitmapData, 'Stride')
Local $Scan0 = DllStructGetData($tBitmapData, 'Scan0')
Local $tPixelData = DllStructCreate('byte[' & $iW * $iH * 4 & ']', $Scan0)
Local $sBmpData = StringTrimLeft(DllStructGetData($tPixelData, 1), 2)
_GDIPlus_BitmapUnlockBits($hImage, $tBitmapData)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
Return $sBmpData
EndFunc ;==>BitmapGetPixel
|