i'm using CreateDIBSection():
Public Function NewImage(ByVal ImageWidth As Long, ByVal ImageHeight As Long, Optional color As ColorConstants = vbBlack) As Long
If (Width > 0 Or Height > 0 Or hBitmap > 0 Or PointerPixelData > 0) Then DeleteImage
Width = ImageWidth
Height = ImageHeight
'Criar HDC
MemoryHDC = CreateCompatibleDC(0)
With bmiInfo.bmiHeader
.biSize = Len(bmiInfo.bmiHeader)
.biWidth = Width
.biHeight = -Height ' is negative for start on top left pixel image
.biPlanes = 1
.biBitCount = 32
.biCompression = BI_RGB
.biSizeImage = AlignScan(bmiInfo.bmiHeader.biWidth, bmiInfo.bmiHeader.biBitCount) * bmiInfo.bmiHeader.biHeight
End With
If MemoryHDC = 0 Then MsgBox "error: HDC not created!!!"
hBitmap = CreateDIBSection(0&, bmiInfo, DIB_RGB_COLORS, PointerPixelData, 0&, 0&)
If hBitmap = 0 Then MsgBox "error: " & GetLastError()
oldBitmap = SelectObject(MemoryHDC, hBitmap)
'using pointers:
' Get the bits in the from DIB section:
With tSA
.fFeatures = FADF_FIXEDSIZE Or FADF_AUTO
.cbElements = 4
.cDims = 1
.Bounds(0).lLbound = 0
.Bounds(0).cElements = bmiInfo.bmiHeader.biHeight * bmiInfo.bmiHeader.biWidth
.pvData = PointerPixelData
End With
'Erase bDib
' Make the bDib() array point to the memory addresses:
CopyMemory ByVal VarPtrArray(bDib()), VarPtr(tSA), 4
CopyMemory ByVal VarPtrArray(bDibBGRA()), VarPtr(tSA), 4
'Clear color
End Function
why, after 4 IDE executions, using CreateDIBSection(), i get, on GetLastError(), 8 : "Not enough memory resources are available to process this command."?
but on EXE i don't get these problem... but why?