I have 2 picture boxes,

Picture1 is visible
Picture2 is invisible

I load a picture to Picture2 from a jpg file:

Picture2.Picture = LoadPicture(SomeFile)

and then I copy a small area from Picture2 to Picture1 and magnify it using StretchBlt:

StretchBlt Picture1.hDC, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, Picture2.hDC, zoomLeft, zoomTop, zoomWidth, zoomHeight, vbSrcCopy

Finally, for the purpose of manipulationg this image I use the function below -which I copied from this forums- to store it in a 2D array:

Dim arr2d() As Long
arr2d = RetDIBDataLong(Picture1, True)

where the function is:

Code:
	Public Function RetDIBDataLong(PictureObject As Object, Optional Return2DArray As Boolean) As Long()
	    Dim BM As BITMAP, bmi As BITMAPINFO, lngImageData() As Long
	    Dim hDC As Long, bReleaseDC As Boolean, hHandle As Long
	    
	    'The PictureObject must be an object with both a HDC and Image property
	    'such as a PictureBox, UserControl or Form
	    
	    If TypeName(PictureObject) = "Picture" Then
	        hHandle = PictureObject.Handle
	        bReleaseDC = True
	    Else
	        hHandle = PictureObject.Picture
	        hDC = PictureObject.hDC
	    End If
	    If GetObjectA(hHandle, 24, BM) = 0& Then Exit Function
	    
	    bmi.bmHeader.bmWidth = BM.bmWidth
	    bmi.bmHeader.bmHeight = BM.bmHeight
	    bmi.bmHeader.bmSize = 40
	    bmi.bmHeader.bmPlanes = 1
	    bmi.bmHeader.bmBitCount = 32
	    
	    If bReleaseDC Then hDC = GetDC(GetDesktopWindow)
	    
	    If Return2DArray Then
	      ReDim lngImageData(BM.bmWidth - 1, BM.bmHeight - 1)
	      GetDIBits hDC, hHandle, 0, BM.bmHeight, lngImageData(0, 0), bmi, 0
	    Else
	      ReDim lngImageData(BM.bmWidth * BM.bmHeight - 1)
	      GetDIBits hDC, hHandle, 0, BM.bmHeight, lngImageData(0), bmi, 0
	    End If
	    
	    If bReleaseDC Then ReleaseDC GetDesktopWindow, hDC
	    RetDIBDataLong = lngImageData
  
	End Function
But in the red line a 0 value is returned for hHandle and the function exits at the GetObjectA statememnt.

However, and this is what I don't understand, the function call works if I try it for test with Picture2.