LEADTOOLS Support
General
General Questions
Convert Tif to GIF and resize for display on web site.
This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Thursday, June 28, 2007 11:43:48 AM(UTC)
Groups: Registered
Posts: 9
Converting TIF image to GIF and resizing in the process. Tried using the .net libraries which do an excellent job but are too slow. I switched to Leadtools which is four times faster but the resolution is poor. The method takes a filename and a percentage to scale the image by.
Any way to maintain the quality in resizing but still maintain the speed?
Thanks
Leadtools code (C# - fast but low quality)
RasterCodecs codecs = new RasterCodecs();
IRasterImage raster = codecs.Load(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read));
raster.Page = 1;
SizeCommand sizer = new
SizeCommand(raster.Width * percent, raster.Height * percent, RasterSizeFlags.Normal);
sizer.Run(raster);
codecs.Save(raster, output, RasterImageFormat.Gif, raster.BitsPerPixel);
.Net code (C# - good quality but slow)
Image image = Image.FromFile(path);
image.SelectActiveFrame(FrameDimension.Page, 0);
Bitmap temp = new Bitmap(image, image.Width, image.Height);
image = temp.GetThumbnailImage(image.Width * percent, image.Height * percent, null, IntPtr.Zero);
image.Save(output, ImageFormat.Gif);
#2
Posted
:
Sunday, July 1, 2007 3:12:39 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Instead of separate calls to
the Load and the Resize methods try calling the Load method as such:
Load(
ByVal fileName As String, _
ByVal width As Integer, _
ByVal height As Integer, _
ByVal bitsPerPixel As Integer, _
ByVal flags As RasterSizeFlags, _
ByVal order As CodecsLoadByteOrder _;
And instead of loading with RasterSizeFlags.Normal try
loading with the RasterSizeFlags.Resample which should yield a higher quality
image.
#3
Posted
:
Thursday, July 5, 2007 4:53:44 AM(UTC)
Groups: Registered
Posts: 9
That worked on improving the graphics quality (much better). The downside is that it is much slower than before. I was really hoping that LeadTools API had something that would be much better than the .Net API. Is there any other calls that I could try to improve performance?
Thanks
#4
Posted
:
Sunday, July 8, 2007 4:03:55 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
I'm afraid that the
interpolation algorithm that improves quality takes time, whether you use LEADTOOLS,
or any other loading functions.
#5
Posted
:
Tuesday, November 27, 2007 11:28:47 AM(UTC)
Groups: Registered
Posts: 23
How would you get the same from a memorystream? I have a byte[] coming out of a DB and the sizecommand makes the images very pixelatted. Setting the codecs.Options.Load.FixedPalette seemed to work. It appears that if you just load a memorystream it doesn't load by default correctly.
RasterImage rasterImage = null;
using (MemoryStream memStreamOrig = new MemoryStream(img))
{
codecs.Options.Load.Format = RasterImageFormat.Png;
codecs.Options.Load.FixedPalette = true;
rasterImage = codecs.Load(memStreamOrig);
}
if (Request["Width"] != null && Request["Height"] != null)
{
Leadtools.ImageProcessing.SizeCommand sz = new Leadtools.ImageProcessing.SizeCommand();
sz.Height = Convert.ToInt32(Request["Height"].ToString());
sz.Width = Convert.ToInt32(Request["Width"].ToString());
sz.Flags = RasterSizeFlags.Bicubic;
sz.Run(rasterImage);
}
#6
Posted
:
Tuesday, November 27, 2007 11:26:18 PM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
The problem you're
facing might be similar to the posts above, but it also could be something
else. Please describe it in more detail and explain how to reproduce it here
without your database system. If the problem is not solved, try to create a
small test application that loads the data from a disk file dump and send it to
us along with a sample dump file in a ZIP or RAR file.
LEADTOOLS Support
General
General Questions
Convert Tif to GIF and resize for display on web site.
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.