ActualAkshay Posted February 22, 2013 Posted February 22, 2013 wanted to know if theres a way to create a blank image of specific color code using au3 only,for example, wanted to make blank jpg pic of hex code 004488 using au3 only, how can it be done? and second question is, how to place a transparent png over another picture and save it as jpg (or any other format)? + = 3rd, how to convert png to jpg? Regards,Akshay
UEZ Posted February 22, 2013 Posted February 22, 2013 (edited) Here a litte code example: expandcollapse popup#include <GUIConstantsEx.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Global Const $hGUI = GUICreate("GDI+ Test", 300, 300) Global Const $iPic = GUICtrlCreatePic("", 100, 100, 100, 100) Global Const $hPic = GUICtrlGetHandle($iPic) GUISetBkColor(0x000000, $hGUI) GUISetState() #region GDI+ ;create an empty bitmap Global Const $iWidth = 100, $iHeight = 100 ;dimension of the bitmap Global Const $iStride = 0, $pScan0 = 0, $iPixelFormat = $GDIP_PXF32ARGB ;some bitmap parameters Global $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0) Global Const $hBitmap = $aResult[6] ;this is the handle of the new empty bitmap Global Const $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;create a context to the bitmap handle to do some GDI+ operations Global Const $iBgColor = 0xFF004488 ;define background color -> ARGB _GDIPlus_GraphicsClear($hContext, $iBgColor) ;clear empty bitmap with new color Global Const $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Step_2_In.png") ;load a transparent PNG image which should be placed on the bitmap _GDIPlus_GraphicsDrawImageRect($hContext, $hImage, 0, 0, $iWidth, $iHeight) ;copy the image onto the bitmap. if image dimension <> bitmap dimension than the image will be displayed deformed ;save result as JPG and PNG (conversation is done automatically) _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\New_Image.jpg") _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\New_Image.png") ;let's display the new created bitmap in the GUI Global Const $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hPic) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, 100, 100) #endregion Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GDIPlus_ImageDispose($hImage) ;release image _GDIPlus_BitmapDispose($hBitmap) ;release bitmap _GDIPlus_GraphicsDispose($hContext) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete() Exit EndSwitch Until False Br, UEZ Edited February 22, 2013 by UEZ ActualAkshay 1 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
ActualAkshay Posted February 22, 2013 Author Posted February 22, 2013 (edited) Oh thanks a lot yay!~ Edited February 22, 2013 by ActualAkshay
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now