HBITMAP StretchBitmap (HBITMAP hBitmap1 )
{
BITMAP bm1 , bm2 ;
HBITMAP hBitmap2 ;
HDC hdc , hdcMem1, hdcMem2 ;
int cxChar, cyChar ;
// Get the width and height of a system font character
cxChar = LOWORD (GetDialogBaseUnits ()) ;
cyChar = HIWORD (GetDialogBaseUnits ()) ;
// Create 2 memory DCs compatible with the display
hdc = CreateIC (TEXT ("DISPLAY"), NULL, NULL, NULL) ;
hdcMem1 = CreateCompatibleDC (hdc ) ;
hdcMem2 = CreateCompatibleDC (hdc ) ;
DeleteDC (hdc ) ;
// Get the dimensions of the bitmap to be stretched
GetObject (hBitmap1 , sizeof (BITMAP), ( PTSTR ) & bm1 ) ;
// Scale these dimensions based on the system font size
bm2 = bm1 ;
bm2 .bmWidth = (cxChar * bm2 .bmWidth) / 4 ;
bm2 .bmHeight = (cyChar * bm2 .bmHeight ) / 8 ;
bm2 .bmWidthBytes = (( bm2 .bmWidth + 15) / 16) * 2 ;
// Create a new bitmap of larger size
hBitmap2 = CreateBitmapIndirect (& bm2 ) ;
// Select the bitmaps in the memory DCs and do a StretchBlt
SelectObject (hdcMem1, hBitmap1 ) ;
SelectObject (hdcMem2, hBitmap2 ) ;
StretchBlt (hdcMem2, 0, 0, bm2 .bmWidth, bm2 .bmHeight ,
hdcMem1, 0, 0, bm1 .bmWidth, bm1 .bmHeight , SRCCOPY) ;
// Clean up
DeleteDC (hdcMem1) ;
DeleteDC (hdcMem2) ;
DeleteObject (hBitmap1 ) ;
return hBitmap2 ;
} 在windows程序设计位图那部分看到这段代码,请问
bm2 .bmWidth = (cxChar * bm2 .bmWidth) / 4 ;
bm2 .bmHeight = (cyChar * bm2 .bmHeight ) / 8 ;
这两句转换是什么意思?
{
BITMAP bm1 , bm2 ;
HBITMAP hBitmap2 ;
HDC hdc , hdcMem1, hdcMem2 ;
int cxChar, cyChar ;
// Get the width and height of a system font character
cxChar = LOWORD (GetDialogBaseUnits ()) ;
cyChar = HIWORD (GetDialogBaseUnits ()) ;
// Create 2 memory DCs compatible with the display
hdc = CreateIC (TEXT ("DISPLAY"), NULL, NULL, NULL) ;
hdcMem1 = CreateCompatibleDC (hdc ) ;
hdcMem2 = CreateCompatibleDC (hdc ) ;
DeleteDC (hdc ) ;
// Get the dimensions of the bitmap to be stretched
GetObject (hBitmap1 , sizeof (BITMAP), ( PTSTR ) & bm1 ) ;
// Scale these dimensions based on the system font size
bm2 = bm1 ;
bm2 .bmWidth = (cxChar * bm2 .bmWidth) / 4 ;
bm2 .bmHeight = (cyChar * bm2 .bmHeight ) / 8 ;
bm2 .bmWidthBytes = (( bm2 .bmWidth + 15) / 16) * 2 ;
// Create a new bitmap of larger size
hBitmap2 = CreateBitmapIndirect (& bm2 ) ;
// Select the bitmaps in the memory DCs and do a StretchBlt
SelectObject (hdcMem1, hBitmap1 ) ;
SelectObject (hdcMem2, hBitmap2 ) ;
StretchBlt (hdcMem2, 0, 0, bm2 .bmWidth, bm2 .bmHeight ,
hdcMem1, 0, 0, bm1 .bmWidth, bm1 .bmHeight , SRCCOPY) ;
// Clean up
DeleteDC (hdcMem1) ;
DeleteDC (hdcMem2) ;
DeleteObject (hBitmap1 ) ;
return hBitmap2 ;
} 在windows程序设计位图那部分看到这段代码,请问
bm2 .bmWidth = (cxChar * bm2 .bmWidth) / 4 ;
bm2 .bmHeight = (cyChar * bm2 .bmHeight ) / 8 ;
这两句转换是什么意思?
解决方案 »
- SOCKET中, 如何读取RAR文件,并发送到服务器中
- 如何实现类似选中多个文件后按下Ctrl + C的效果?
- 初学者高分求一简单的vs c++ 2005编写的ado访问sql server数据库的项目源码
- 玩游戏时,保存了以后关了,再打开时会接着上回结束的地方打,是使用什么原理啊?
- 最近没有一点进步,公司也快跨了,心情跌到了低谷,闭关 && 找工作。散分(2)!!!!
- 程序在运行开始时出现 user breakpoint called from code at 0x7c953412 的对话框如何处理?
- 求救:实现插件功能时,遇到的一个问题
- 关于超时的问题。请高手指点
- 如何给对话框增加最大化和最小化按扭呢?
- 怎么使用ATL编写的COM/COM+组件使其能返回ADOrecordset记录集给客户端?
- 编译器内置的宏 VC中怎么显示这些宏定义,编译原理,词法分析,语法分析
- 问一个关于播放器的界面问题,十分感谢
当我们需要缩放字体以适应不同显示分辨率或纵横比时,内存设备内容也能解决问题。在GRAFMENU程序中,
我建立了四个位图,这些位图只适用于系统字体高8图素、宽4图素的显示。对于其它尺寸的系统字体,
只能缩放位图。GRAFMENU中的StretchBitmap函数完成此功能。这是《windows程序设计》位图 部分的原话。
除以4和除以8指的是字体的大小,那么前面的cxChar和cyChar呢?希望指点一下