Jump to content
Sign in to follow this  
Vindicator209

Creating a blank image

Recommended Posts

Hello, I am trying to create a script to replace many .png files with a blank image of the same dimensions.

I guessed I would be using GDIPlus, but I'm not sure how to create a blank image using it.

Here is my unfinished attempt:

#include <Array.au3>
#include <File.au3>
#include <GDIPlus.au3>
_GDIPlus_Startup()
$folders = _FileListToArray(@ScriptDir,"*",2)
For $i = 1 to $folders[0]
    $files = _FileListToArray(@ScriptDir & "\" & $folders[$i],"*.png")
    For $k = 1 to $files[0]
        $image = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $folders[$i] & "\" & $files[$i])
        $height = _GDIPlus_ImageGetWidth($image)
        $width = _GDIPlus_ImageGetHeight($image)
        _GDIPlus_ImageDispose($image)
        FileDelete(@ScriptDir & "\" & $folders[$i] & "\" & $files[$i])

        ;create blank image of height and width
        $newimage = "Blank Image Here"
        $CLSID = _GDIPlus_EncodersGetCLSID ("PNG")
        _GDIPlus_ImageSaveToFileEx($newimage,@ScriptDir & "\" & $folders[$i] & "\" & $files[$i],$CLSID)
    Next
Next
_GDIPlus_Shutdown()

How would I create a blank image using the GDIPlus UDF to be saved using _ImageSaveToFileEx?

Thanks


[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites

Try this:

#include <Array.au3>
#include <File.au3>
#include <GDIPlus.au3>
_GDIPlus_Startup()
$folders = _FileListToArray(@ScriptDir,"*",2)
For $i = 1 to $folders[0]
    $files = _FileListToArray(@ScriptDir & "\" & $folders[$i],"*.png")
    For $k = 1 to $files[0]
        $image = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $folders[$i] & "\" & $files[$i])
        $height = _GDIPlus_ImageGetWidth($image)
        $width = _GDIPlus_ImageGetHeight($image)
        _GDIPlus_ImageDispose($image)
        FileDelete(@ScriptDir & "\" & $folders[$i] & "\" & $files[$i])

        ;create blank image of height and width
        $newimage = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $width, "int",  $height, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
        $newimage = $newimage[6]
        $CLSID = _GDIPlus_EncodersGetCLSID ("PNG")
        _GDIPlus_ImageSaveToFileEx($newimage,@ScriptDir & "\" & $folders[$i] & "\" & $files[$i],$CLSID)
        _GDIPlus_BitmapDispose($newimage)
    Next
Next
_GDIPlus_Shutdown()

Not tested!

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

That works beautifully! Thanks!


[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...