VB 多次调用StretchBlt 导致失败的问题

我在程序中调用StretchBlt函数对一个400*400的位图放大8倍后显示,可是该程序同时开启大约4个之后StretchBlt函数开始返回0值,图像不能被正确放大,是... 我在程序中调用StretchBlt函数对一个400*400的位图放大8倍后显示,可是该程序同时开启大约4个之后StretchBlt函数开始返回0值,图像不能被正确放大,是我的内存太小(512M)还是别的原因?
Private Sub load_map(num As Long)
Dim l as long
DeleteDC hMemDc
DeleteDC hMemDc1
Set PicBmp = LoadPicture(App.Path & "\map\" & CStr(num) & ".map")
Dim bm As BITMAP
Dim hBitmap1 As Long, holdmap As Long
GetObject PicBmp.Handle, Len(bm), bm
w = bm.bmWidth
h = bm.bmHeight
hMemDc = CreateCompatibleDC(hdc)
SelectObject hMemDc, PicBmp.Handle
w1 = w * 8
h1 = h * 8
hMemDc1 = CreateCompatibleDC(hdc)
hBitmap1 = CreateCompatibleBitmap(hdc, w1, h1)
holdmap = SelectObject(hMemDc1, hBitmap1)
l = StretchBlt(hMemDc1, 0, 0, w1, h1, hMemDc, 0, 0, w, h, vbSrcCopy)
DeleteObject hBitmap1
If holdmap <> 0 Then
DeleteObject holdmap
End If
If l = 0 Then Msgbox "显示地图:" & map_num & "失败"
End Sub
展开
 我来答
firsthua
2009-08-01 · TA获得超过1781个赞
知道大有可为答主
回答量:2034
采纳率:0%
帮助的人:789万
展开全部
你的DC每次有没有销毁。
你可能重复了DC。
把代码贴上来看看。
Private Sub load_map(num As Long)
Dim l as long
Set PicBmp = LoadPicture(App.Path & "\map\" & CStr(num) & ".map")
Dim bm As BITMAP
Dim hBitmap1 As Long, holdmap As Long
GetObject PicBmp.Handle, Len(bm), bm
w = bm.bmWidth
h = bm.bmHeight
hMemDc = CreateCompatibleDC(hdc)
SelectObject hMemDc, PicBmp.Handle
w1 = w * 8
h1 = h * 8
hMemDc1 = CreateCompatibleDC(hdc)
hBitmap1 = CreateCompatibleBitmap(hdc, w1, h1)
holdmap = SelectObject(hMemDc1, hBitmap1)
l = StretchBlt(hMemDc1, 0, 0, w1, h1, hMemDc, 0, 0, w, h, vbSrcCopy)
DeleteObject hBitmap1
If holdmap <> 0 Then
DeleteObject holdmap
End If
DeleteDC hMemDc
DeleteDC hMemDc1

If l = 0 Then Msgbox "显示地图:" & map_num & "失败"
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式