Hi all,
I use MFC to create a dialog base application. I load a bitmap into picture box in dialog. When I change dpi of windows so bitmap don't resize.
So fixing this problem. I use code as bellow:
double scale = afxGlobalData.GetRibbonImageScale();
CImage img1;
img1.LoadFromResource(AfxGetInstanceHandle(), IDB_BITMAP1);
int dimx = img1.GetWidth()*scale;
int dimy = img1.GetHeight()*scale;
CDC *pDC = GetDC();
CDC mDC;
mDC.CreateCompatibleDC(pDC);
CBitmap scale_bitmap;
scale_bitmap.CreateCompatibleBitmap(pDC, dimx, dimy);
CBitmap *pob = mDC.SelectObject(&scale_bitmap);
img1.StretchBlt(mDC.m_hDC, 0, 0, dimx, dimy, 0, 0, img1.GetWidth(), img1.GetHeight(), SRCCOPY);
mDC.SelectObject(pob);
Bitmap_.SetBitmap((HBITMAP)scale_bitmap.Detach());
ReleaseDC(pDC);
My bitmap is resized but size of bitmap is incorrect.
examble : dpi = 125% size of bitmap is incorect.
can members help for me ?
Thanks