"Parameter is not valid" when trying to save an image.
"Parameter is not valid" when trying to save an image.
"Parameter is not valid" when trying to save an image.
"Parameter is not valid" when trying to save an image.
"Parameter is not valid" when trying to save an image.
"Parameter is not valid" when trying to save an image. "Parameter is not valid" when trying to save an image. "Parameter is not valid" when trying to save an image. "Parameter is not valid" when trying to save an image. "Parameter is not valid" when trying to save an image. "Parameter is not valid" when trying to save an image. "Parameter is not valid" when trying to save an image. "Parameter is not valid" when trying to save an image.
"Parameter is not valid" when trying to save an image. "Parameter is not valid" when trying to save an image.
"Parameter is not valid" when trying to save an image.
Go Back  Xtreme Visual Basic Talk > > > "Parameter is not valid" when trying to save an image.


Reply
 
Thread Tools Display Modes
  #1  
Old 08-11-2008, 09:43 PM
TerMight TerMight is offline
Regular
 
Join Date: Oct 2007
Posts: 73
Default "Parameter is not valid" when trying to save an image.


Currently, I am trying to save an image using the .Save method.

The variable imgformat declared as an object (I have tried declaring this as an ImageFormat with the correct imports yet get the same error)

The point of declaring it as an Object or ImageFormat is to leave it open for the calling block to specify the format to save the bitmap in. The call works like this approximately.

Code:
SaveScreen(txtFilePath.Text, ImageFormat.Jpeg)
This is relevant code:

Code:
    Private Sub SaveScreen(ByVal filepath As String, ByVal imgformat as Object)
        Dim img As Bitmap
        Dim sc As New Screencap.clsScreencap 'uses .NET API to return a bitmap
        img = sc.CaptureScreen()

        '-------- VARIABLES --------
        '--- filepath is currently set to "C:\Image.JPEG"
        '--- imgformat is currently set to ImageFormat.Jpeg
        '----------------------------

        If File.Exists(filepath) = True Then
            File.Delete(filepath)
            img.Save(filepath, imgformat)
        Else
            img.Save(filepath, imgformat)
        End If
    End Function

Last edited by TerMight; 08-11-2008 at 09:48 PM.
Reply With Quote
  #2  
Old 08-11-2008, 10:44 PM
TerMight TerMight is offline
Regular
 
Join Date: Oct 2007
Posts: 73
Default

Anyone? I am really stuck here, this is pretty much the only thing keeping the application from being completed. I cannot pinpoint the problem, the exception is so generic, and I don't understand what could be causing it. Nothing appears to me to be incorrect with the usage of img.Save.
Reply With Quote
  #3  
Old 08-12-2008, 12:13 PM
TerMight TerMight is offline
Regular
 
Join Date: Oct 2007
Posts: 73
Default

I managed to get a hold of the issue. Apparently the Bitmap that was being tossed back from the function was not made properly to save and image file. I forgot to add PixelFormat.Format32bppRgb when Instantiating the Bitmap object.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
"Parameter is not valid" when trying to save an image.
"Parameter is not valid" when trying to save an image.
"Parameter is not valid" when trying to save an image. "Parameter is not valid" when trying to save an image.
"Parameter is not valid" when trying to save an image.
"Parameter is not valid" when trying to save an image.
"Parameter is not valid" when trying to save an image. "Parameter is not valid" when trying to save an image. "Parameter is not valid" when trying to save an image. "Parameter is not valid" when trying to save an image. "Parameter is not valid" when trying to save an image. "Parameter is not valid" when trying to save an image. "Parameter is not valid" when trying to save an image.
"Parameter is not valid" when trying to save an image.
"Parameter is not valid" when trying to save an image.
 
"Parameter is not valid" when trying to save an image.
"Parameter is not valid" when trying to save an image.
 
-->