Friends hello! Help me please! I have a control with a transparent background, in which a red rectangle is drawn. How to blur this rectangle, so that the edges are not gray.
Below example. The left rectangle is blurred over the transparent background, the right rectangle, blurred over the white background. It is necessary that in the left, the result was similar to the right. But in the left, the edges should remain transparent. Under control can be any picture and it will move.
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <WinApi.au3>
Local $hForm = GUICreate('', 300, 160)
Local $iPic1 = GUICtrlCreatePic('', 20, 20, 140, 140)
Local $iPic2 = GUICtrlCreatePic('', 160, 20, 140, 140)
GUICtrlSetResizing($iPic1, $GUI_DOCKALL)
GUICtrlSetResizing($iPic2, $GUI_DOCKALL)
_GDIPlus_Startup()
; Left rectangle. Pouring on transparency
Local $hImage1 = _GDIPlus_BitmapCreateFromScan0(120, 120, $GDIP_PXF32ARGB)
Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)
Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000)
_GDIPlus_GraphicsFillRect($hGraphic, 20, 20, 80, 80, $hBrush)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hGraphic)
Local $hEffect = _GDIPlus_EffectCreateBlur(10)
_GDIPlus_BitmapApplyEffect($hImage1, $hEffect)
_GDIPlus_EffectDispose($hEffect)
;Right rectangle. Filling in color
Local $hImage2 = _GDIPlus_BitmapCreateFromScan0(120, 120, $GDIP_PXF32ARGB)
Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage2)
_GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)
Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000)
_GDIPlus_GraphicsFillRect($hGraphic, 20, 20, 80, 80, $hBrush)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hGraphic)
Local $hEffect = _GDIPlus_EffectCreateBlur(10)
_GDIPlus_BitmapApplyEffect($hImage2, $hEffect)
_GDIPlus_EffectDispose($hEffect)
Local $hBitmap1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage1)
Local $hBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage2)
GUICtrlSendMsg($iPic1, 0x0172, 0, $hBitmap1)
GUICtrlSendMsg($iPic2, 0x0172, 0, $hBitmap2)
_WinAPI_DeleteObject($hBitmap1)
_WinAPI_DeleteObject($hBitmap2)
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_ImageDispose($hImage2)
GUISetState()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
_GDIPlus_Shutdown()