Created
March 20, 2020 01:16
-
-
Save wsmelton/0a27ec1aa9127ca23ff1b7772ec143c9 to your computer and use it in GitHub Desktop.
Trying to add text to a give bmp image file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Ref: https://stackoverflow.com/a/6827017/12974596 | |
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms"); | |
$file = Get-ChildItem 'C:\temp\template.bmp' | |
$img = New-Object System.Drawing.BitMap($file.FullName) | |
$newFile = 'C:\temp\eureka.bmp' | |
[String]$drawString = "lab-ss-01 server" | |
$colorBlue = (New-Object System.Drawing.ColorConverter).ConvertFromString("blue") | |
$drawFont = New-Object -TypeName System.Drawing.Font -ArgumentList "Arial",16 | |
$drawBrush = New-Object -TypeName System.Drawing.SolidBrush -ArgumentList $colorBlue | |
[float]$x = '150.0' | |
[float]$y = '50.0' | |
$stringFlags = New-Object System.Drawing.StringFormatFlags | |
$stringFlags.value__ = 2 | |
$drawFormat = New-Object -TypeName System.Drawing.StringFormat | |
$drawFormat.FormatFlags = $stringFlags | |
# this line won't run | |
(New-Object -TypeName System.Drawing.Graphics).DrawString($drawString,$drawFont,$drawBrush,$x,$y,$drawFormat) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment