High(er) speed thumbnail generation

D

dean.greg

Im looking for a way to generate thumbnails from an image as fast as
possible. Currently I'm using GDI+ however going from 1024x768 to
100x100 takes too long. I'd imagine the whole process can be
optimized by using hardware acceleration (ie DirectX), however I am
not all that familar with the DirectX API. What I'm looking for is
some direction, or even some sample/psuedo code, that might point me
in the right direction.

If not DirectX can anyone recommend a more efficient method?

In short I want to replace the following code, with something that is
faster:

using (Bitmap newImg = new Bitmap(width, height,
PixelFormat.Format16bppRgb555))
{
newImg.SetResolution(72, 72);

using (Graphics g = Graphics.FromImage(newImg))
{
g.Clear(Color.White);
g.InterpolationMode = InterpolationMode.HighQualityBilinear;
g.SmoothingMode = SmoothingMode.HighSpeed;
g.PixelOffsetMode = PixelOffsetMode.HighSpeed;
g.CompositingQuality = CompositingQuality.HighSpeed;

g.DrawImage(img, new Rectangle(0, 0, width, height), new
Rectangle(0, 0, img.Width, img.Height), GraphicsUnit.Pixel);
}

ImageCodecInfo[] info = ImageCodecInfo.GetImageEncoders();
EncoderParameters parameters = new EncoderParameters(1);
parameters.Param[0] = new
EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 85L);
newImg.Save(thumbnailPath, info[1], parameters);
}
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Im looking for a way to generate thumbnails from an image as fast as
possible. Currently I'm using GDI+ however going from 1024x768 to
100x100 takes too long. I'd imagine the whole process can be
optimized by using hardware acceleration (ie DirectX), however I am
not all that familar with the DirectX API. What I'm looking for is
some direction, or even some sample/psuedo code, that might point me
in the right direction.

If not DirectX can anyone recommend a more efficient method?

In short I want to replace the following code, with something that is
faster:

using (Bitmap newImg = new Bitmap(width, height,
PixelFormat.Format16bppRgb555))
{
newImg.SetResolution(72, 72);

using (Graphics g = Graphics.FromImage(newImg))
{
g.Clear(Color.White);
g.InterpolationMode = InterpolationMode.HighQualityBilinear;
g.SmoothingMode = SmoothingMode.HighSpeed;
g.PixelOffsetMode = PixelOffsetMode.HighSpeed;
g.CompositingQuality = CompositingQuality.HighSpeed;

g.DrawImage(img, new Rectangle(0, 0, width, height), new
Rectangle(0, 0, img.Width, img.Height), GraphicsUnit.Pixel);
}

ImageCodecInfo[] info = ImageCodecInfo.GetImageEncoders();
EncoderParameters parameters = new EncoderParameters(1);
parameters.Param[0] = new
EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 85L);
newImg.Save(thumbnailPath, info[1], parameters);
}

Have you tried the GetThumbnailImage method?
 
D

dean.greg

Im looking for a way to generate thumbnails from an image as fast as
possible. Currently I'm using GDI+ however going from 1024x768 to
100x100 takes too long. I'd imagine the whole process can be
optimized by using hardware acceleration (ie DirectX), however I am
not all that familar with the DirectX API. What I'm looking for is
some direction, or even some sample/psuedo code, that might point me
in the right direction.
If not DirectX can anyone recommend a more efficient method?
In short I want to replace the following code, with something that is
faster:
using (Bitmap newImg = new Bitmap(width, height,
PixelFormat.Format16bppRgb555))
{
newImg.SetResolution(72, 72);
using (Graphics g = Graphics.FromImage(newImg))
{
g.Clear(Color.White);
g.InterpolationMode = InterpolationMode.HighQualityBilinear;
g.SmoothingMode = SmoothingMode.HighSpeed;
g.PixelOffsetMode = PixelOffsetMode.HighSpeed;
g.CompositingQuality = CompositingQuality.HighSpeed;
g.DrawImage(img, new Rectangle(0, 0, width, height), new
Rectangle(0, 0, img.Width, img.Height), GraphicsUnit.Pixel);
}
ImageCodecInfo[] info = ImageCodecInfo.GetImageEncoders();
EncoderParameters parameters = new EncoderParameters(1);
parameters.Param[0] = new
EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 85L);
newImg.Save(thumbnailPath, info[1], parameters);
}

Have you tried the GetThumbnailImage method?

--
Göran Andersson
_____http://www.guffa.com- Hide quoted text -

- Show quoted text -

Yeah its just as slow and produces terrible qualtiy images when
resampling from 1024x768 down to 100x100
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Im looking for a way to generate thumbnails from an image as fast as
possible. Currently I'm using GDI+ however going from 1024x768 to
100x100 takes too long. I'd imagine the whole process can be
optimized by using hardware acceleration (ie DirectX), however I am
not all that familar with the DirectX API. What I'm looking for is
some direction, or even some sample/psuedo code, that might point me
in the right direction.
If not DirectX can anyone recommend a more efficient method?
In short I want to replace the following code, with something that is
faster:
using (Bitmap newImg = new Bitmap(width, height,
PixelFormat.Format16bppRgb555))
{
newImg.SetResolution(72, 72);
using (Graphics g = Graphics.FromImage(newImg))
{
g.Clear(Color.White);
g.InterpolationMode = InterpolationMode.HighQualityBilinear;
g.SmoothingMode = SmoothingMode.HighSpeed;
g.PixelOffsetMode = PixelOffsetMode.HighSpeed;
g.CompositingQuality = CompositingQuality.HighSpeed;
g.DrawImage(img, new Rectangle(0, 0, width, height), new
Rectangle(0, 0, img.Width, img.Height), GraphicsUnit.Pixel);
}
ImageCodecInfo[] info = ImageCodecInfo.GetImageEncoders();
EncoderParameters parameters = new EncoderParameters(1);
parameters.Param[0] = new
EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 85L);
newImg.Save(thumbnailPath, info[1], parameters);
}
Have you tried the GetThumbnailImage method?

--
Göran Andersson
_____http://www.guffa.com- Hide quoted text -

- Show quoted text -

Yeah its just as slow and produces terrible qualtiy images when
resampling from 1024x768 down to 100x100

The speed depends on the format of the original image. If the original
file contains a thumbnail, the GetThumbnailImage method uses that
instead of the entire image to produce the thumbnail that you requested.

As for the quality, you have to choose. Either speed or quality.
 
S

susiedba

I would just use VB dotnet

any break things into multiple threads

C# does not support multi-threading, does it??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top