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

    • Skeletor
      By Skeletor
      Hi All,
      It has been bugging me for a while now. 
      Can you view the AutoIt code from within a compiled exe. Like how you can with most .Net exe's by using a certain program.
      If this is possible, how then can I secure my program (if this method exists).
       
    • badcoder123
      By badcoder123
      Hey, all.  
      I've been looking for a way to change cursor colour but not the cursor itself. I've been looking for a couple hours now and can't find anything.  I also don't even know where to start, if anyone has any tips or examples please comment them.
      Thanks
    • Xandy
      By Xandy
      Special thanks: AdmiralAlkex, Melba23, MrCrearoR, Dragon Warrior 3, SDL
      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.  
      Changing and replacing tile / world data is easy.  B/c tile world editor.

      CTRL+R in image above to signal replace tile action and I use "G" to Get the tile under mouse.
      A full list of hotkeys can be assigned in the: Help Menu\Hotkeys
       
      MapParser is a C++ project that scans images for unique tiles. 
      MapIt can be downloaded without MapParser. MapParser can be toggled off in the Scan_Image dialog. Without MapParser, MapIt will use the Scan_Tiles() function written in AutoIt ; which is 100 * slower Idk. If MapParser.exe will not run for you:      Installing Visual C++ Redistributable for Visual Studio 2015 should fix it: https://www.microsoft.com/en-us/download/details.aspx?id=48145   
      You can start with example world and tiles.
      Example world was made following these steps:
      Started with a tile map image of DragonWarrior3 town of: Reeve From MapIt World Menu \ New \ Scan_Image dialog, I set the area to exclude the key legend to the far right of image. After scanning the map image to world and tile array.  I removed a few of the map artifacts.  More work could be done on this world; removing unwanted tiles, but it is fine for now. I saved my world to disk.  This creates folder: Worldname: Containing folder of Tiles and a Worldname.txt. Using The Gimp, I edited some tiles to have a transparent color: Stairs, Trees, Desk Tables, Chest-of-drawers, Chairs, Signs, Doors, Beds. I changed the world layers to 2: World Menu \ Properties. F9 Finds all selected tile on current layer and changes to a new selected tile on new layer. I used F9 to change all Trees on layer: 0 to Trees on layer: 1. Then I used F9 to change all Trees on layer: 0 to Grass on layer: 0  
      In this video you can see how I used the Tile Menu \ Replace From Disk option to remap tile images to my custom tiles.  Conveniently my tiles already have a transparent pixel.
      See video for how that was done:
      To use the example world:
      First unzip the world save file: http://songersoft.com/programming/mapit/worlds/Reeve_Swapped.zip From the World Menu: choose \Load Navigate to the Reeve_Swapped.txt located in the extracted zip. Or you can scan any image.
      The map images I used are here: http://www.realmofdarkness.net/dq/games/nes/dw3/maps/world
      For download, videos, and example of created world file data; please visit the MapIt webpage: http://songersoft.com/programming/mapit/mapit_about.phtml
    • Skeletor
      By Skeletor
      Hi All,
      While creating a few excel spreadsheets using AutoIt, I came across something which to my limiting time to research the forums I don't anyone has mentioned. 
      The color pallettes are reversed. 
      Huge shock to me.
       
      I wanted to produce a red row but kept on getting blue. 
      Seems like 0xFF0000 was red on the charts but when running the script, I got blue. 
      I then played around with the colors, and after a few tries, I finally got Red. 
      Reversed the FF0000 and the result is 0000FF.
       
      So for Excel compared to Html
      0000FF (Red) - Excel
      0000FF (Blue) - Html

      FFFF00 (Cyan) - Excel
      FFFF00(Yellow) - Html
       
    • xtcislove
      By xtcislove
      Hello,
      i stuck again,
      Im using this function to create a treeview from root dir.
       
      ;https://autoit.de/index.php?thread/86082-treeview-root-verbergen/&postID=691139#post691139 #include <File.au3> #include <WindowsConstants.au3> Global $sPath = @ScriptDir Global $hGui = GUICreate('TreeView-Example', 400, 600) Global $idTreeView = GUICtrlCreateTreeView(10, 10, 380, 580, Default, $WS_EX_CLIENTEDGE) GUISetState() _CreatePath($sPath, $idTreeView) Do Until GUIGetMsg() = -3 Func _CreatePath($sPath, $idParent) Local $aFolder, $aFiles, $idItem If StringRight($sPath, 1) <> '\' Then $sPath &= '\' $aFolder = _FileListToArray($sPath, '*', $FLTA_FOLDERS) If Not @error Then For $i = 1 To $aFolder[0] $idItem = GUICtrlCreateTreeViewItem($aFolder[$i], $idParent) _CreatePath($sPath & $aFolder[$i], $idItem) Next EndIf $aFiles = _FileListToArray($sPath, '*', $FLTA_FILES) If @error Then Return For $i = 1 To $aFiles[0] $idItem = GUICtrlCreateTreeViewItem($aFiles[$i], $idParent) Next EndFunc Folder Structure:

      Folder1
      Folder2
      Folder3
      If a file exists in multiple folders, i like to color it red, if not green. 

      I know how to do this for files, but nut for the folders.

      Because if there is only 1 file in Folder2 that is also in Folder1 that it should only color this single file red, inlcuding its whole tree.

      The Folder1 and Folder2 should be red in this case, too. Other files and trees should stay green.
       
      Edit:
      Basically i like to color a file and its belonging tree red if the file exists more than 1 time.
×