关于picture control控件

lhskw1 2018-11-09 05:23:20
你好 之前使用WIN32通过调用fstream
fstream binary_file("d:\\1.png", ios::binary | ios::in);

再调用网上找的base64_encode函数实现了外部图片文件编码成Base64

现在想通过MFC来实现 把picture control控件上面的图片编码成Base64

但是请问要用哪个函数才能把picture control控件上面的图片转成二进制呢?
...全文
33 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
smwhotjay 2018-11-09
  • 打赏
  • 举报
回复
可以对控件图像截屏成hbitmap 然后save 图像
zgl7903 2018-11-09
  • 打赏
  • 举报
回复
拷贝pWnd指向窗口的lpRect部分 写成BMP文件
先转换成图片文件, 然后再编码


schlafenhamster 2018-11-09
  • 打赏
  • 举报
回复
HBITMAP CopyScreenToBitmap(CRect &Rect,HWND hwnd)
{
HDC hScrDC, hMemDC;
HBITMAP hOldBitmap,hBitmap;
int xScrn, yScrn;
// to screen coordinates.
MapWindowPoints(hwnd,NULL,(POINT *)&Rect,2);
hScrDC = CreateDC("DISPLAY", NULL, NULL, NULL);
hMemDC = CreateCompatibleDC(hScrDC);
//
xScrn = GetDeviceCaps(hScrDC, HORZRES);
yScrn = GetDeviceCaps(hScrDC, VERTRES);
//
if (Rect.left < 0) Rect.left = 0;
if (Rect.top < 0) Rect.top = 0;
if (Rect.right > xScrn) Rect.right = xScrn;
if (Rect.bottom > yScrn) Rect.bottom = yScrn;
//
hBitmap = CreateCompatibleBitmap(hScrDC, Rect.Width(),Rect.Height());
hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);
BitBlt(hMemDC,0,0,Rect.Width(),Rect.Height(),hScrDC,Rect.left,Rect.top,SRCCOPY);
hBitmap =(HBITMAP)SelectObject(hMemDC,hOldBitmap);
//
DeleteDC(hScrDC);
DeleteDC(hMemDC);
//
return hBitmap;
}

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧