By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,241 Members | 733 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,241 IT Pros & Developers. It's quick & easy.

High(er) speed thumbnail generation

P: n/a
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.Qu ality, 85L);
newImg.Save(thumbnailPath, info[1], parameters);
}

Feb 12 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
de*******@gmail.com wrote:
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.Qu ality, 85L);
newImg.Save(thumbnailPath, info[1], parameters);
}
Have you tried the GetThumbnailImage method?

--
Göran Andersson
_____
http://www.guffa.com
Feb 13 '07 #2

P: n/a
On Feb 12, 4:35 pm, Göran Andersson <g...@guffa.comwrote:
dean.g...@gmail.com wrote:
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.Qu ality, 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

Feb 13 '07 #3

P: n/a
de*******@gmail.com wrote:
On Feb 12, 4:35 pm, Göran Andersson <g...@guffa.comwrote:
>dean.g...@gmail.com wrote:
>>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.

--
Göran Andersson
_____
http://www.guffa.com
Feb 13 '07 #4

P: n/a
I would just use VB dotnet

any break things into multiple threads

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


On Feb 12, 3:36 pm, dean.g...@gmail.com wrote:
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.Qu ality, 85L);
newImg.Save(thumbnailPath, info[1], parameters);

}- Hide quoted text -

- Show quoted text -

Feb 14 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.