初学者:关于位图的问题!

wudi251314 2007-08-16 08:12:42
为PICTURE 控件定义了一个变量m_CBmp,又定义了一个对象CBitmap cBmp
语句m_CBmp.SetBitmap(HBITMAP(cBmp))里的HBITMAP(cBmp)是什么意思?
有哪位朋友有现成的关于位图操作的经常能用到的函数的总结和用法,麻烦上传一下
我的MSDN不能用,不知道为什么就是装不上,晕死了!
...全文
141 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
clever101 2007-08-16
  • 打赏
  • 举报
回复
到网上查一下CDib类吧,一个操作位图的通用类
wudi251314 2007-08-16
  • 打赏
  • 举报
回复
msdn的解释也太多了啊
真的好麻烦啊
头快大了
shell_shell 2007-08-16
  • 打赏
  • 举报
回复
HBITMAP是句柄。
获得句柄,例下:
HBITMAP hbitmap;
hbitmap=(HBITMAP)::LoadImage(AfxGetInstanceHandle(),"E:\\cmos.bmp", IMAGE_BITMAP,1200,960, LR_CREATEDIBSECTION|LR_LOADFROMFILE);

xxxxx.SetBitmap(hbitmap);


MSDN解释:

LoadImage
The LoadImage function loads an icon, cursor, or bitmap.

HANDLE LoadImage(
HINSTANCE hinst, // handle of the instance containing the image
LPCTSTR lpszName, // name or identifier of image
UINT uType, // type of image
int cxDesired, // desired width
int cyDesired, // desired height
UINT fuLoad // load flags
);

Parameters
hinst
Handle to an instance of the module that contains the image to be loaded. To load an OEM image, set this parameter to zero.
lpszName
Handle to the image to load.
If the hinst parameter is non-NULL and the fuLoad parameter does not include LR_LOADFROMFILE, lpszName is a pointer to a null-terminated string that contains the name of the image resource in the hinst module.

If hinst is NULL and LR_LOADFROMFILE is not specified, the low-order word of this parameter must be the identifier of the OEM image to load. The OEM image identifiers are defined in WINUSER.H and have the following prefixes: Prefix Meaning
OBM_ OEM bitmaps
OIC_ OEM icons
OCR_ OEM cursors



If the fuLoad parameter includes the LR_LOADFROMFILE value, lpszName is the name of the file that contains the image.

uType
Specifies the type of image to be loaded. This parameter can be one of the following values: Value Meaning
IMAGE_BITMAP Loads a bitmap.
IMAGE_CURSOR Loads a cursor.
IMAGE_ICON Loads an icon.


cxDesired
Specifies the width, in pixels, of the icon or cursor. If this parameter is zero and the fuLoad parameter is LR_DEFAULTSIZE, the function uses the SM_CXICON or SM_CXCURSOR system metric value to set the width. If this parameter is zero and LR_DEFAULTSIZE is not used, the function uses the actual resource width.
cyDesired
Specifies the height, in pixels, of the icon or cursor. If this parameter is zero and the fuLoad parameter is LR_DEFAULTSIZE, the function uses the SM_CYICON or SM_CYCURSOR system metric value to set the height. If this parameter is zero and LR_DEFAULTSIZE is not used, the function uses the actual resource height.
fuLoad
Specifies a combination of the following values: Value Meaning
LR_DEFAULTCOLOR The default flag; it does nothing. All it means is "not LR_MONOCHROME".
LR_CREATEDIBSECTION When the uType parameter specifies IMAGE_BITMAP, causes the function to return a DIB section bitmap rather than a compatible bitmap. This flag is useful for loading a bitmap without mapping it to the colors of the display device.
LR_DEFAULTSIZE Uses the width or height specified by the system metric values for cursors or icons, if the cxDesired or cyDesired values are set to zero. If this flag is not specified and cxDesired and cyDesired are set to zero, the function uses the actual resource size. If the resource contains multiple images, the function uses the size of the first image.
LR_LOADFROMFILE Loads the image from the file specified by the lpszName parameter. If this flag is not specified, lpszName is the name of the resource.
LR_LOADMAP3DCOLORS Searches the color table for the image and replaces the following shades of gray with the corresponding 3D color:

Color Replaced with
Dk Gray,
RGB(128,128,128) COLOR_3DSHADOW
Gray,
RGB(192,192,192) COLOR_3DFACE
Lt Gray,
RGB(223,223,223) COLOR_3DLIGHT

LR_LOADTRANSPARENT Retrieves the color value of the first pixel in the image and replaces the corresponding entry in the color table with the default window color (COLOR_WINDOW). All pixels in the image that use that entry become the default window color. This value applies only to images that have corresponding color tables.
If fuLoad includes both the LR_LOADTRANSPARENT and LR_LOADMAP3DCOLORS values, LRLOADTRANSPARENT takes precedence. However, the color table entry is replaced with COLOR_3DFACE rather than COLOR_WINDOW.

LR_MONOCHROME Loads the image in black and white.
LR_SHARED Shares the image handle if the image is loaded multiple times. If LR_SHARED is not set, a second call to LoadImage for the same resource will load the image again and return a different handle.
Do not use LR_SHARED for images that have non-standard sizes, that may change after loading, or that are loaded from a file.

Windows 95 and Windows 98: The function finds the first image with the requested resource name in the cache, regardless of the size requested.

LR_VGACOLOR Uses true VGA colors.
wudi251314 2007-08-16
  • 打赏
  • 举报
回复
能不能给提供一个网址?想下一个。
ZHAOZIMING1984 2007-08-16
  • 打赏
  • 举报
回复
装2005的msdn

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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