Sign in to follow this  
Followers 0
jayme65

Image reflection (with alpha channel)

10 posts in this topic

#1 ·  Posted (edited)

If would like to reproduce an effect like this one

1323411215_screenshot_1.png

How would you do to mirror an image with an alpha blend?

Thanks very much for your help/advice!!

Edited by jayme65

Share this post


Link to post
Share on other sites



is this that impossible to achieve?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi,

You could use GDI with Function  _GDIPlus_ImageRotateFlip()

;original by UEZ ;o)

#include <ScreenCapture.au3>

_GDIPlus_Startup()
Global Const $iDiv = @DesktopHeight
Global Const $hHBitmap = _ScreenCapture_Capture("", 0, 0, @DesktopWidth, $iDiv)
Global Const $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap)
Global Const $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_WinAPI_DeleteObject($hHBitmap)

Global Const $hBitmap_Temp = _GDIPlus_BitmapCreateFromScan0(@DesktopWidth, $iDiv)
Global Const $hCtxt_Temp = _GDIPlus_ImageGetGraphicsContext($hBitmap_Temp)

Global $iStep = 0


    _GDIPlus_GraphicsDrawImageRectRect($hCtxt_Temp, $hBitmap, $iStep, 0, $iDiv, $iDiv, 0, 0, $iDiv, $iDiv)
    _GDIPlus_ImageRotateFlip($hBitmap_Temp,6)
    _GDIPlus_GraphicsDrawImageRectRect($hCtxt, $hBitmap_Temp, 0, 0, $iDiv, $iDiv, $iStep, 0, $iDiv, $iDiv)


Global Const $hGUI = GUICreate("Flipped Images", @DesktopWidth, $iDiv)
GUISetState()
Global Const $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, @DesktopWidth, $iDiv)

Do
Until GUIGetMsg() = -3

_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_BitmapDispose($hBitmap_Temp)
_GDIPlus_GraphicsDispose($hCtxt)
_GDIPlus_GraphicsDispose($hCtxt_Temp)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
GUIDelete()
Exit
Edited by AndyG

Share this post


Link to post
Share on other sites

Andy,

Thanks very much for your help and for the time taken to write this script!!

Any idea on how to apply an alpha blen to a bitmap to achieve the reflection effetct?

Share this post


Link to post
Share on other sites

Have a look here:

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

With alpha channel.

 

#Include <GDIPlus.au3>

If StringRegExpReplace(@AutoItVersion, '(?<!\d)(\d)(?!\d)', '0\1') < '03.03.12.00' Then
    MsgBox(16, 'Error', 'Require AutoIt 3.3.12.0 or later.')
EndIf

$sFile = @ScriptDir & '\iPhone.png'

_GDIPlus_Startup()
$hBitmap = _GDIPlus_BitmapCreateFromFile($sFile)
$hReflection = _GDIPlus_BitmapCreateReflectionBitmap($hBitmap, _GDIPlus_ImageGetHeight($hBitmap) * 0.25, 128)
_GDIPlus_ImageSaveToFile($hReflection, StringRegExpReplace($sFile, '(\.[^\.]+)', '_Reflection\1'))
_GDIPlus_BitmapDispose($hReflection)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_Shutdown()

Func _GDIPlus_BitmapCreateReflectionBitmap($hBitmap, $iReflectionHeight, $iAlpha)

    Local $hGraphics, $hBrush, $hReflection[2], $hAlpha, $hResult, $Size

    $Size = DllCall($__g_hGDIPDll, 'uint', 'GdipGetImageDimension', 'handle', $hBitmap, 'float*', 0, 'float*', 0)
    If (@Error) Or ($Size[0]) Then
        Return 0
    EndIf
    If $iReflectionHeight > $Size[3] Then
        $iReflectionHeight = $Size[3]
    EndIf
    If $iReflectionHeight < 0 Then
        $iReflectionHeight = 0
    EndIf
    $hReflection[0] = _GDIPlus_BitmapCloneArea($hBitmap, 0, $Size[3] - $iReflectionHeight, $Size[2], $iReflectionHeight, $GDIP_PXF32ARGB)
    _GDIPlus_ImageRotateFlip($hReflection[0], 6)
    $hAlpha = _GDIPlus_BitmapCreateFromScan0($Size[2], $iReflectionHeight, $GDIP_PXF32ARGB)
    $hGraphics = _GDIPlus_ImageGetGraphicsContext($hAlpha)
    _GDIPlus_GraphicsClear($hGraphics, 0)
    $hBrush = _GDIPlus_LineBrushCreate(0, 0, 0, $iReflectionHeight, BitShift($iAlpha, -24), 0)
    _GDIPlus_GraphicsFillRect($hGraphics, 0, 0, $Size[2], $iReflectionHeight, $hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    $hReflection[1] = _GDIPlus_BitmapCreateBitmapWithAlpha($hReflection[0], $hAlpha)
    $hResult = _GDIPlus_BitmapCreateFromScan0($Size[2], $Size[3] + $iReflectionHeight)
    $hGraphics = _GDIPlus_ImageGetGraphicsContext($hResult)
    _GDIPlus_GraphicsClear($hGraphics, 0)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $Size[2], $Size[3])
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hReflection[1], 0, $Size[3], $Size[2], $iReflectionHeight)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hAlpha)
    For $i = 0 To 1
        _GDIPlus_BitmapDispose($hReflection[$i])
    Next
    _GDIPlus_BrushDispose($hBrush)
    Return $hResult
EndFunc   ;==>_GDIPlus_BitmapCreateReflectionBitmap

Func _GDIPlus_BitmapCreateBitmapWithAlpha($hBitmap, $hAlpha, $iChannel = 0)

    Local $hGraphics, $hBmp[2], $bProc, $tProc, $pProc, $Size1, $Size2, $Lenght, $Result
    Local $tData[2] = [$GDIP_ILMWRITE, $GDIP_ILMREAD]

    $Size1 = DllCall($__g_hGDIPDll, 'uint', 'GdipGetImageDimension', 'handle', $hBitmap, 'float*', 0, 'float*', 0)
    If (@Error) Or ($Size1[0]) Then
        Return 0
    EndIf
    $Size2 = DllCall($__g_hGDIPDll, 'uint', 'GdipGetImageDimension', 'handle', $hAlpha, 'float*', 0, 'float*', 0)
    If (@Error) Or ($Size2[0]) Then
        Return 0
    EndIf
    $hBmp[0] = _GDIPlus_BitmapCloneArea($hBitmap, 0, 0, $Size1[2], $Size1[3], $GDIP_PXF32ARGB)
    If ($Size1[2] = $Size2[2]) And ($Size1[3] = $Size2[3]) Then
        $hBmp[1] = $hAlpha
    Else
        $hBmp[1] = _GDIPlus_BitmapCreateFromScan0($Size1[2], $Size1[3], $GDIP_PXF32ARGB)
        $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBmp[1])
        _GDIPlus_GraphicsClear($hGraphics, 0)
        _GDIPlus_GraphicsDrawImageRect($hGraphics, $hAlpha, 0, 0, $Size1[2], $Size1[3])
        _GDIPlus_GraphicsDispose($hGraphics)
    EndIf
    If ($iChannel < 0) Or ($iChannel > 3) Then
        $iChannel = 0
    EndIf
    For $i = 0 To 1
        $tData[$i] = _GDIPlus_BitmapLockBits($hBmp[$i], 0, 0, $Size1[2], $Size1[3], $tData[$i], $GDIP_PXF32ARGB)
    Next
    If @AutoItX64 Then
        $bProc = Binary('0x48894C240848895424104C894424184C894C24205541574831C0505050504883EC2848837C24600074054831C0EB0748C7C0010000004821C00F858100000048837C24680074054831C0EB0748C7C0010000004821C07555837C24700074054831C0EB0748C7C0010000004821C0752A4C637C24784D21FF7C0D4C637C24784983FF037F02EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000EB034831C04821C0740B4831C04863C0E9950000004C8B7C24604983C7034C897C24284C8B7C246848634424784929C74983C7034C897C243048C7442438000000004C637C247049FFCF4C3B7C24387C4A488B6C24284C0FB67D00488B6C2430480FB645004C0FAFF84C89F848C7C1FF000000489948F7F94989C74C89F850488B6C24305888450048834424280448834424300448FF44243871A748C7C0010000004863C0EB034831C04883C448415F5DC3')
    Else
        $bProc = Binary('0x555331C0505050837C241800740431C0EB05B80100000021C07568837C241C00740431C0EB05B80100000021C07545837C242000740431C0EB05B80100000021C075228B5C242421DB7C0B8B5C242483FB037F02EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C07502EB07B801000000EB0231C021C0740431C0EB6B8B5C241883C303891C248B5C241C2B5C242483C303895C2404C7442408000000008B5C24204B3B5C24087C368B2C240FB65D008B6C24040FB645000FAFD889D8B9FF00000099F7F989C3538B6C240458884500830424048344240404FF44240871BFB801000000EB0231C083C40C5B5DC21000')
    EndIf
    $Length = BinaryLen($bProc)
    $pProc = DllCall('kernel32.dll', 'ptr', 'VirtualAlloc', 'ptr', 0, 'ulong_ptr', $Length, 'dword', 0x1000, 'dword', 0x0040)
    $tProc = DllStructCreate('byte[' & $Length & ']', $pProc[0])
    DllStructSetData($tProc, 1, $bProc)
    $Result = DllCallAddress('uint', $pProc[0], 'ptr', $tData[0].Scan0, 'ptr', $tData[1].Scan0, 'uint', $Size1[2] * $Size1[3], 'uint', $iChannel)
    If Not $Result[0] Then
        ; Nothing
    EndIf
    DllCall('kernel32.dll', 'int', 'VirtualFree', 'ptr', $pProc[0], 'ulong_ptr', 0, 'dword', 0x4000)
    For $i = 0 To 1
        _GDIPlus_BitmapUnlockBits($hBmp[$i], $tData[$i])
    Next
    If $hBmp[1] <> $hAlpha Then
        _GDIPlus_BitmapDispose($hBmp[1])
    EndIf
    Return $hBmp[0]
EndFunc   ;==>_GDIPlus_BitmapCreateBitmapWithAlpha

h_1420948569_5461059_62a9fd22bf.png

h_1420948577_9234784_d9bd1cfaa3.png

Edited by Yashied

Share this post


Link to post
Share on other sites

Here one more which I found in my collections:
 

;idea from here -> http://danbystrom.se/2009/01/12/thumbnails-with-glass-table-reflection-in-gdi/
;coded by UEZ 2013-10-04

#include <GDIPlus.au3>

Opt("GUIOnEventMode", 1)

_GDIPlus_Startup()
Global Const $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp,*.gif;*.jpg;*.png)")
If @error Then Exit


Global Const $hGUI = GUICreate("GDI+ Thumbnails with glass table reflection", 600, 400)
GUISetBkColor(0xF0F0F0)
GUISetState()

Global Const $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
Global Const $hImage = _GDIPlus_ImageLoadFromFile($sFile)

$t = TimerInit()
Global Const $hBmp = _GDIPlus_BitmapCreateThumbnailWithReflection($hImage)
ConsoleWrite(TimerDiff($t) & " ms" & @LF)
$t = TimerInit()
Global Const $hBmp2 = _GDIPlus_BitmapCreateThumbnailWithReflection2($hImage)
ConsoleWrite(TimerDiff($t) & " ms" & @LF)
ConsoleWrite(_GDIPlus_ImageGetWidth($hBmp) & " x " & _GDIPlus_ImageGetHeight($hBmp) & @LF)
_GDIPlus_GraphicsDrawImage($hGraphic, $hBmp, (400 - _GDIPlus_ImageGetWidth($hBmp)) / 2, (400 - _GDIPlus_ImageGetHeight($hBmp)) / 2)
_GDIPlus_GraphicsDrawImage($hGraphic, $hBmp2, (600 + _GDIPlus_ImageGetWidth($hBmp2)) / 2, (400 - _GDIPlus_ImageGetHeight($hBmp2)) / 2)
GUISetOnEvent(-3, "_Exit")

While Sleep(2 ^ 16)
WEnd

Func _Exit()
    _GDIPlus_BitmapDispose($hBmp)
    _GDIPlus_BitmapDispose($hBmp2)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>_Exit

Func _GDIPlus_BitmapCreateThumbnailWithReflection($hImage, $iTNWidth = 150, $iTNHeight = 150, $iSkew = 40, $iBorderWhite = 2, $iBorderBlack = 1, $fBlur = 0.4, $iBrightness = 175, $iContrast = -70, $iSmooth = 7)
    Local $iWidth = _GDIPlus_ImageGetWidth($hImage), $iHeight = _GDIPlus_ImageGetHeight($hImage), $f
    If $iWidth > $iHeight Then
        $iTNHeight *= $iHeight / $iWidth
    ElseIf $iWidth < $iHeight Then
        $iTNWidth *= $iWidth / $iHeight
    EndIf
    Local $iW = Floor($iTNWidth + ($iBorderWhite + $iBorderBlack) * 2), $iH = Floor($iTNHeight + ($iBorderWhite + $iBorderBlack) * 2)
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH * 2 - $iBorderBlack)
    Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetInterpolationMode($hCtxt, $iSmooth)
;~  _GDIPlus_GraphicsClear($hCtxt, 0xFFFFFFFF)
    Local $hBitmap_tmp = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local $hCtxt_tmp = _GDIPlus_ImageGetGraphicsContext($hBitmap_tmp)
    _GDIPlus_GraphicsSetInterpolationMode($hCtxt_tmp, $iSmooth)
    Local $hPen = _GDIPlus_PenCreate(0xFFFFFFFF, $iBorderWhite)
    _GDIPlus_GraphicsDrawRect($hCtxt_tmp, $iBorderBlack, $iBorderBlack, $iW - $iBorderWhite - $iBorderBlack, $iH - $iBorderWhite - $iBorderBlack, $hPen)
    _GDIPlus_PenSetColor($hPen, 0xFF000000)
    _GDIPlus_PenSetWidth($hPen, $iBorderBlack)
    _GDIPlus_GraphicsDrawRect($hCtxt_tmp, 0, 0, $iW - $iBorderBlack / 2, $iH, $hPen)
    _GDIPlus_GraphicsDrawImageRect($hCtxt_tmp, $hImage, $iBorderWhite + $iBorderBlack, $iBorderWhite + $iBorderBlack, $iTNWidth, $iTNHeight)
    _GDIPlus_GraphicsDrawImage($hCtxt, $hBitmap_tmp, 0, 0)
    _GDIPlus_ImageRotateFlip($hBitmap_tmp, 6)

    Local Const $iQual = 6
    Local $hBmpSmall = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local $hGfxSmall = _GDIPlus_ImageGetGraphicsContext($hBmpSmall)
    _GDIPlus_GraphicsSetPixelOffsetMode($hGfxSmall, 2)
    Local $hBmpBig = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local $hGfxBig = _GDIPlus_ImageGetGraphicsContext($hBmpBig)
    _GDIPlus_GraphicsSetPixelOffsetMode($hGfxBig, 2)

    _GDIPlus_GraphicsScaleTransform($hGfxSmall, $fBlur, $fBlur)
    _GDIPlus_GraphicsSetInterpolationMode($hGfxSmall, $iQual)

    _GDIPlus_GraphicsScaleTransform($hGfxBig, 1 / $fBlur, 1 / $fBlur)
    _GDIPlus_GraphicsSetInterpolationMode($hGfxBig, $iQual)

    _GDIPlus_GraphicsDrawImageRect($hGfxSmall, $hBitmap_tmp, 0, 0, $iW, $iH)
    _GDIPlus_GraphicsDrawImageRect($hGfxBig, $hBmpSmall, 0, 0, $iW, $iH)

    _GDIPlus_GraphicsDrawImageRect($hCtxt_tmp, $hBmpBig, 0, 0, $iW, $iH)

    _GDIPlus_GraphicsDispose($hGfxSmall)
    _GDIPlus_GraphicsDispose($hGfxBig)
    _GDIPlus_BitmapDispose($hBmpSmall)
    _GDIPlus_BitmapDispose($hBmpBig)

    Local $fAlpha, $iColor, $iPixelColor
    Local $tBitmapData = _GDIPlus_BitmapLockBits($hBitmap_tmp, 0, 0, $iW, $iH, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB)
    Local $iScan0 = DllStructGetData($tBitmapData, "Scan0") ;get scan0 (pixel data) from locked bitmap
    Local $tPixel = DllStructCreate("int[" & $iW * $iH & "];", $iScan0)
    Local $iPixel, $iRowOffset, $iR, $iG, $iB
    For $iY = 0 To $iH - 1
        $iRowOffset = $iY * $iW + 1
        $fAlpha = (0xF8 * ($iH - $iY - 0x18) / $iH)
        If $fAlpha < 0 Then $fAlpha = 0
        For $iX = 0 To $iW - 1
            $iPixelColor = BitAND(DllStructGetData($tPixel, 1, $iRowOffset + $iX), 0x00FFFFFF)
            $iR = BitAND(BitShift($iPixelColor, 16), 0x0000FF)
            $iG = BitAND(BitShift($iPixelColor, 8), 0x0000FF)
            $iB = BitAND($iPixelColor, 0x0000FF)
            DllStructSetData($tPixel, 1, "0x" & _
                    Hex(Int($fAlpha), 2) & _
                    Hex(Int(($iR * 3 + $iG * 2 + $iB * 2) / 8), 2) & _
                    Hex(Int(($iR * 2 + $iG * 3 + $iB * 2) / 8), 2) & _
                    Hex(Int(($iR * 2 + $iG * 2 + $iB * 3) / 8), 2), $iRowOffset + $iX)
        Next
    Next
    _GDIPlus_BitmapUnlockBits($hBitmap_tmp, $tBitmapData)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDrawImageRect($hCtxt, $hBitmap_tmp, 0, $iH, $iW, $iH)
    _GDIPlus_GraphicsDispose($hCtxt)
    _GDIPlus_GraphicsDispose($hCtxt_tmp)
    _GDIPlus_BitmapDispose($hBitmap_tmp)
    If $iSkew Then
        $iW = _GDIPlus_ImageGetWidth($hBitmap)
        $iH = _GDIPlus_ImageGetHeight($hBitmap)
        Local $hBitmapSkewed = _GDIPlus_BitmapCreateFromScan0($iW, $iH), $x
        $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmapSkewed)
;~      _GDIPlus_DrawImagePoints($hCtxt, $hBitmap, 0, 0, $iW, $iSkew, 0, $iH)
        For $x = 0 To $iW - 1
            _GDIPlus_GraphicsDrawImageRectRect($hCtxt, $hBitmap, _
                    $x, 0, 1, $iH, _
                    $x, 0, 1, $iH - $iSkew * ($iW - $x) / $iW)
        Next
        _GDIPlus_GraphicsDispose($hCtxt)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hBitmapSkewed
    EndIf
    Return $hBitmap
EndFunc   ;==>_GDIPlus_BitmapCreateThumbnailWithReflection

Func _GDIPlus_BitmapCreateThumbnailWithReflection2($hImage, $iTNWidth = 150, $iTNHeight = 150, $iSkew = 40, $iBorderWhite = 2, $iBorderBlack = 1, $fBlur = 3.25, $iBrightness = 170, $iContrast = -70, $iSmooth = 7)
    Local $iWidth = _GDIPlus_ImageGetWidth($hImage), $iHeight = _GDIPlus_ImageGetHeight($hImage), $f
    If $iWidth > $iHeight Then
        $iTNHeight *= $iHeight / $iWidth
    ElseIf $iWidth < $iHeight Then
        $iTNWidth *= $iWidth / $iHeight
    EndIf
    Local $iW = Floor($iTNWidth + ($iBorderWhite + $iBorderBlack) * 2), $iH = Floor($iTNHeight + ($iBorderWhite + $iBorderBlack) * 2)
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH * 2 - $iBorderBlack)
    Local $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetInterpolationMode($hCtxt, $iSmooth)
    Local $hBitmap_tmp = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local $hCtxt_tmp = _GDIPlus_ImageGetGraphicsContext($hBitmap_tmp)
    _GDIPlus_GraphicsSetInterpolationMode($hCtxt_tmp, $iSmooth)
    Local $hPen = _GDIPlus_PenCreate(0xFFFFFFFF, $iBorderWhite)
    _GDIPlus_GraphicsDrawRect($hCtxt_tmp, $iBorderBlack, $iBorderBlack, $iW - $iBorderWhite - $iBorderBlack, $iH - $iBorderWhite - $iBorderBlack, $hPen)
    _GDIPlus_PenSetColor($hPen, 0xFF000000)
    _GDIPlus_PenSetWidth($hPen, $iBorderBlack)
    _GDIPlus_GraphicsDrawRect($hCtxt_tmp, 0, 0, $iW - $iBorderBlack / 2, $iH, $hPen)
    _GDIPlus_GraphicsDrawImageRect($hCtxt_tmp, $hImage, $iBorderWhite + $iBorderBlack, $iBorderWhite + $iBorderBlack, $iTNWidth, $iTNHeight)
    _GDIPlus_GraphicsDrawImage($hCtxt, $hBitmap_tmp, 0, 0)
    _GDIPlus_ImageRotateFlip($hBitmap_tmp, 6)

    Local $hEffectBC = _GDIPlus_EffectCreateBrightnessContrast($iBrightness, $iContrast)
    _GDIPlus_BitmapApplyEffect($hBitmap_tmp, $hEffectBC)
    Local $hEffectBlur = _GDIPlus_EffectCreateBlur($fBlur, True)
    _GDIPlus_BitmapApplyEffect($hBitmap_tmp, $hEffectBlur)

    _GDIPlus_EffectDispose($hEffectBC)
    _GDIPlus_EffectDispose($hEffectBlur)

    Local $hAttribute_Alpha = _GDIPlus_ImageAttributesCreate()
    Local $hBitmap_Alpha = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local $hCtxt_Alpha = _GDIPlus_ImageGetGraphicsContext($hBitmap_Alpha), $iY, $tColorMatrix, $d = (-1 / 0x80)

    For $iY = 0 To $iH - 1
        $tColorMatrix = _GDIPlus_ColorMatrixCreateTranslate(0, 0, 0, $iY * $d)
        _GDIPlus_ImageAttributesSetColorMatrix($hAttribute_Alpha, 0, True, DllStructGetPtr($tColorMatrix))
        _GDIPlus_GraphicsDrawImageRectRect($hCtxt_Alpha, $hBitmap_tmp, 0, $iY, $iW, 1, 0, $iY, $iW, 1, $hAttribute_Alpha)
    Next

    _GDIPlus_GraphicsDispose($hCtxt_Alpha)
    _GDIPlus_ImageAttributesDispose($hAttribute_Alpha)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDrawImageRect($hCtxt, $hBitmap_Alpha, 0, $iH, $iW, $iH)
    _GDIPlus_GraphicsDispose($hCtxt)
    _GDIPlus_GraphicsDispose($hCtxt_tmp)
    _GDIPlus_BitmapDispose($hCtxt_Alpha)
    _GDIPlus_BitmapDispose($hBitmap_tmp)
    If $iSkew Then
        $iW = _GDIPlus_ImageGetWidth($hBitmap)
        $iH = _GDIPlus_ImageGetHeight($hBitmap)
        Local $hBitmapSkewed = _GDIPlus_BitmapCreateFromScan0($iW, $iH), $iX
        $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmapSkewed)
;~      _GDIPlus_DrawImagePoints($hCtxt, $hBitmap, 0, 0, $iW, $iSkew, 0, $iH)
        For $iX = 0 To $iW - 1
            _GDIPlus_GraphicsDrawImageRectRect($hCtxt, $hBitmap, _
                                                        $iX, 0, 1, $iH, _
                                                        $iX, 0, 1, $iH - $iSkew * ($iW - $iX) / $iW)
        Next
        _GDIPlus_GraphicsDispose($hCtxt)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hBitmapSkewed
    EndIf
    Return $hBitmap
EndFunc   ;==>_GDIPlus_BitmapCreateThumbnailWithReflection2

Br,

UEZ

1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

You are right. For a few images it should be fast enough but for plenty of images it's too slow.

Learning ASM / C++ is the next level of coding for me. But when...

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Thanks very much for the url (UEZ) and for the complete code (Yashied) to achieve this reflection effect!

I'm really gratefull to you!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0