Fastest way to resize bitmap with Picturebox

G

Guest

Hi,

I've got a Picturebox, into which I am putting a frame bitmap from a video
camera. The camera bitmap is larger than the picturebox, which has SizeMode
set to "Zoom" which causes the bitmap to be resized and correctly displayed.

My question is whether letting the Picturebox do the bitmap resizing is the
most efficient mechanism, or whether it would be preferable to perfrom the
resizing myself before passing the modified image to the Picturebox?

Cheers,

Jon.
 
N

Nicholas Paldino [.NET/C# MVP]

Jon,

I imagine it uses GDI+ (through the Graphics object) to perform the
scaling. If you think you can do better than that (I understand that GDI+
has some performance issues, so I don't blame you), then by all means go for
it. You can always perform some tests and see for yourself.
 
P

Peter Duniho

[...]
My question is whether letting the Picturebox do the bitmap resizing is
the
most efficient mechanism, or whether it would be preferable to perfrom
the
resizing myself before passing the modified image to the Picturebox?

Depends on what you are asking and how often the given image will be
redrawn.

You aren't likely to be able to scale the bitmap once faster than .NET.
However, if you want to be able to efficiently handle resizing or
redrawing the same image repeatedly (for example, changing the size of the
PictureBox, or dealing with other windows getting moved on top of your
PictureBox, etc.) then caching a resized version of the Bitmap and using
that for the PictureBox may be better.

Of course, that assumes that PictureBox doesn't make it's own cached
version of the original bitmap. I haven't tested that, and maybe it does.

I certainly wouldn't bother doing any caching unless I actually ran into
some sort of UI performance problem.

Pete
 

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