Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Display an image from powershell?

Reply
 
Old 01-06-2009   #1 (permalink)
James


 
 

Display an image from powershell?

I need, given a file path to a .jpg or .bmp, to display the image on the
screen. Here is some code I came across on
the net:

$file = (get-item "c:\image.jpg")

[void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms")
$form = new-object Windows.Forms.Form
$form.Text = "Image Viewer"
$form.width = 1280
$form.height = 1024
$pictureBox = new-object Windows.Forms.PictureBox
$pictureBox.Width = 1280
$pictureBox.Height = 1024

$pictureBox.Image = [System.Drawing.Image]::Fromfile($file)
$form.controls.add($pictureBox)
$form.Add_Shown( { $form.Activate() } )
$form.ShowDialog()

I modified the code a little, my problem though is that when
$form.showdialog executes, powershell waits for the dialog results (i.e. a
user to close the dialog). Is there a way for the script to keep executing
and possibly close the dialog itself? Like a simple slide-show type script?


My System SpecsSystem Spec
Old 01-07-2009   #2 (permalink)
James


 
 

Re: Display an image from powershell?

Doesn't matter any more, I found a nice software program for slide shows for
free on the net that works, I have Vista and it has a slideshow program but
it causes tearing when watching videos in WMP (on a second monitor) and
doing a slide show at the same time.

"James" <no@xxxxxx> wrote in message
news:B5E11535-671A-4CF5-BA8A-3CD9E405DD72@xxxxxx
Quote:

>I need, given a file path to a .jpg or .bmp, to display the image on the
>screen. Here is some code I came across on
> the net:
>
> $file = (get-item "c:\image.jpg")
>
> [void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms")
> $form = new-object Windows.Forms.Form
> $form.Text = "Image Viewer"
> $form.width = 1280
> $form.height = 1024
> $pictureBox = new-object Windows.Forms.PictureBox
> $pictureBox.Width = 1280
> $pictureBox.Height = 1024
>
> $pictureBox.Image = [System.Drawing.Image]::Fromfile($file)
> $form.controls.add($pictureBox)
> $form.Add_Shown( { $form.Activate() } )
> $form.ShowDialog()
>
> I modified the code a little, my problem though is that when
> $form.showdialog executes, powershell waits for the dialog results (i.e. a
> user to close the dialog). Is there a way for the script to keep
> executing and possibly close the dialog itself? Like a simple slide-show
> type script?
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
can powershell be included in a Win PE boot image? PowerShell
Windows programming and image manipulation in Powershell question PowerShell
Viewing an image from within Powershell PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46