Click here to Skip to main content
15,913,610 members
Home / Discussions / Graphics
   

Graphics

 
AnswerRe: How to Load .X File using DirectX9? Pin
MarkB7773-Jan-08 12:19
MarkB7773-Jan-08 12:19 
Generalcharacter segmentation Pin
zhaojun27-Dec-07 18:04
zhaojun27-Dec-07 18:04 
General.max to .x conversion Pin
DanB198324-Dec-07 3:37
DanB198324-Dec-07 3:37 
GeneralRe: .max to .x conversion Pin
Paul Conrad24-Dec-07 11:32
professionalPaul Conrad24-Dec-07 11:32 
GeneralRe: .max to .x conversion Pin
DanB198324-Dec-07 21:42
DanB198324-Dec-07 21:42 
GeneralRe: .max to .x conversion Pin
El Corazon24-Dec-07 11:53
El Corazon24-Dec-07 11:53 
GeneralRe: .max to .x conversion Pin
DanB198324-Dec-07 21:43
DanB198324-Dec-07 21:43 
QuestionZooming an image in a PictureBox Pin
gp005@hotpop.com29-Nov-07 6:46
gp005@hotpop.com29-Nov-07 6:46 
I'm working on an application that displays several large image files simultaneously, and operations on each of the files takes place simultaneously as well, for example when you zoom on one image it zooms all of the images, etc.

I'm using PictureBoxes to display the images.

To do the zooming I first used simply set the SizeMode to zoom and changed the size of the PicutreBox allowing its default methods to resize the image accordingly, as shown below:

public void ZoomImage(double ZoomFactor)<br />
{<br />
  zoomFactor = ZoomFactor;<br />
  pbImage.SizeMode = PictureBoxSizeMode.Zoom;<br />
  pbImage.Height = Convert.ToInt32(Math.Round(origHeight * ZoomFactor));<br />
  pbImage.Width = Convert.ToInt32(Math.Round(origWidth * ZoomFactor));<br />
  MaximumSize = new Size(pbImage.Width + 10, pbImage.Height + 30);<br />
  pbImage.Invalidate();<br />
}


The problem here is that the image quality was poor. I'm not sure what interpolation algorithm it uses to do the resizing, but its not a good one.

Then I tried using a methods that I got from The Code Project that uses Graphics.DrawImage, the core of this code is shown below:

<br />
// Create a new temporary bitmap to resize the original image<br />
// The size of this bitmap is the size of the picImage picturebox.<br />
Bitmap tempBitmap = new Bitmap(pbImage.Width, pbImage.Height, PixelFormat.Format32bppRgb);<br />
<br />
// Set the resolution of the bitmap to match the original resolution.<br />
tempBitmap.SetResolution(origionalImage.HorizontalResolution, origionalImage.VerticalResolution);<br />
<br />
// Create a Graphics object to further edit the temporary bitmap<br />
Graphics bmGraphics = Graphics.FromImage(tempBitmap);<br />
<br />
// Set the interpolationmode since we are resizing an image here<br />
bmGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;<br />
<br />
// Draw the original image on the temporary bitmap, resizing it using<br />
// the calculated values of targetWidth and targetHeight.<br />
bmGraphics.DrawImage(origionalImage, 0, 0, pbImage.Width, pbImage.Height);<br />
<br />
// Dispose of the bmGraphics object<br />
bmGraphics.Dispose();<br />
<br />
// Set the image of the picImage picturebox to the temporary bitmap<br />
pbImage.Image = tempBitmap;


The problem with this code is that it is extremely slow. When zooming to 300% it takes about a minute to resize 9 images on the screen. Using the other method it took about half a second.

Likewise, this methods actually creates new full sized images in memory, which ends up taking over a gig of memory then just to zoom in, which then starts paging and makes it even slower.

So, what are some other alternatives? I need to be able to zoom in using high quality interpolation, but PictureBox doesn't allow you to specify the interpolation method, but the method above, which does result in good picture quality, is orders of magnitude too slow and using too much memory.
AnswerRe: Zooming an image in a PictureBox Pin
Luc Pattyn29-Nov-07 8:02
sitebuilderLuc Pattyn29-Nov-07 8:02 
Questionhow to draw 3d window Pin
yoel good27-Nov-07 15:10
yoel good27-Nov-07 15:10 
AnswerRe: how to draw 3d window Pin
Stephen Hewitt27-Nov-07 16:57
Stephen Hewitt27-Nov-07 16:57 
GeneralRe: how to draw 3d window Pin
yoel good28-Nov-07 0:35
yoel good28-Nov-07 0:35 
GeneralRe: how to draw 3d window Pin
Mark Salsbery28-Nov-07 5:52
Mark Salsbery28-Nov-07 5:52 
AnswerRe: how to draw 3d window Pin
Maximilien28-Nov-07 3:37
Maximilien28-Nov-07 3:37 
AnswerRe: how to draw 3d window Pin
Pete O'Hanlon30-Nov-07 12:15
mvePete O'Hanlon30-Nov-07 12:15 
QuestionWPF: Rounded rects on only certain corners? Pin
chaiguy133725-Nov-07 13:22
chaiguy133725-Nov-07 13:22 
AnswerRe: WPF: Rounded rects on only certain corners? Pin
Jared Bienz [MSFT]29-Nov-07 5:02
Jared Bienz [MSFT]29-Nov-07 5:02 
GeneralRe: WPF: Rounded rects on only certain corners? Pin
Jared Bienz [MSFT]29-Nov-07 5:04
Jared Bienz [MSFT]29-Nov-07 5:04 
GeneralRe: WPF: Rounded rects on only certain corners? Pin
chaiguy133729-Nov-07 5:32
chaiguy133729-Nov-07 5:32 
QuestionAddind a Toolbar window into a MDI frame window [modified] Pin
Tien-Thong22-Nov-07 12:58
Tien-Thong22-Nov-07 12:58 
AnswerRe: Addind a Toolbar window into a MDI frame window Pin
senthillogin24-Nov-07 3:18
senthillogin24-Nov-07 3:18 
AnswerCross post. Please ignore this thread. Pin
Pete O'Hanlon25-Nov-07 9:24
mvePete O'Hanlon25-Nov-07 9:24 
GeneralRe: Addind a Toolbar window into a MDI frame window Pin
Paul Conrad24-Dec-07 11:33
professionalPaul Conrad24-Dec-07 11:33 
QuestionSave animation to movie Pin
levgiang21-Nov-07 22:05
levgiang21-Nov-07 22:05 
QuestionGraphic Interface Pin
Gaddonis16-Nov-07 1:57
professionalGaddonis16-Nov-07 1:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.