Jump to content

GDI and reflection


zeehteam
 Share

Go to solution Solved by UEZ,

Recommended Posts

  • Moderators

zeehteam,

Welcome to the AutoIt forum. :)

The answer to your question is "quite likely". What have you done so far to try and get it to work? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

zeehteam,

Looking in the Help file, searching the forum for GDI+ code threads, asking specific questions rather then giving the impression that you expect someone to do it all for you - there are lots of ways. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Solution

I didn't fully understand the C# code so here a way which is similar to the code (AutoIt version 3.3.10.x needed):

#include <GDIPlus.au3>

_GDIPlus_Startup()
Global Const $hImage = _GDIPlus_BitmapCreateFromMemory(InetRead("http://www.touchscreengadget.com/wp-content/uploads/2008/02/windowslivewriternewsonyericssontouchscreenunveils-b1ddg700i-1-3.jpg"))
Global Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage)
Global Const $iReflectivity = 40
Global $hBmp_Reflection = _GDIPlus_ImageDrawReflection($hImage, 0xFFFFFFFF, $iReflectivity)
_GDIPlus_ImageSaveToFile($hBmp_Reflection, @ScriptDir & "\Test.png")
_GDIPlus_BitmapDispose($hBmp_Reflection)
_GDIPlus_Shutdown()
ShellExecute(@ScriptDir & "\Test.png")

Func _GDIPlus_ImageDrawReflection($hBitmap, $iBgColor, $iReflectivity, $iDeltaY = 2, $iAlpha = 0xD0) ;coded by UEZ build 2014-01-30
    If $iReflectivity < 0 Then $iReflectivity = 0
    If $iReflectivity > 0xFF Then $iReflectivity = 0xFF
    Local Const $iW = _GDIPlus_ImageGetWidth($hBitmap), $iH = _GDIPlus_ImageGetHeight($hBitmap)
    Local Const $iHeight = $iH + $iH * $iReflectivity / 255 + $iDeltaY
    Local Const $hBitmap_new = _GDIPlus_BitmapCreateFromScan0($iW, $iHeight)
    Local Const $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap_new)
    _GDIPlus_GraphicsSetInterpolationMode($hGraphics, $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC)
    _GDIPlus_GraphicsClear($hGraphics, $iBgColor)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iW,$iH)
    Local Const $fReflectionHeight = $iH * $iReflectivity / 255
    Local Const $hBitmap_reflectedImage = _GDIPlus_BitmapCreateFromScan0($iW, $fReflectionHeight)
    Local Const $hGraphics_reflectedImage = _GDIPlus_ImageGetGraphicsContext($hBitmap_reflectedImage)
    _GDIPlus_GraphicsDrawImageRectRect($hGraphics_reflectedImage, $hBitmap, 0, $iH - $fReflectionHeight, $iW, $fReflectionHeight, 0, 0, $iW, $fReflectionHeight)
    _GDIPlus_ImageRotateFlip($hBitmap_reflectedImage, 6)
    Local Const $hBrush = _GDIPlus_LineBrushCreate($iW / 2, 0, $iW / 2, $fReflectionHeight, $iAlpha * 0x01000000 + BitAND(0x00FFFFFF, $iBgColor), 0xFF000000 + BitAND(0x00FFFFFF, $iBgColor))
    _GDIPlus_GraphicsFillRect($hGraphics_reflectedImage, 0, 0, $iW, $fReflectionHeight, $hBrush)
    _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBitmap_reflectedImage, 0, 0, $iW, $fReflectionHeight, 0, $iH + $iDeltaY, $iW, $fReflectionHeight)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics_reflectedImage)
    _GDIPlus_BitmapDispose($hBitmap_reflectedImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    Return $hBitmap_new
EndFunc
Sorry M23, that I did it for him but I couldn't resist.  :D

 

Information: Beta 3.3.11.3 has a bug in _GDIPlus_BitmapCreateFromMemory() function - don't use the beta!!!

 

Br,

UEZ

Edited by 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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • Moderators

UEZ,

No problem at all. I rather thought that you might find it difficult not to produce some code! :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

After taking a look at GDIPlusConstants.au3 file (Autoit 3.3.10.2), I've noticed an error in $GDIP_PXF32PARGB declaration.

Global Const $GDIP_PXF32PARGB = 0x000D200B

should be

Global Const $GDIP_PXF32PARGB = 0x000E200B

GdiPlusPixelFormats.h:

#define PixelFormatGDI                      0x00020000
#define PixelFormatAlpha                   0x00040000
#define PixelFormatPAlpha                 0x00080000
#define PixelFormat32bppPARGB      (11 | (32 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatGDI)

 

Zeehteam

Link to comment
Share on other sites

Thanks for the hint. Seems to be a typo. -> http://msdn.microsoft.com/en-us/library/cc230858.aspx

Also PixelFormat64bppPARGB is wrong.

Br,

UEZ

Edited by 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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...