| Bassem Srouji 2004-09-12, 3:57 pm |
| Xref: TK2MSFTNGP08.phx.gbl microsoft.public.vstudio.general:24259 microsoft.public.vstudio.development:23275
Hi,
I did a program that read my jpeg file from my canon a80 camera and get the
date of picture taken that is stored into the jpeg file as a propertyid
once this date and time is extracted, I give the user 2 choise either rename
the jpeg file to DateTimeOfpitctureTaken.jpg or to keep the same file name
but draw into the jpeg at the bottom right of the image the date time of the
image
everything work perfectly. My question is simple.
My original jpeg file from the camera (not modified file) is about 2 MBytes
when I open the file and draw the date time and then do save again which
include the date time in it
my file size is about 600 KBytes, I compared the 2 images, the resolution is
the same, and bit/color is the same and all the tag id are still there
however I don't understand why my new saved picture is taking only 600
KBytes. Am i loosing some date in the process ? the resulting image looks
the same as the original but somewhere something is not their anymore right
?
this my code : it;s quit simple and streight forward
DateTime myOriginDateTime = new DateTime();
myOriginDateTime = inf.DTOrig; // Here I get the original date/time of
picture taken
Image my_image = inf.Image; // This is my original picture
item.m_dtCreationTime = myOriginDateTime; // some internal logic
item.m_bDataCollected = true; // some internal logic
Graphics GraphText = Graphics.FromImage(my_image);
GraphText.CompositingQuality = CompositingQuality.HighQuality;
GraphText.SmoothingMode = SmoothingMode .HighQuality;
GraphText.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
GraphText.InterpolationMode = InterpolationMode.HighQualityBicubic;
GraphText.PixelOffsetMode = PixelOffsetMode.HighQuality;
Brush br=new SolidBrush(m_FontColor);
Font drawFont = m_FontOption; // this is the result of a font dialog that
the user can change
String mDateTime = item.m_dtCreationTime.DayOfW +","+
mMonthOfYear[item.m_dtCreationTime.Month]+"-"+item.m_dtCreationTime.Day+"-"+
item.m_dtCreationTime.Year+" "+item.m_dtCreationTime.Hour+":"+
item.m_dtCreationTime.Minute+":"+item.m_dtCreationTime.Second;
RectangleF nRectange = new RectangleF(0, 0,my_image.Width,my_image.Height);
StringFormat drawFormat = new StringFormat();
drawFormat.Alignment = StringAlignment.Far;
drawFormat.LineAlignment = StringAlignment.Far;
GraphText.DrawString(mDateTime, drawFont, br, nRectange, drawFormat);
string szFileName = item.m_sFileName+"T";
string sNewFileName;
sNewFileName = Path.GetDirectoryName(item.m_sFileName);
sNewFileName += "\\" + "FRZ_" + Path.GetFileName(item.m_sFileName);
try
{
my_image.Save(sNewFileName);
}
catch
{
sMessage = "Error can not save to file "+ sNewFileName +"\n";
AddMessage(sMessage);
nError++;
}
any support ?
Thanks
Bassem
|