Jump to content
Xtreme .Net Talk

robs108ducks

Members
  • Posts

    3
  • Joined

  • Last visited

robs108ducks's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. I�m working with images in C#. Loading from file system, resizing, then saving (overwriting.) This is all good up until the save over operation. I�ve tried a couple different ways of doing this but it either throws an exception or it destroys my image. Any ideas? WORKING APPROACH (but not what I want to do) //This works because there is no save-over operation attempted here. System.Drawing.Bitmap b1 = new System.Drawing.Bitmap(FullFilePath); b1.SetResolution(72,72); b1.Save(FullFilePath+�.copy.jpg�,System.Drawing.Imaging.ImageFormat.Jpeg); FIRST APPROACH //access filesystem via Bitmap Class Methods System.Drawing.Bitmap b1 = new System.Drawing.Bitmap(FullFilePath); b1.SetResolution(72,72); //Line 424 below, where program errors b1.Save(FullFilePath,System.Drawing.Imaging.ImageFormat.Jpeg); ERROR: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, Encoder Parameters encoderParams) at System.Drawing.Image.Save(String filename, ImageFormat format) at System.Drawing.Image.Save(String filename) �:line 424 SECOND APPROACH //access filesystem via IO Stream System.IO.FileStream UploadedFile = new System.IO.FileStream(FullFilePath,FileMode.OpenOrCreate,FileAccess.ReadWrite); System.Drawing.Bitmap OrigImage = new System.Drawing.Bitmap(UploadedFile); Console.WriteLine("Width: " + OrigImage.Width); OrigImage.SetResolution(72,72); OrigImage.Save(UploadedFile,System.Drawing.Imaging.ImageFormat.Jpeg); ERROR: The code executes, but it mangles the image � You can see the top quarter of the image but the bottom is all blacked out, and my image viewer reports it is still 100 dpi Has any one figured out how to do this? -Rob108ducks
  2. Learning ASP.NET C#... Really struggling to understand event handling and use of delegates. I've read and read what my training book has to offer and just don't get it. I'm a veteran of ASP, VB, and Delphi. My Delphi experience has made understanding the .NET C# object architecture pretty easy until I got to this (they are practically identical). Any recommendations on a good resource for understanding this? Preferably a good online tutorial? robs108ducks ________________________ I was born not knowing and have had only a little time to change that here and there. -Richard Feynman
  3. thanks a ton... this helped me a lot. Been stuck on how to resize images for a while. However, one small snag: How do I do it from a console application? Another question, is there any way to use the System.Drawing... Classes from a Console Application?
×
×
  • Create New...