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

来源:百度知道 编辑:UC知道 时间:2024/05/31 10:32:22
我在程序中调用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 <>

你的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
Delet