Xee Posted April 16, 2003 Posted April 16, 2003 Anyone know how I would go about resizing jpg images? I want to be able to make thumbnails of jpg images while keeping the original the same size. Usually, I would use Microsoft Photo Editor and resize it to 25% of it's original size and then save it with a different name, but when I'm dealing with 15 or more images, that can get tedious. I'm not expecting any complete code; just a helpful point in the right direction and I'll take it from there. Thanks a lot. -Xee Quote
*Gurus* divil Posted April 16, 2003 *Gurus* Posted April 16, 2003 You would use the Bitmap class to load them from disk in to memory, then create another bitmap passing the old bitmap and the new size to the constructor. You can then use the bitmap's Save method. To automate this for, say, a whole directory of images, you'd use System.IO.Directory.GetFiles to get all the files ending in bmp in to a string array and loop through it. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
hog Posted May 7, 2003 Posted May 7, 2003 Divil, I'm trying to do this but, I'm probably being thick here, there isn't a constructor for Bitmap that accepts a bitmap as an argument. there is one that accepts a graphics object but I can't get that to work either :-( Quote My website
*Experts* Nerseus Posted May 7, 2003 *Experts* Posted May 7, 2003 The Bitmap class is derived from Image, which is one of the constructors. You can even use a Bitmap without casting, as in: Bitmap b = new Bitmap(@"c:\mybitmap.bmp"); Bitmap b2 = new [b]Bitmap(b, 100, 100);[/b] b2.Save(@"c:\mynewsmallerbitmap.bmp", System.Drawing.Imaging.ImageFormat.Bmp); Note the last param to Save. This is where you define the type of picture. Even though you may save the file as "image.BMP", if you don't specify the ImageFormat, you'll get a PNG formatted image. -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
robs108ducks Posted June 10, 2003 Posted June 10, 2003 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? Quote
AndreRyan Posted June 11, 2003 Posted June 11, 2003 Right Click the References Directory in the Solution Explorer, choose Add and find System.Drawing.dll, add it to the project then use the Imports System.Drawing to make use of it Quote .Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
ThePentiumGuy Posted June 11, 2003 Posted June 11, 2003 The Bitmap class is derived from Image, which is one of the constructors. You can even use a Bitmap without casting, as in: Bitmap b = new Bitmap(@"c:\mybitmap.bmp"); Bitmap b2 = new [b]Bitmap(b, 100, 100);[/b] b2.Save(@"c:\mynewsmallerbitmap.bmp", System.Drawing.Imaging.ImageFormat.Bmp); -Nerseus in the first line of code whats the @ symbol next to NewBitmap? How do you write the same in vb.net? Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Administrators PlausiblyDamp Posted June 11, 2003 Administrators Posted June 11, 2003 the @ symbol prevents C# treating the \ as an escape character. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.