public void Render(
IntPtr hdc,
int x,
int y,
int cx,
int cy,
int xSrc,
int ySrc,
int cxSrc,
int cySrc,
IntPtr prcWBounds)
{
using (Graphics gr = Graphics.FromHdc(hdc))
{
// Sometimes width or height is negative and we are expected to draw backwards (which DrawImage doesn't seem to do)
if (cySrc < 0)
{
cySrc = Math.Abs(cySrc);
ySrc -= cySrc;
}
if (cxSrc < 0)
{
cxSrc = Math.Abs(cxSrc);
xSrc -= cxSrc;
}
gr.DrawImage(m_img, new Rectangle(x, y, cx, cy),
new Rectangle(
new HiMetric(xSrc).GetPixels(dpiX),
new HiMetric(ySrc).GetPixels(dpiY),
new HiMetric(cxSrc).GetPixels(dpiX),
new HiMetric(cySrc).GetPixels(dpiY)), GraphicsUnit.Pixel);
}
}