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);
}
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);
}