473,804 Members | 2,998 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is Degradation in Quality Necessary?

I'm using the following code to rotate an image (jpeg or gif), and have
discovered that there is a significant degradation in the quality of the
photo.

Just wondering if there is a way to rotate/flip a graphic in .NET *without*
data loss. If so, how? If not, why?

I understand that when *resizing* a graphic, some degradation in the
appearance will result from the loss of data. However, when it comes to
simply rotating or flipping a graphic, is it necessary that any data loss
will occur?

System.IO.FileS tream fs = new System.IO.FileS tream(pathToOri ginal,
System.IO.FileM ode.Open, System.IO.FileA ccess.ReadWrite );
System.Drawing. Image imageToFlip = System.Drawing. Image.FromStrea m(fs);
imageToFlip.Rot ateFlip(System. Drawing.RotateF lipType.Rotate9 0FlipNone);
// then either of these depending on the origina'ls format (jpeg or gif):
imageToFlip.Sav e(pathToOrigina l, System.Drawing. Imaging.ImageFo rmat.Jpeg);
imageToFlip.Sav e(pathToOrigina l, System.Drawing. Imaging.ImageFo rmat.Gif);

Thanks.
Nov 16 '05 #1
2 3095
Cecil Windham wrote:

I'm using the following code to rotate an image (jpeg or gif), and have
discovered that there is a significant degradation in the quality of the
photo.

Just wondering if there is a way to rotate/flip a graphic in .NET *without*
data loss. If so, how? If not, why?

I understand that when *resizing* a graphic, some degradation in the
appearance will result from the loss of data. However, when it comes to
simply rotating or flipping a graphic, is it necessary that any data loss
will occur?

System.IO.FileS tream fs = new System.IO.FileS tream(pathToOri ginal,
System.IO.FileM ode.Open, System.IO.FileA ccess.ReadWrite );
System.Drawing. Image imageToFlip = System.Drawing. Image.FromStrea m(fs);
imageToFlip.Rot ateFlip(System. Drawing.RotateF lipType.Rotate9 0FlipNone);
// then either of these depending on the origina'ls format (jpeg or gif):
imageToFlip.Sav e(pathToOrigina l, System.Drawing. Imaging.ImageFo rmat.Jpeg);
imageToFlip.Sav e(pathToOrigina l, System.Drawing. Imaging.ImageFo rmat.Gif);

Thanks.


As you are aware, jpeg compression is lossy. During a rotate, the image has to
be decompressed, rotated, and then recompressed. The recompression will cause
inevitable loss of quality.

I don't know the details of the compressor, but most jpeg compressors have a
quality (and other) settings to be used during compression. The default may be
to minimize size (at the expense of visual quality). Check the docs and see if
you can change to a higher quality compression.
Nov 16 '05 #2
Just to add to this response, there is a way to do a lossless rotation of a
JPEG image. A search on Google should turn up some results since it is
widely used in digital image catalogue programs.

Colin

"Julie" <ju***@nospam.c om> wrote in message
news:40******** *******@nospam. com...
Cecil Windham wrote:

I'm using the following code to rotate an image (jpeg or gif), and have
discovered that there is a significant degradation in the quality of the
photo.

Just wondering if there is a way to rotate/flip a graphic in .NET *without* data loss. If so, how? If not, why?

I understand that when *resizing* a graphic, some degradation in the
appearance will result from the loss of data. However, when it comes to
simply rotating or flipping a graphic, is it necessary that any data loss will occur?

System.IO.FileS tream fs = new System.IO.FileS tream(pathToOri ginal,
System.IO.FileM ode.Open, System.IO.FileA ccess.ReadWrite );
System.Drawing. Image imageToFlip = System.Drawing. Image.FromStrea m(fs);
imageToFlip.Rot ateFlip(System. Drawing.RotateF lipType.Rotate9 0FlipNone);
// then either of these depending on the origina'ls format (jpeg or gif): imageToFlip.Sav e(pathToOrigina l, System.Drawing. Imaging.ImageFo rmat.Jpeg); imageToFlip.Sav e(pathToOrigina l, System.Drawing. Imaging.ImageFo rmat.Gif);
Thanks.
As you are aware, jpeg compression is lossy. During a rotate, the image

has to be decompressed, rotated, and then recompressed. The recompression will cause inevitable loss of quality.

I don't know the details of the compressor, but most jpeg compressors have a quality (and other) settings to be used during compression. The default may be to minimize size (at the expense of visual quality). Check the docs and see if you can change to a higher quality compression.

Nov 16 '05 #3

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

Similar topics

0
1544
by: Yash | last post by:
We have an application that loads millions of records into a table. Around 10 fields in this record are date fields. We perform the insert using SQL*Loader in direct path mode. The loading takes a few hours. Recently we had to convert the date columns to TIMESTAMP WITH TIMEZONE(3). After doing the appropriate changes in the SQL*Loader control file, when we performed a load, we experienced a performance degradation of 50%. Is the...
4
1940
by: Jason Heyes | last post by:
What can I do to circumvent the performance degradation associated with dynamic allocation and small objects? Thanks.
4
367
by: Cecil Windham | last post by:
I'm using the following code to rotate an image (jpeg or gif), and have discovered that there is a significant degradation in the quality of the photo. Just wondering if there is a way to rotate/flip a graphic in .NET *without* data loss. If so, how? If not, why? I understand that when *resizing* a graphic, some degradation in the appearance will result from the loss of data. However, when it comes to simply rotating or flipping a...
2
2941
by: Travis | last post by:
Hi everyone, I'm using the System.Drawing.Imaging.Bitmap to retrieve and modify the metadata tags (user comments, keywords etc) of JPEGS. I was wondering if changing these tags in any way degrades the image quality of the JPEG. I am using SetPropertyItem to change the tag value and then calling the Save method to save the JPEG under a different name (you have to do this because GDI holds a lock on the original file).... If there is...
6
2775
by: Michael | last post by:
I'm trying to use the Bitmap class's Save Method to save a Bitmap as a GIF. My code runs fine, and converts the image, but the quality is not anywhere close to as good. I know that GIF quality is not a good as a BMP's but, is there a way to convert the image while preserving its quality. Any help would be greatly appreciated. Here's what I have... Public Enum ImageType Bmp = 0 Emf = 1
15
9623
by: WHY | last post by:
Since there's no way to create a c# method with optional, or nullable parameters. And since you can't write an overloaded web method. Is it possible to edit the WSDL in conjunction with a c# method to make the parameter optional, or have a default value at the client consumer? --
3
1853
by: petermichaux | last post by:
Hi, I'm trying to do the right thing. I currently have a page that doesn't have any JavaScript and the page works. The page works with CSS on or off. Now I would like to add some JavaScript to enhance the page. The JavaScript will rearrange some of the DOM and use CSS. I am willing to put in the effort to try to ensure that the JavaScript doesn't do anything if necessary JavaScript support for full functionality is not available. This...
8
3693
by: berkshire | last post by:
Hi, Anyone know of a script out there that can resize images and not sacrifice image quality? I've been using phpthumb (http://phpthumb.sourceforge.net/) but when compared to an image resized in photoshop it's products are not as good (yeah I upped the image quality and tried out some filters - no luck). Tutorials or scripts online preferred are preferred, but if you know of a way to change the settings on phpthumb to maintain the...
0
1055
by: RajaSS | last post by:
Hi, I have a windowed mode graphics application which uses OpenGL and Directx3D. Though the quality of the graphics and text I have is very good intially, once I lock and unloack my system it goes for a toss. The Quality degrades. I can get back a better quality if I have a bigger window while locking and unlocking. But if I resize the quality degraded window to a bigger window, the quality is still worse. Any pointers to what all...
0
10332
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
10321
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,...
0
10077
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
9152
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...
1
7620
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
6853
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();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4300
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
3820
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.