Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, December 2, 2009 2:33:05 AM(UTC)
joepacelli

Groups: Registered
Posts: 2


I wrote a utility which goes through our directories where our users store there images and I look for any .ann file's which indicate an annotation.
I then save the file with the annotation as part of the file. The problem is the image grows substanially. For example a 100kb jpg with a 2kb .ann file became a 25Mb jpg. Here is my code, what is wrong;
private void BurnAnnotaion(string strSourceFileName, string strAnnotationFileName,
string strTargetFileName, string strExtension)
{
const int firstPage = 1;

try
{

RasterImageFormat imgFormat = GetOutputFormat(strExtension);

// intitialize a new RasterCodecs object
//RasterCodecs.CodecsPath = CodecPath;
RasterCodecs codecs = new RasterCodecs();

// load the main image into our viewer
rasterImageViewer.Image = codecs.Load(strSourceFileName);

if (rasterImageViewer.Image != null)
{
// Load annotations into each image page
for (int page = 1; page <= rasterImageViewer.Image.PageCount; page++)
{
rasterImageViewer.Image.Page = page;

ColorResolutionCommand ColorRes = new ColorResolutionCommand();
ColorRes.BitsPerPixel = 24;
ColorRes.Run(rasterImageViewer.Image);

// Create an instance of the Annotation IO engine
AnnCodecs annCodecs = new AnnCodecs();

annAutomation.Container.UnitConverter.DpiX = 50;
annAutomation.Container.UnitConverter.DpiY = 50;

annCodecs.Load(strAnnotationFileName, annAutomation.Container, page);

annAutomation.Realize();

// Save the modified file out with annotation
if (page == firstPage)
{
codecs.Save(rasterImageViewer.Image, strTargetFileName, imgFormat,
rasterImageViewer.Image.BitsPerPixel < 4 ? 4 : rasterImageViewer.Image.BitsPerPixel, page, page, page, CodecsSavePageMode.Overwrite);
}
else
{
codecs.Save(rasterImageViewer.Image, strTargetFileName, imgFormat,
rasterImageViewer.Image.BitsPerPixel < 4 ? 4 : rasterImageViewer.Image.BitsPerPixel, page, page, page, CodecsSavePageMode.Append);
}

annAutomation.Container.Objects.Clear();
}
}
}
catch (Exception ex)
{
objLog.Error("BurnAnnotation Error:", ex);
}
}

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Thursday, December 3, 2009 5:28:57 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

I'm not sure what is the value returned by GetOutputFormat, but it seems that you are saving the file as uncompressed JPEG. Try to use the RasterImage.OriginalFormat Property to save the file. For example try to save the file as follows:
Save(rasterImageViewer.Image, strTargetFileName, rasterImageViewer.Image.OriginalFormat , ....

 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.083 seconds.