本文整理汇总了C++中ImageAttributes::SetWrapMode方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageAttributes::SetWrapMode方法的具体用法?C++ ImageAttributes::SetWrapMode怎么用?C++ ImageAttributes::SetWrapMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageAttributes
的用法示例。
在下文中一共展示了ImageAttributes::SetWrapMode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderPage
bool ImagesEngine::RenderPage(HDC hDC, RectI screenRect, int pageNo, float zoom, int rotation, RectD *pageRect, RenderTarget target, AbortCookie **cookie_out)
{
Bitmap *bmp = LoadImage(pageNo);
if (!bmp)
return false;
RectD pageRc = pageRect ? *pageRect : PageMediabox(pageNo);
RectI screen = Transform(pageRc, pageNo, zoom, rotation).Round();
Graphics g(hDC);
g.SetCompositingQuality(CompositingQualityHighQuality);
g.SetSmoothingMode(SmoothingModeAntiAlias);
g.SetPageUnit(UnitPixel);
Color white(0xFF, 0xFF, 0xFF);
Rect screenR(screenRect.x, screenRect.y, screenRect.dx, screenRect.dy);
g.SetClip(screenR);
g.FillRectangle(&SolidBrush(white), screenR);
Matrix m;
GetTransform(m, pageNo, zoom, rotation);
m.Translate((REAL)(screenRect.x - screen.x), (REAL)(screenRect.y - screen.y), MatrixOrderAppend);
g.SetTransform(&m);
RectI pageRcI = PageMediabox(pageNo).Round();
ImageAttributes imgAttrs;
imgAttrs.SetWrapMode(WrapModeTileFlipXY);
Status ok = g.DrawImage(bmp, Rect(0, 0, pageRcI.dx, pageRcI.dy), 0, 0, pageRcI.dx, pageRcI.dy, UnitPixel, &imgAttrs);
return ok == Ok;
}
示例2: OnPaint
void CEnteringRoomDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: 在此处添加消息处理程序代码
// 不为绘图消息调用 CDialog::OnPaint()
//中间
CRect rcClient ;
GetClientRect( &rcClient ) ;
Graphics graphics(dc);
ImageAttributes imgAtt;
imgAtt.SetWrapMode(WrapModeTileFlipXY);//GDI+在位伸图片时会自动加上渐变效果。但此处不需要,所以得加上此属性
//去掉边框
//左上、上中、右上
graphics.DrawImage(m_imgTopLeft,Rect(0, 0, m_imgTopLeft->GetWidth(), m_imgTopLeft->GetHeight()),
0, 0, m_imgTopLeft->GetWidth(), m_imgTopLeft->GetHeight(),UnitPixel,&imgAtt);//没拉抻
graphics.DrawImage(m_imgTopMid, Rect(m_imgTopLeft->GetWidth(), 0, rcClient.Width() - m_imgTopLeft->GetWidth() * 2, m_imgTopMid->GetHeight()),
0, 0, rcClient.Width() - m_imgTopLeft->GetWidth() * 2, m_imgTopMid->GetHeight(), UnitPixel,&imgAtt);
graphics.DrawImage(m_imgTopRight, Rect(rcClient.right - m_imgTopRight->GetWidth() - 1, 0, m_imgTopRight->GetWidth(), m_imgTopRight->GetHeight()),
0, 0, m_imgTopRight->GetWidth(), m_imgTopRight->GetHeight(), UnitPixel,&imgAtt);
//左中、右中
graphics.DrawImage(m_imgMidLeft, Rect(0, m_imgTopMid->GetHeight(), m_imgMidLeft->GetWidth(), rcClient.Height() - m_imgTopMid->GetHeight() * 2),
0, 0, m_imgMidLeft->GetWidth(), rcClient.Height() - m_imgTopMid->GetHeight() * 2, UnitPixel,&imgAtt);
graphics.DrawImage(m_imgMidRight, Rect(rcClient.right - m_imgMidRight->GetWidth() - 1, m_imgTopMid->GetHeight(), m_imgMidRight->GetWidth(), rcClient.Height() - m_imgTopMid->GetHeight() * 2),
0, 0, m_imgMidRight->GetWidth(), rcClient.Height() - m_imgTopMid->GetHeight() * 2,UnitPixel,&imgAtt);
//左下、下中、右下
graphics.DrawImage(m_imgBottomLeft,Rect(0, rcClient.bottom - m_imgBottomLeft->GetHeight() - 1, m_imgBottomLeft->GetWidth(), m_imgBottomLeft->GetHeight()),
0, 0, m_imgBottomLeft->GetWidth(), m_imgBottomLeft->GetHeight(), UnitPixel,&imgAtt);
graphics.DrawImage(m_imgBottomMid, Rect(m_imgMidLeft->GetWidth(), rcClient.bottom - m_imgBottomMid->GetHeight() - 1, rcClient.Width() - m_imgMidLeft->GetWidth() * 2, m_imgBottomMid->GetHeight()),
0, 0,rcClient.Width() - m_imgMidLeft->GetWidth() * 2, m_imgBottomMid->GetHeight(), UnitPixel,&imgAtt);
graphics.DrawImage(m_imgBottomRight,Rect(rcClient.right - m_imgBottomRight->GetWidth() - 1, rcClient.bottom - m_imgBottomRight->GetHeight() - 1, m_imgBottomRight->GetWidth(), m_imgBottomRight->GetHeight()),
0, 0, m_imgBottomRight->GetWidth(), m_imgBottomRight->GetHeight(), UnitPixel,&imgAtt);
//中间
graphics.DrawImage( m_pPic->GetCurImage() ,Rect(m_imgMidLeft->GetWidth(), m_imgTopMid->GetHeight(), rcClient.Width() - m_imgMidLeft->GetWidth() * 2 - 1 , rcClient.Height() - m_imgTopMid->GetHeight() * 2 - 1),
0, 0, rcClient.Width() - m_imgMidLeft->GetWidth() * 2 - 1 , rcClient.Height() - m_imgTopMid->GetHeight() * 2 - 1,UnitPixel,&imgAtt) ;
/*graphics.DrawImage( m_pPic->GetCurImage() ,Rect(0, 0, rcClient.Width(), rcClient.Height()),
0, 0, rcClient.Width(), rcClient.Height(),UnitPixel,&imgAtt) ;*/
}
示例3: ResizeBitmap
//输入原图片指针的指针,及新图片的新宽高
//示例:ResizeBitmap(&m_pOrignImageS,width,height);
BOOL CExampleDemoDlg::ResizeBitmap(Bitmap **ppImg, int m_NewWidth, int m_NewHeight)
{
if (ppImg == NULL || *ppImg == NULL)
{
return FALSE;
}
Bitmap *m_NewImage = new Bitmap(m_NewWidth, m_NewHeight);
ColorMatrix colorMatrix = {
1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 1.0f };
ImageAttributes imageAtt;
imageAtt.SetColorMatrix(&colorMatrix);
imageAtt.SetWrapMode(WrapModeTileFlipXY);
Graphics gs(m_NewImage);
gs.SetSmoothingMode(SmoothingModeAntiAlias);
gs.SetInterpolationMode(InterpolationModeHighQuality);
gs.DrawImage(
(*ppImg),
Rect(0, 0, m_NewWidth, m_NewHeight), // Destination rectangle
0, // Source rectangle temp->x
0, // Source rectangle temp->y
(*ppImg)->GetWidth(), // Source rectangle width
(*ppImg)->GetHeight(), // Source rectangle height
UnitPixel,
&imageAtt);
//交换指针
delete (*ppImg);
(*ppImg) = m_NewImage;
return TRUE;
}
示例4: InitImageAttributes
// ***************************************************************
// InitImageAttributes()
// ***************************************************************
void TilesDrawer::InitImageAttributes(TileManager* manager, ImageAttributes& attr)
{
attr.SetWrapMode(WrapModeTileFlipXY);
if (!manager->IsBackground())
{
Gdiplus::ColorMatrix m = ImageHelper::CreateMatrix(manager->contrast,
manager->brightness,
manager->saturation,
manager->hue,
0.0f, RGB(255, 255, 255), false, manager->get_Alpha() / 255.0f);
attr.SetColorMatrix(&m);
if (manager->useTransparentColor)
{
Gdiplus::Color color(GetRValue(manager->transparentColor),
GetGValue(manager->transparentColor),
GetBValue(manager->transparentColor));
attr.SetColorKey(color, color);
}
}
}
示例5: Draw
/*
** Draws the meter on the double buffer
**
*/
bool MeterImage::Draw(Gfx::Canvas& canvas)
{
if (!Meter::Draw(canvas)) return false;
if (m_Image.IsLoaded())
{
// Copy the image over the doublebuffer
Bitmap* drawBitmap = m_Image.GetImage();
int imageW = drawBitmap->GetWidth();
int imageH = drawBitmap->GetHeight();
if (imageW == 0 || imageH == 0 || m_W == 0 || m_H == 0) return true;
int x = GetX();
int y = GetY();
int drawW = m_W;
int drawH = m_H;
if (drawW == imageW && drawH == imageH &&
m_ScaleMargins.left == 0 && m_ScaleMargins.top == 0 && m_ScaleMargins.right == 0 && m_ScaleMargins.bottom == 0)
{
canvas.DrawBitmap(drawBitmap, Rect(x, y, drawW, drawH), Rect(0, 0, imageW, imageH));
}
else if (m_DrawMode == DRAWMODE_TILE)
{
Gdiplus::Graphics& graphics = canvas.BeginGdiplusContext();
ImageAttributes imgAttr;
imgAttr.SetWrapMode(WrapModeTile);
Rect r(x, y, drawW, drawH);
graphics.DrawImage(drawBitmap, r, 0, 0, drawW, drawH, UnitPixel, &imgAttr);
canvas.EndGdiplusContext();
}
else if (m_DrawMode == DRAWMODE_KEEPRATIO || m_DrawMode == DRAWMODE_KEEPRATIOANDCROP)
{
int cropX = 0;
int cropY = 0;
int cropW = imageW;
int cropH = imageH;
if (m_WDefined && m_HDefined)
{
REAL imageRatio = imageW / (REAL)imageH;
REAL meterRatio = m_W / (REAL)m_H;
if (imageRatio != meterRatio)
{
if (m_DrawMode == DRAWMODE_KEEPRATIO)
{
if (imageRatio > meterRatio)
{
drawH = m_W * imageH / imageW;
y += (m_H - drawH) / 2;
}
else
{
drawW = m_H * imageW / imageH;
x += (m_W - drawW) / 2;
}
}
else
{
if (imageRatio > meterRatio)
{
cropW = (int)(imageH * meterRatio);
cropX = (imageW - cropW) / 2;
}
else
{
cropH = (int)(imageW / meterRatio);
cropY = (imageH - cropH) / 2;
}
}
}
}
Rect r(x, y, drawW, drawH);
canvas.DrawBitmap(drawBitmap, r, Rect(cropX, cropY, cropW, cropH));
}
else
{
const RECT& m = m_ScaleMargins;
if (m.top > 0)
{
if (m.left > 0)
{
// Top-Left
Rect r(x, y, m.left, m.top);
canvas.DrawBitmap(drawBitmap, r, Rect(0, 0, m.left, m.top));
}
//.........这里部分代码省略.........
示例6: DrawSudoku
void DrawSudoku(Image * pImage, Graphics * pGraphics, RectF& rcDraw
, UINT nLeft, UINT nTop, UINT nRight, UINT nBottom )
{
if (pGraphics == NULL) return;
if (pImage == NULL) return;
UINT cx = pImage->GetWidth();
UINT cy = pImage->GetHeight();
if ( nLeft + nRight > cx )
{
nLeft = nRight = 0;
}
if ( nTop + nBottom > cy )
{
nTop = nBottom = 0;
}
//左上角
if (nLeft > 0 && nTop > 0 && nTop < cy && nLeft < cx)
{
pGraphics->DrawImage( pImage
, rcDraw.GetLeft(), rcDraw.GetTop()
, 0.0f, 0.0f, (float)nLeft, (float)nTop
, Gdiplus:: UnitPixel );
}
//右上角
if (nRight > 0 && nTop > 0 && nTop < cy && nRight < cx)
{
pGraphics->DrawImage( pImage
, rcDraw.GetRight() - (float)nRight, rcDraw.GetTop()
, (float)cx - (float)nRight, 0.0f, (float)nRight, (float)nTop
, Gdiplus:: UnitPixel );
}
//右下角
if (nRight > 0 && nBottom > 0 && nBottom < cy && nRight < cx)
{
pGraphics->DrawImage( pImage
, rcDraw.GetRight() - (float)nRight, rcDraw.GetBottom() - (float)nBottom
, (float)cx - (float)nRight, (float)cy - (float)nBottom, (float)nRight, (float)nBottom
, Gdiplus:: UnitPixel );
}
//左下角
if (nLeft > 0 && nBottom > 0 && nBottom < cy && nLeft < cx)
{
pGraphics->DrawImage( pImage
, rcDraw.GetLeft(), rcDraw.GetBottom() - (float)nBottom
, 0.0f, (float)cy - (float)nBottom , (float)nLeft, (float)nBottom
, Gdiplus:: UnitPixel );
}
ImageAttributes ImgAtt;
ImgAtt.SetWrapMode(WrapModeTileFlipXY);
//左边
if (nLeft > 0 && cy - nTop - nBottom > 0)
{
RectF rc(rcDraw.GetLeft(), rcDraw.GetTop() + (float)nTop
, (float)nLeft, rcDraw.Height - (float)nTop - (float)nBottom );
pGraphics->DrawImage( pImage
, rc
, 0.0f, (float)nTop, (float)nLeft, (float)cy - (float)nTop - (float)nBottom
, UnitPixel, &ImgAtt );
}
//上边
if (nTop > 0 && cx - nLeft - nRight > 0)
{
RectF rc(rcDraw.GetLeft() + (float)nLeft, rcDraw.GetTop()
, rcDraw.Width - (float)nLeft - (float)nRight, (float)nTop );
pGraphics->DrawImage( pImage
, rc
, (float)nLeft, 0.0f, (float)cx - (float)nLeft - (float)nRight, (float)nTop
, UnitPixel, &ImgAtt );
}
//右边
if (nRight > 0 && cy - nTop - nBottom > 0)
{
RectF rc(rcDraw.GetRight() - (float)nRight, rcDraw.GetTop() + (float)nTop
, (float)nRight, rcDraw.Height - (float)nTop - (float)nBottom );
pGraphics->DrawImage( pImage
, rc
, (float)cx - (float)nRight, (float)nTop, (float)nRight, (float)cy - (float)nTop - (float)nBottom
, UnitPixel, &ImgAtt );
}
//下边
if (nBottom > 0 && cx - nLeft - nRight > 0)
{
RectF rc(rcDraw.GetLeft() + (float)nLeft, rcDraw.GetBottom() - (float)nBottom
, rcDraw.Width - (float)nLeft - (float)nRight, (float)nBottom );
pGraphics->DrawImage( pImage
, rc
, (float)nLeft, (float)cy - (float)nBottom, (float)cx - (float)nLeft - (float)nRight, (float)nBottom
, UnitPixel, &ImgAtt );
CString str;
str.Format("下边:%0.4f", rc.GetTop());
OutputDebugString(str);
}
//中间
{
//.........这里部分代码省略.........
示例7: WndProc
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc, hCompatibleDC;
HANDLE hOldBitmap, hBitmap;
BITMAP Bitmap;
RECT rect;
int i=0;
GetClientRect(hWnd, &rect);
int j, k;
TCHAR greeting[] = _T("Elaborat de studentul Ghelas Marc, TI-141.");
hBitmap = (HBITMAP)LoadImage(NULL, _T("E:\\example.BMP"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
//hLocalDC = CreateCompatibleDC(NULL);
switch (message)
{
case WM_PAINT:
{
GetClientRect(hWnd, &rect);
hdc = BeginPaint(hWnd, &ps);
HBRUSH hBrush;
Graphics graphics(hdc);
ImageAttributes IAttr;
RectF destination(45, 85, rect.right - 85, rect.bottom - 170);
Color colorRGB(0, 0, 0);
IAttr.SetWrapMode(WrapModeClamp, colorRGB);
Image image(L"E:\\example.BMP");
graphics.TranslateTransform(pos.x+45, pos.y+85);
graphics.RotateTransform(rotate.x);
graphics.TranslateTransform(-45.0f, -85.0f);
graphics.ScaleTransform(stretch.x, stretch.y);
graphics.DrawImage(&image, destination, 0, 0, 290, 450, UnitPixel, &IAttr);
//Graphics graphics(hdc);
//
//Pen pen(Color(255, 0, 0, 255));
//
//Matrix matrix;
//matrix.Translate(250.0f, 200.0f);
//matrix.RotateAt(rotate.x, PointF(250.0f, 200.0f), MatrixOrderAppend);
//
//graphics.SetTransform(&matrix);
//graphics.DrawRectangle(&pen, -40, -20, 80, 40);
//GetObject(hBitmap, sizeof(BITMAP), &Bitmap);
//hCompatibleDC = CreateCompatibleDC(hdc);
//hOldBitmap = SelectObject(hCompatibleDC, hBitmap);
//if (hCompatibleDC){
//
// StretchBlt(hdc, pos.x + 45, pos.y + 85, stretch.x - 85, stretch.y - 170,
// hCompatibleDC, 0, 0, Bitmap.bmWidth,
// Bitmap.bmHeight, SRCCOPY);
//
//
//}
//
//SelectObject(hCompatibleDC, hOldBitmap);
//DeleteObject(hBitmap);
//DeleteDC(hCompatibleDC);
EndPaint(hWnd, &ps);
break;
}
case WM_KEYDOWN:
switch (wParam)
{
case VK_RIGHT:
pos.x+=5;
InvalidateRect(hWnd, NULL, TRUE);
break;
case VK_LEFT:
pos.x-=5;
i++;
InvalidateRect(hWnd, NULL, TRUE);
break;
case VK_UP:
pos.y-=5;
InvalidateRect(hWnd, NULL, TRUE);
break;
case VK_DOWN:
pos.y+=5;
InvalidateRect(hWnd, NULL, TRUE);
break;
case 0x41:
stretch.x+=0.1f;
InvalidateRect(hWnd, NULL, TRUE);
break;
case 0x5A:
//.........这里部分代码省略.........
示例8: Draw
/*
** Draws the meter on the double buffer
**
*/
bool CMeterImage::Draw(Graphics& graphics)
{
if (!CMeter::Draw(graphics)) return false;
if (m_Image.IsLoaded())
{
// Copy the image over the doublebuffer
Bitmap* drawBitmap = m_Image.GetImage();
int imageW = drawBitmap->GetWidth();
int imageH = drawBitmap->GetHeight();
if (imageW == 0 || imageH == 0 || m_W == 0 || m_H == 0) return true;
int x = GetX();
int y = GetY();
int drawW = m_W;
int drawH = m_H;
if (drawW == imageW && drawH == imageH &&
m_ScaleMargins.left == 0 && m_ScaleMargins.top == 0 && m_ScaleMargins.right == 0 && m_ScaleMargins.bottom == 0)
{
Rect r(x, y, drawW, drawH);
graphics.DrawImage(drawBitmap, r, 0, 0, imageW, imageH, UnitPixel);
}
else if (m_Tile)
{
ImageAttributes imgAttr;
imgAttr.SetWrapMode(WrapModeTile);
Rect r(x, y, drawW, drawH);
graphics.DrawImage(drawBitmap, r, 0, 0, drawW, drawH, UnitPixel, &imgAttr);
}
else if (m_PreserveAspectRatio)
{
if (m_WDefined && m_HDefined)
{
REAL imageRatio = imageW / (REAL)imageH;
REAL meterRatio = m_W / (REAL)m_H;
if (imageRatio >= meterRatio)
{
drawW = m_W;
drawH = m_W * imageH / imageW;
}
else
{
drawW = m_H * imageW / imageH;
drawH = m_H;
}
// Centering
x += (m_W - drawW) / 2;
y += (m_H - drawH) / 2;
}
Rect r(x, y, drawW, drawH);
graphics.DrawImage(drawBitmap, r, 0, 0, imageW, imageH, UnitPixel);
}
else
{
const RECT m = m_ScaleMargins;
if (m.top > 0)
{
if (m.left > 0)
{
// Top-Left
Rect r(x, y, m.left, m.top);
graphics.DrawImage(drawBitmap, r, 0, 0, m.left, m.top, UnitPixel);
}
// Top
Rect r(x + m.left, y, drawW - m.left - m.right, m.top);
graphics.DrawImage(drawBitmap, r, m.left, 0, imageW - m.left - m.right, m.top, UnitPixel);
if (m.right > 0)
{
// Top-Right
Rect r(x + drawW - m.right, y, m.right, m.top);
graphics.DrawImage(drawBitmap, r, imageW - m.right, 0, m.right, m.top, UnitPixel);
}
}
if (m.left > 0)
{
// Left
Rect r(x, y + m.top, m.left, drawH - m.top - m.bottom);
graphics.DrawImage(drawBitmap, r, 0, m.top, m.left, imageH - m.top - m.bottom, UnitPixel);
}
// Center
Rect r(x + m.left, y + m.top, drawW - m.left - m.right, drawH - m.top - m.bottom);
graphics.DrawImage(drawBitmap, r, m.left, m.top, imageW - m.left - m.right, imageH - m.top - m.bottom, UnitPixel);
//.........这里部分代码省略.........
示例9: Draw
/*
** Draws the meter on the double buffer
**
*/
bool MeterImage::Draw(Gfx::Canvas& canvas)
{
if (!Meter::Draw(canvas)) return false;
if (m_Image.IsLoaded())
{
// Copy the image over the doublebuffer
Bitmap* drawBitmap = m_Image.GetImage();
int imageW = drawBitmap->GetWidth();
int imageH = drawBitmap->GetHeight();
if (imageW == 0 || imageH == 0 || m_W == 0 || m_H == 0) return true;
Gdiplus::Rect meterRect = GetMeterRectPadding();
int drawW = meterRect.Width;
int drawH = meterRect.Height;
bool hasMask = (m_Skin->GetUseD2D() && m_MaskImage.IsLoaded());
if (hasMask)
{
Bitmap* maskBitmap = m_MaskImage.GetImage();
imageW = maskBitmap->GetWidth();
imageH = maskBitmap->GetHeight();
int imageMW = drawBitmap->GetWidth();
int imageMH = drawBitmap->GetHeight();
int cropX = 0;
int cropY = 0;
int cropW = imageMW;
int cropH = imageMH;
REAL imageratio = imageMW / (REAL)imageMH;
REAL meterRatio = meterRect.Width / (REAL)meterRect.Height;
if (imageratio != meterRatio)
{
if (imageratio > meterRatio)
{
cropW = (int)(imageMH * meterRatio);
cropX = (imageMW - cropW) / 2;
}
else
{
cropH = (int)(imageMW / meterRatio);
cropY = (imageMH - cropH) / 2;
}
}
canvas.DrawMaskedBitmap(drawBitmap, maskBitmap, meterRect, Rect(0, 0, imageW, imageH), Gdiplus::Rect(cropX, cropY, cropW, cropH));
}
else if (drawW == imageW && drawH == imageH &&
m_ScaleMargins.left == 0 && m_ScaleMargins.top == 0 && m_ScaleMargins.right == 0 && m_ScaleMargins.bottom == 0)
{
canvas.DrawBitmap(drawBitmap, Rect(meterRect.X, meterRect.Y, drawW, drawH), Rect(0, 0, imageW, imageH));
}
else if (m_DrawMode == DRAWMODE_TILE)
{
Gdiplus::Graphics& graphics = canvas.BeginGdiplusContext();
ImageAttributes imgAttr;
imgAttr.SetWrapMode(WrapModeTile);
Rect r(meterRect.X, meterRect.Y, drawW, drawH);
graphics.DrawImage(drawBitmap, r, 0, 0, drawW, drawH, UnitPixel, &imgAttr);
canvas.EndGdiplusContext();
}
else if (m_DrawMode == DRAWMODE_KEEPRATIO || m_DrawMode == DRAWMODE_KEEPRATIOANDCROP)
{
int cropX = 0;
int cropY = 0;
int cropW = imageW;
int cropH = imageH;
if (m_WDefined && m_HDefined)
{
REAL imageRatio = imageW / (REAL)imageH;
REAL meterRatio = meterRect.Width / (REAL)meterRect.Height;
if (imageRatio != meterRatio)
{
if (m_DrawMode == DRAWMODE_KEEPRATIO)
{
if (imageRatio > meterRatio)
{
drawH = meterRect.Width * imageH / imageW;
meterRect.Y += (meterRect.Height - drawH) / 2;
}
else
{
drawW = meterRect.Height * imageW / imageH;
meterRect.X += (meterRect.Width - drawW) / 2;
//.........这里部分代码省略.........