Sign in to follow this  
Followers 0
FireFox

[SOLVED] Picture repeat

3 posts in this topic

#1 ·  Posted (edited)

Hi,

I have got a square picture (ex: 100*100) which is in the background of my gui (ex: 500*500), but the image is stretched if i set the bounds to the gui size.

I'm wondering if it's possible to make it repeat in order to fill the gui without resizing the picture like "repeat" style in css.

Edit: I don't want to create multiple Pic ctrls to fill the gui (because my gui can be resized)

Thanks in advance.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this:

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>

_GDIPlus_Startup()
Global Const $w = 680
Global Const $h = 710
Global Const $hGUI = GUICreate("Test", $w, $h, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME))
Global Const $idPic = GUICtrlCreatePic("", 0, 0, $w, $h)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()

Global $sImage = StringReplace(@AutoItExe, "autoit3.exe", "ExamplesGUIMerlin.gif")
TileImage($sImage, $idPic, $w, $h)

Do
Until GUIGetMsg() = -3

GUIDelete()
_GDIPlus_Shutdown()
Exit

Func TileImage($sImage, $iControlID, $iWidth, $iHeight, $iWrapMode = 0) ;coded by UEZ 2012
    If Not FileExists($sImage) Then Return SetError(1, 0, 0)
    Local $hImage = _GDIPlus_ImageLoadFromFile($sImage)
    If @error Then Return SetError(2, 0, 0)
    Local $hTextureBrush = DllCall($ghGDIPDll, "uint", "GdipCreateTexture", "ptr", $hImage, "int", $iWrapMode, "int*", 0)
    $hTextureBrush = $hTextureBrush[3]
    Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
    $hBitmap = $hBitmap[6]
    Local $hCtx = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsFillRect($hCtx, 0, 0, $iWidth, $iHeight, $hTextureBrush)
    Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    Local Const $IMAGE_BITMAP = 0
    Local Const $STM_SETIMAGE = 0x0172
    _WinAPI_DeleteObject(GUICtrlSendMsg($iControlID, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap))
    _GDIPlus_BrushDispose($hTextureBrush)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hCtx)
    _WinAPI_DeleteObject($hHBitmap)
    Return 1
EndFunc

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!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

@UEZ

Thanks! I was not expecting less from you :oops:

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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