473,661 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Resize Gif Image without losing too much info?

I've got this bit of code:

Image origImage = Image.FromFile( "temp.jpg") ;
Image newImage = new Bitmap(objNewSi ze.Width, objNewSize.Heig ht,
origImage.Pixel format);

Graphics objGraphic = Graphics.FromIm age(newImage);

objGraphic.Comp ositingQuality = CompositingQual ity.HighQuality ;
objGraphic.Smoo thingMode = SmoothingMode.H ighQuality;
objGraphic.Inte rpolationMode = InterpolationMo de.High;

Rectangle objRect = new Rectangle(0, 0, 200, 200);

objGraphic.Draw Image(origImage , objRect);

newImage.Save(" temp_new.jpg", origImage.RawFo rmat);
It works beautifully for jpgs. As the GRaphics.FromIm age does not
accept Indexed pixel formats, such as Format8bppIndex ed, I made some
changes to my code:

Image origImage = Image.FromFile( "temp.gif") ;
Image newImage = new Bitmap(objNewSi ze.Width, objNewSize.Heig ht,
System.Drawing. Imaging.PixelFo rmat.Format24bp pRgb);

Graphics objGraphic = Graphics.FromIm age(newImage);

objGraphic.Comp ositingQuality = CompositingQual ity.HighQuality ;
objGraphic.Smoo thingMode = SmoothingMode.H ighQuality;
objGraphic.Inte rpolationMode = InterpolationMo de.High;

Rectangle objRect = new Rectangle(0, 0, 200, 200);

objGraphic.Draw Image(origImage , objRect);

newImage.Save(" temp_new.gif", origImage.RawFo rmat);

The result I get is an over-pixelated image. (As opposed to me using
Photoshop to resize the image) I'm running out of ideas. How can I
resize an indexed image wihtout losin too much info?
Nov 16 '05 #1
0 2289

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
898
by: funcSter | last post by:
I've got this bit of code: Image origImage = Image.FromFile("temp.jpg"); Image newImage = new Bitmap(objNewSize.Width, objNewSize.Height, origImage.Pixelformat); Graphics objGraphic = Graphics.FromImage(newImage); objGraphic.CompositingQuality = CompositingQuality.HighQuality; objGraphic.SmoothingMode = SmoothingMode.HighQuality;
14
2781
by: Rudy | last post by:
Hello all! I been trying to get a handle with Images. I have learned alot from the fine people here. So, I also learned that thumbnail images look terrible taken from a digital cam. I know why they look bad. So what is the best way to resize an image. I'm not too concerned about size, but I guess I would like to compress it on the upload. Any thoughts?
15
5336
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the path of the uploaded image, and resize it with the provided dimensions. My function is below. The current function is returning an error when run from the upload function: A generic error occurred in GDI+. Not sure what exactly that means. From what...
2
2503
by: Tim Arnold | last post by:
Hi, I'm using the Image module to resize PNG images from 300 to 100dpi for use in HTML pages, but I'm losing some vertical and horizontal lines in the images (usually images of x-y plots). Here's what I do: import Image def imgResize(self,filename): img = Image.open(filename) dpi = img.info.get('dpi') if dpi and 295 < int(dpi) < 305:
0
8341
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
8851
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
8754
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...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7362
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2760
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
1984
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1740
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.