locked
System Drawing Rectangle - How does this happen? RRS feed

  • Question

  • User711556406 posted

    I am using the following code :

    using (var thumbnailBitmap = new Bitmap(newWidth, newHeight, PixelFormat.Format32bppArgb))
                    using (var thumbnailGraph = Graphics.FromImage(thumbnailBitmap))
                    {

    thumbnailGraph.DrawImage(image,
                            new Rectangle(destX, destY, destWidth, destHeight),
                            new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight),
                            GraphicsUnit.Pixel);

    }

    }

    And I get a 400X300 rectangle. the actual parameters are :

    thumbnailGraph.DrawImage(image,
                            new Rectangle(11, 0, 377, 300),
                            new Rectangle(0, 0, 800, 635),
                            GraphicsUnit.Pixel);

    if the point is 11,0 and the width is 377, how do I get an image of 400X300? I am so curious about this...

    If anyone knows, or can point me at the right direction, I will be grateful.

    Monday, September 12, 2011 6:31 AM

Answers

All replies