Jump to content
buymeapc

[SOLVED] GDIPlus image created with a faint border??

Recommended Posts

Posted (edited)

Hey all,

Thanks to the forums, I've managed to create a Base64 image that I can use as a partial background for my GUI. However, the issue I'm having is that when the image is created, you can see a faint border around where the image is created. Is there any way to create the image without having this border created, so it can blend in?

Here's a small reproducer. Thanks for the help!

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

_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172
Global Const $hGUI = GUICreate("Blending a pic in with the BG", 450, 144)
GUISetBkColor(0xFFFFFF, $hGUI)
GUISetState()

$idPic2 = GUICtrlCreatePic("", 150, 0, 300, 144) ; resized picture
$hBitmap2 = _GDIPlus_BitmapCreateFromMemory(_OptumFade())
$hBitmap_resized = _GDIPlus_ImageResize($hBitmap2, 300, 144) ;GDI+ bitmap
$hHBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_resized) ;GDI bitmap

_WinAPI_DeleteObject(GUICtrlSendMsg($idPic2, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap2))

While True
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

;Code below was generated by: 'File to Base64 String' Code Generator v1.20 Build 2015-01-20

Func _OptumFade($bSaveBinary = False, $sSavePath = @ScriptDir)
    Local $OptumFade
    $OptumFade &= 'iVBORw0KGgoAAAANSUhEUgAAASMAAABGCAYAAACHbvJwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAlDSURBVHhe7Z3teqrKEoQB3fd/t2f/SMBTVd0No2KiYFbY66nXhcxHd08DMxWiLtP/799/L90TTLC6jJeu77MhofPShNJQ4bKVjgMLreMFsaI0DGi/ckEf63w6RSNauv4S/izzn8qw6emEvdplO8FWRUEblekmv0m2EYe+3PGJ/TKIPWOim8fL444eAFvmMuK4wm9S8wUHOeT4E33RHylE/jk4QI1FbCN8mX9Y0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EPwV4lRfAHc83xnf/s34eZy1h/BXtlW/PL7htkePGPfmD/NM2GN+Q0sRl9Q4lPCMJez/gj2yrbil983zPbgGfvG/GmeCWvMb/DrYsS1UVsR9aVFCyhX0SwIK/SXPvtn87le4cqfbbJXFx/qjVo6xJfOwS6/W66+hO7CBtpUrPSpredGW8RPx/BrbDQWd0Sh6LfY0F5dtG3saq9ihlel+kjVq62pZ9i/n+aYvb2wfcUj+3Z/20fW+ousa86P09h2/Qj9ygjVpMWmFYJk1NB1k9onfg1l5KontvbdFJVYrCwmjDNNaOBguahpwu/2Zl2xWdcfHqAj/VHOsaM+ZpxJ8WmmP1KgWCkUGIPfCK5hWM8kODZtCfuYJ/17yT189T3jcpKf2suOvojKLBUHD6WleuRCaKc0aZMndWDsKCqufPlIHyZzfYkZA33ZzerfAA+pzkOQ19x8y3LaotSey7nMk6m26/OqeZj98w/fpOboWj/nabSFzdSNXf/x+ZEeP0fl1FJNQ2WKvZYyqqpRUHoue9hg4U48ECzMWsUlKiVKWogoD3KOvsuEisz5JwXkhtghKjx8FNgFBtToE3F6LuDoVlmxaCgDmDMVhmM/SyPzg83AToCmaRw7Dk+jnjkzX9XZRGGiIf8yi4LwnzqVM/eZD/OdeAJTpBibcXAUygGnCOmjAf2KRU4UI+zZF14zPe3YIgPQdv6HmReNThrnDuYCr735Fk3tKGmtzucSzOV5ulyfV/2AZB0xbuX/euahX4szuOAHJOfxkGum77ru/yXLKH+v3ak0AAAAAElFTkSuQmCC'
    Local Const $bString = Binary(_WinAPI_Base64Decode($OptumFade))
    If $bSaveBinary Then
        Local Const $hFile = FileOpen($sSavePath & "\Optum_Fade_291x70.png", 18)
        If @error Then Return SetError(1, 0, 0)
        FileWrite($hFile, $bString)
        FileClose($hFile)
    EndIf
    Return $bString
EndFunc   ;==>_OptumFade

Func _WinAPI_Base64Decode($sB64String)
    Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "")
    Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]")
    $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($bBuffer, 1)
EndFunc   ;==>_WinAPI_Base64Decode

 

Edited by buymeapc

Share this post


Link to post
Share on other sites

Try

$hBitmap_resized = _GDIPlus_ImageResize($hBitmap2, 300, 144, $GDIP_INTERPOLATIONMODE_NEARESTNEIGHBOR) ;GDI+ bitmap

and it should work as expected. The reason the is interpolation on resize function.


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

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

×
×
  • Create New...