Jump to content
Sign in to follow this  
ActualAkshay

Creating a blank image of specific hex color code?

Recommended Posts

ActualAkshay

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?

post-72083-0-20054700-1361515686_thumb.j

and second question is, how to place a transparent png over another picture and save it as jpg (or any other format)?

post-72083-0-20054700-1361515686_thumb.j + post-72083-0-65293700-1361515690_thumb.p = post-72083-0-17465500-1361515696_thumb.j

3rd, how to convert png to jpg?

:bye:

Regards,

Akshay

Share this post


Link to post
Share on other sites
UEZ

Here a litte code example:

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

Share this post


Link to post
Share on other sites
ActualAkshay

Oh thanks a lot yay!~ :thumbsup:

Edited by ActualAkshay

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  

  • Similar Content

    • Xandy
      By Xandy
      MapIt is a tile world editor.  MapIt was built around the concept of reversing Dragon Warrior map images.  MapIt can take image input and produce a tile and world array.
      MapIt features Unity style dragable labels that adjust property values.

      MapParser is a C++ project that needed updating after a hard drive failure.  New version:  Front-end in AutoIt, command line controls, and shared with the world; so that I can't lose it again.
      You can toggle the C++ MapParser off to see the difference in speeds between the MapParser CPP verse AutoIt function.  Function is named Scan_Tiles() in AutoIt.  You can also chose to download without MapParser.exe.
      At the moment Scanning a image resets the arrays, but you can add tiles after scanning.
      Images can be added as tiles without scan image at all.  Then configure settings to give your world parameters and manually fill the world data with tile indexes.
      Using the settings you can change tile size after a scan.  Example: you wanted to replace a map with different sized tiles.
      Changing and replacing tile / world data is easy.  B/c tile world editor.

      Hotkeys, I use CTRL+R in image above to signal replace tile action and I use "G" to Get the tile under mouse.
      Hotkeys are not saved to disk and thus are set to default between sessions.
      I might draw the world to pre-rendered surfaces and use them as multi-layer someday.  I do that in my AutoIt, DragonWarrior Remake but I could spend forever unsure what features are important for this.  The DW_Remake has a method of replacing a tile with a tile on two layers.  So you could replace a tree on the first layer with a grass, and a tree in the second layer.  This is all getting very confusing.
      I attempted to write the good code.  If something could be better, please advise.
      First release.  Enjoy.
      For download, videos, and example of created world file data; please visit the MapIt webpage: http://songersoft.com/programming/mapit/mapit_about.phtml
      Updated credits in files. (Twice now): 
      Special thanks: @AdmiralAlkex, @Melba23, @MrCreatoR
      Main AutoIt source file: Will not run without other Includes and SDL Dlls.
      Last Update push: 5/19/2018 7:38 PM EST
      Next Version Fixed Window Screen Size, Cancel no longer creates micro-GUI; same for Tile_Palette Size Tile Menu can scale all tiles  
    • Ambient
      By Ambient
      I have tried several way sto get this to work to no avail. Any help would be appreciated. #include <ListViewConstants.au3> #include <GuiListView.au3> #include "GuiListViewEx.au3" $idItem = GUICtrlCreateListViewItem($r & " | " & $c & $adoRs.Fields("TransactionAmount").value & " | " & $Timestamp & " | " & _StringProper($adoRs.Fields("Tillid").value) & @CRLF & @CRLF & "Card Number : " & $cardnum & " " , $idListView) ConsoleWrite( "IDITEM" & $idItem) If STRINGLEFT($adoRs.Fields("TransactionAmount").value,1)= "-" Then Consolewrite(" String is Negative" & @CRLF) ;Drops in Here as expected ;GUICtrlSetColor(-1, $COLOR_RED) ; Colour line if item is negative this didn' work $TxC= _GUICtrlListView_SetTextColor($hListView, $CLR_RED) ; I also tried $TxC= _GUICtrlListView_SetTextColor(-1, 0xFF0000) CONSOLEWRITE("TEXTCOLOUR RETURNED " & $TxC & @crlf) ; This is returning True ELSE Consolewrite(" String is NOT Negative" & @CRLF) EndIf  
    • lenclstr746
      By lenclstr746
      HELLO GUYS
      I'm a work on a background see and click bot project 
      I can complete it if your help me
      (using imagesearch , gdi+ and  fastfind)
    • dadalt95
      By dadalt95
      I would like to know if it's possible to pass an image recognition (captcha) system.
       
      What are the ways to achieve this?
      Just the references or links is enough for me by now.
       
      Thanks by now!
       
      Thanks!
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.