要写一个位图播放软件demo,用定时器每隔100ms从硬盘中读取一副位图然后显示,所以用API LoadImage从硬盘中读取位图,函数调用如下
结果定时器计数到50~60次时,动画便停止。
本来以为是定时器被堵死,无法响应中断,然后尝试将文件放到内存中直接显示,结果问题还是存在。
然后单步调试跟踪发现是LoadImage在执行了50~60次以后载入位图出错,bmp地址为0x00000000,参阅MSDN
LoadImage<!-- Built on Wednesday, August 08, 2001 -->
<script src="langref.js"></script>
LoadImage
The LoadImage
function loads an icon, cursor, animated cursor, or
bitmap.
HANDLE LoadImage(
HINSTANCE
hinst
,
// handle to instance
LPCTSTR
lpszName
,
// image to load
UINT
uType
,
// image type
int
cxDesired
,
// desired width
int
cyDesired
,
// desired height
UINT
fuLoad
// load options
);
Parameters
hinst
[in] 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
[in] Specifies the image to load. If the hinst
parameter is non-NULL
and the fuLoad
parameter omits LR_LOADFROMFILE, lpszName
specifies
the image resource in the hinst
module. If the image resource is to be
loaded by name, the lpszName
parameter is a pointer to a null-terminated
string that contains the name of the image resource. If the image resource is to
be loaded by ordinal, use the MAKEINTRESOURCE
macro to convert the image
ordinal into a form that can be passed to the LoadImage
function.
If the hinst
parameter is NULL and the fuLoad
parameter omits
the LR_LOADFROMFILE value, the lpszName
specifies 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 |
To pass these constants to the LoadImage
function, use the
MAKEINTRESOURCE
macro. For example, to load the OCR_NORMAL cursor, pass
MAKEINTRESOURCE
(OCR_NORMAL) as the lpszName
parameter and NULL as
the hinst
parameter.
If the fuLoad
parameter includes the LR_LOADFROMFILE value,
lpszName
is the name of the file that contains the image.
uType
[in] 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
[in] 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
[in] 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
[in] This parameter can be one or more 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 3-D 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 |
|
Do not use this option if you are loading a bitmap
with a color depth greater than 8bpp. |
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.
Do not use this option if you are loading a bitmap with a color depth greater
than 8bpp.
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.
When you use this flag, the system will destroy the resource when it is no
longer needed.
Do not use LR_SHARED for images that have non-standard sizes, that may change
after loading, or that are loaded from a file.
When loading a system icon or cursor, you must use LR_SHARED or the function
will fail to load the resource.
Windows 95/98/Me:
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. |
当加载OEM位图,并且fuLoad为LR_LOADFROMFILE,hinst可以等于NULL,所以将函数调用修改为
一切OK。但是问题是能够正常运行一段时间,然后动画终止?
分享到:
相关推荐
LoadImage
matlab开发-loadimage。负载
下载图片loadImage
重载cesium.ImageryProvider类中的loadImage函数,用于获取瓦片资源
vc CBitmapLoadBitmap_LoadImage加载.bmp文件
亲测可以打开! JS加载load图片 jquery.LoadImage图片预加载(逐渐加载)demo
EXCEL中所有图片链接,直接转成缩略图,并加入原来链接,可以点击
jquery.LoadImage图片预加载是一款一款实用简单的图片预加载效果,支持loading小图片,完全不需要在html让做任何改变即可实现。
UEFI loadImage protorcl如何使用,并给出调用后可得到的内存中的模块信息
以DIB格式显示图片
1、导入jquery库以及jquery.LoadImage.js插件 2、使用一小段jquery代码,指定需要加载的img即可,例如本案例指定class 为 main 下的图片预加载,则如$(".main img"),当然也可以指定加载的loading路径以及加载后的...
使用vs2015与opencv加载并显示图像
这将帮助您将库中的图像加载到 matlab 中的项目中
基于jquery开发的一个小插件,主要作用是绑定图片(img标签)的onload事件,如果是纯JavaScript开发,可借鉴下面的代码: var imgLoad = function (url, callback) { var img = new Image(); img.src = url;...
opencv入门小程序,使用opencv库加载图像,动态库的环境变量必须配置,必须使用mingw32版本的opencv3.4.7
105. bird = (HBITMAP)LoadImage(NULL,"angrybird.bmp",IMAGE_BITMAP,120,60,LR_LOADFROMFILE); 106. 107. GetClientRect(hWnd,▭); //取得内部窗口区域的大小 108. MyPaint(hdc); 109. 110. return TRUE; ...
图片切换
显示PNG控件 显示PNG控件 显示PNG控件 ...从图片文件中加载pngaicAlphaImage1.LoadImage_FromFile "C:\1.png" 如 Private Sub Command1_Click() aicAlphaImage1.LoadImage_FromFile "C:\1.png" End Sub
jquery.LoadImage图片预加载是一款一款实用简单的图片预加载效果,支持loading小图片,完全不需要在html让做任何改变即可实现。
Halloween_loadImage 此作业的目标 了解如何使用图像功能加载图像。使用loadImage函数创建艺术品并进行设置和绘制Expand Java词汇表 要求 使用加载的图像创建艺术品并进行设置和绘制,然后进行更改并添加到提供的源...