TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Andy
NA
1
17.6k
Bitmap.RotateFlip resizing image
Jan 29 2011 8:39 PM
I'm iterating over images in a folder and rotating them using the RotateFlip method of the Bitmap class. The images start out at around 6MB before rotation, but end up 1.32MB after. Here's a snipet of the code I'm using:
private
void
ProcessFile(FileInfo fi)
{
Bitmap bmp =
new
Bitmap(fi.FullName);
EXIFextractor exif =
new
EXIFextractor(
ref
bmp,
"\n"
);
if
(exif[
"Orientation"
] !=
null
)
{
string
orientation = exif[
"Orientation"
].ToString();
RotateFlipType rotateFlipType = OrientationToFlipType(orientation);
if
(rotateFlipType != RotateFlipType.RotateNoneFlipNone)
{
//rotate the image
bmp.RotateFlip(rotateFlipType);
if
(chkUpdateOrientationProperty.Checked)
{
try
{
//reset the orientation flag
exif.SetOrientationTag(1);
}
catch
{ }
}
//save the image
string
newFileName = (chkRotateOriginals.Checked) ? fi.FullName : SaveAsFileName(fi);
bmp.Save(newFileName, ImageFormat.Jpeg);
}
}
else
{
}
bmp.Dispose();
}
If I comment out the line
bmp.RotateFlip( rotateFlipType );
the image size is not affected, so I've narrowed down the problem to that one line of code. I've checked the properties of the original and rotated images and the dimensions aren't any smaller (just rotated), dpi, bit depth, etc are all the same. So I'm at a loss as to why the rotated image's file size is so much smaller. Does anyone have any idea what would cause this and if there is a way to prevent this from happening? Thanks in advance.
Reply
Answers (
0
)
The process cannot access the file because it is being used by another process.
Need help on a calculator I'm making.