#include <APIConstants.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <Constants.au3>
#include <file.au3>
#include <GDIPlus.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <INet.au3>
#include <ListViewConstants.au3>
#include <Math.au3>
#include <Memory.au3>
#include <PostMessage_UDF.au3>
#include <SendMessage.au3>
;#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
_GDIPlus_Startup()
Local $hfileBitmap = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\GDIPlus_Image.jpg")
Local $hfileBitmap_clone = _GDIPlus_ImageClone($hfileBitmap)
$hfileBitmap = _ColorMatrix_set_lum($hfileBitmap,$hfileBitmap_clone)
$YzmArray = YzmToArray($hfileBitmap)
$oldBitMap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hfileBitmap)
_GDIPlus_ImageDispose($hfileBitmap)
;_MemGlobalFree($hData)
_GDIPlus_Shutdown()
Func _ColorMatrix_set_lum($hfileBitmap,$hfileBitmap_clone)
Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($hfileBitmap_clone)
Local $hIA = _GDIPlus_ImageAttributesCreate()
Local $tColorMatrix, $pColorMatrix, $nBrightness
$tColorMatrix = _GDIPlus_ColorMatrixCreate()
$pColorMatrix = DllStructGetPtr($tColorMatrix)
$nBrightness = -0.3
_GDIPlus_ColorMatrixTranslate($tColorMatrix, $nBrightness, $nBrightness, $nBrightness, 0, 1)
_GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $pColorMatrix)
_GDIPlus_GraphicsDrawImage($hGraphics, $hfileBitmap, 100, 100)
Local $hBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hfileBitmap)
_GDIPlus_ImageAttributesDispose($hIA)
Return $hBMP
EndFunc ;==>_Update
Func YzmToArray($hImage, $func_bg = 0xffffff);background
Local $BitmapData, $iwidth, $iheight, $Scan0, $pixelData, $s_BMPData, $i_Stride
$iwidth = _GDIPlus_ImageGetWidth($hImage)
$iheight = _GDIPlus_ImageGetHeight($hImage)
$BitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iwidth, $iheight, $GDIP_ILMREAD, $GDIP_PXF24RGB)
$i_Stride = DllStructGetData($BitmapData, "Stride");Stride - Offset, in bytes, between consecutive scan lines of the bitmap. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up.
$Scan0 = DllStructGetData($BitmapData, "Scan0");Scan0 - Pointer to the first (index 0) scan line of the bitmap.
$pixelData = DllStructCreate("ubyte lData[" & (Abs($i_Stride) * $iheight) & "]", $Scan0)
;不要使用官方论坛上提供的Abs($i_Stride) * $iheight-1,否则无法正确处理gif冗余等情形
$s_BMPData = DllStructGetData($pixelData, "lData")
$s_BMPData = StringTrimLeft($s_BMPData, 2);去掉头部"0x"
Local $emptyworkingset_show = DllCall('psapi.dll', 'int', 'EmptyWorkingSet', 'hWnd', -1)
;Local $emptyworkingset_show = DllCall('Kernel32.dll', 'int', 'EmptyWorkingSet', 'hWnd', -1)
;MsgBox(0,"",$emptyworkingset_show,2)
;处理图片数组
Local $a_return[$iheight][$iwidth], $x, $y, $s
For $y = 0 To $iheight - 1
$s = StringMid($s_BMPData, $y * ($i_Stride * 2) + 1, $iwidth * 6)
For $x = 0 To $iwidth - 1
$a_return[$y][$x] = Number("0x" & StringMid($s, $x * 6 + 1, 6))
Next
Next
Local $xScale = Int(510 / $iwidth)
Local $yScale = Int(180 / $iheight)
$Scale = $xScale
If $xScale > $yScale Then $Scale = $yScale
GUICtrlSetPos($Pic2, 20, 20, $iwidth * $Scale + $Coordinate * 2, $iheight * $Scale + $Coordinate * 2)
GUICtrlSetPos($Pic, 20, 290 + $offset_01, $iwidth, $iheight)
;Exit
Return $a_return
EndFunc ;==>YzmToArray