Graphics.DrawImage函数其中一种的用法

来源:互联网 发布:大学生分期软件 编辑:程序博客网 时间:2024/05/16 18:10

原型

Status DrawImage(IN Image* image,
                     IN const RectF& destRect,
                     IN REAL srcx,
                     IN REAL srcy,
                     IN REAL srcwidth,
                     IN REAL srcheight,
                     IN Unit srcUnit,
                     IN const ImageAttributes* imageAttributes = NULL,
                     IN DrawImageAbort callback = NULL,
                     IN VOID* callbackData = NULL)


使用图片加载并绘制图片的一部分

Image* pImage=Gdiplus::Image::FromFile(L"c:\\small.png");
    RectF grect;
      //  grect.X=m_rcRect.left, grect.Y=m_rcRect.top; grect.Width = (int)(nStringWidth*g_dbDpi); grect.Height = (int)(iHeight*g_dbDpi);
    grect.X= 450;
    grect.Y=500;



    int iWidth = pImage->GetWidth()/4;
    int iHeight = pImage->GetHeight();


    grect.X= 600;
    grect.Y=500;
    grect.Width=200;
    graphics.DrawImage(pImage, grect, iWidth*0,0,100,iHeight, UnitPixel);

   此处可以看出,在RectF中确定的width是画出的图片的实际宽度,而参数srcwidth是加载图片的宽度,如果加载的图片宽度小于实际的宽度就会进行加长填充,反之则会压缩加载图片

0 0
原创粉丝点击