473,773 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to save a GIF file using .NET

1 New Member
I can't save a picture, and i dont know the reson.
here is the code:
Dim img As New Bitmap(Server.M apPath("409.gif "))

Dim height As Integer = Int(img.Height)
Dim Width As Integer = Int(img.Width)

Dim img1 As New Bitmap(img.Clon e(New RectangleF(0, 0, 300, 50), img.PixelFormat ))

img1.Dispose()
img1.Save((Serv er.MapPath("r.g if")), ImageFormat.Gif )

this is the eror that i reseve:


Server Error in '/WebApplication3 ' Application.
--------------------------------------------------------------------------------

Invalid parameter used.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Argument Exception: Invalid parameter used.

Source Error:


Line 35:
Line 36: img1.Dispose()
Line 37: img1.Save((Serv er.MapPath("r.g if")), ImageFormat.Gif )
Line 38:
Line 39: End Sub


Source File: c:\inetpub\wwwr oot\WebApplicat ion3\WebForm1.a spx.vb Line: 37

Stack Trace:


[ArgumentExcepti on: Invalid parameter used.]
System.Drawing. Image.Save(Stri ng filename, ImageCodecInfo encoder, EncoderParamete rs encoderParams)
System.Drawing. Image.Save(Stri ng filename, ImageFormat format)
WebApplication3 .WebForm1.Page_ Load(Object sender, EventArgs e) in c:\inetpub\wwwr oot\WebApplicat ion3\WebForm1.a spx.vb:37
System.Web.UI.C ontrol.OnLoad(E ventArgs e)
System.Web.UI.C ontrol.LoadRecu rsive()
System.Web.UI.P age.ProcessRequ estMain()




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.432 2.573; ASP.NET Version:1.1.432 2.573
Oct 8 '07 #1
3 1860
nateraaaa
663 Recognized Expert Contributor
Try moving your Dispose() method call after the save method. Also the file names that you are using do not look consistent. At the beginning you are using 409.gif then you try saving r.gif. I am not sure what you are trying to do there.

Nathan
Oct 8 '07 #2
Frinavale
9,735 Recognized Expert Moderator Expert
Hi Avnireut,

I have changed the title of your thread to better refelect the problem you are facing. Please use a more descriptive title for your questions in the future.

Thanks

Moderator


-Frinny
Oct 8 '07 #3
Plater
7,872 Recognized Expert Expert
First, move the .Dispose() after the save call as stated.
Next ImageFormat is not the same object as ImageCodecInfo. I don't know why it wants a ImageCodecInfo when there appears to be an overload of .Save(string, ImageFormat) but I would suggest trying to fix that too.
Oct 8 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
626
by: F. Hall | last post by:
If I read a bitmap image from one file and save it to another the save operation is slow unless I draw on the image. In other words, Image inputImage = Image.FromFile( @"c:\temp\source.bmp" ); using ( Graphics g = Graphics.FromImage( inputImage ) ) { g.DrawLine( new Pen(Brushes.White), 0, 0, 1, 1 ); } inputImage.Save( @"c:\temp\sink.bmp", ImageFormat.Bmp );
0
6437
by: a | last post by:
Save text file as html kloepper 17:42 23 Jul '04 I'm using httpwebresponse and a StringBuilder to return a stream that originates as a file with the .txt suffix (My download code converts the html tags in this text file to well formed XHTML tags). The contents of the file contain html tags and the data in those tags. eg., <table cellSpacing=0 cellPadding=0 width="100%" align=center border=0> <TBODY> <tr> <td width="48%"></td> <td...
4
11008
by: Carl Williams | last post by:
Hope someone can help with this... I have looked at all the newsgroup articles and put into practice all the suggestions but to no good. I am pretty new to CSharp and .Net so any help would be greatly appreciated. I have an .ASPX.CS in which I am trying to open an XML file (which already contains content), making some alterations to the XML obtained from the file, and then trying to 'Save' the XML back to the file. I am using a...
4
4532
by: Jae | last post by:
I'm writing a web application that exports and imports excel files. The application gets a list of users and their info and displays it in a datagrid .The user then selects to save the file as a tab delimited file or an excel file. The application then saves the file in the correct format. The flip side is for the user to import/upload the file to the server The application must be able to import the excel file and read the contents. I...
4
3719
by: Glenn M | last post by:
I have a shared XML file on a server . i also have one xslt file that performs a simple transform on in to view the data. now i want to have another page that lets users modify the shared xml file via some editable controls such as text boxes , option boxes etc. how can i implment this , should i use another xslt file with <INPUT> controls . if so how can i save the result back using the asp.net
4
4514
by: sunilj20 | last post by:
Hello, I have a requirement wherein, a user clicks on a file name in an ASP.NET web application, and the file should automatically be downloaded (Without showing the "Open", "Save As") in the local machine at a pre defined path (path defined in the registry), and launch the file in its associated application. I think this can be done through ActiveX Controls, but i dont know how to create ActiveX controls in .NET??
8
3713
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box and save it to a file. This step is not to hard however the contents of the textarea is mostly latex source so it contains just about every special character you can imagine. My question is this, how do I save an exact copy of the textarea...
4
6262
by: Jonny | last post by:
Hello Group How do I open a Save File Dialog from an ASPX page behind a browse button? Any help would be fantastic!! I am using ASP.NET 1.1 using VB.NET as the coding language TIA
3
6440
by: =?Utf-8?B?YXNkZg==?= | last post by:
Hello. I am making a web application with c# and am using this code: Response.ContentType = "application/x-excel"; Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("あいうえお") + ".csv"); Encoding encoding = Encoding.GetEncoding("Shift-JIS"); Response.BinaryWrite(encoding.GetBytes(csvStr)); Response.End(); It works fine..the data gets saved nicely to an excel file. The user pushes the...
3
7162
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this file but save it as an excel file. The data in this excel file will be imported into an Access database. The
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.