Store and read a picture from memory.
API Declarations
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Public Function SetPictureIntoMemory(SrcPic As PictureBox, DestPic As PictureBox, Index As Byte)
BackUpSrcDC(Index) = CreateCompatibleDC(DestPic.hdc) 'Create DC to hold stage
BackUpResultDC(Index) = CreateCompatibleDC(DestPic.hdc) 'Create DC to hold stage
BackUphResultBmp(Index) = CreateCompatibleBitmap(DestPic.hdc, DestPic.ScaleWidth, DestPic.ScaleHeight)
'Select bitmap in DC
hSrcPrevBmp = SelectObject(BackUpSrcDC(Index), SrcPic.Picture) 'or put LoadPicture(Filename)
hDestPrevBmp = SelectObject(BackUpResultDC(Index), BackUphResultBmp(Index)) 'Select bitmap
End Function
Public Function CopyPictureFormMemory(SrcPic As PictureBox, SrcDc As Long)
SrcPic.AutoRedraw = True
BitBlt SrcPic.hdc, 0, 0, SrcPic.ScaleWidth, SrcPic.ScaleHeight, SrcDc, 0, 0, vbSrcCopy
SrcPic.Picture = SrcPic.Image
SrcPic.AutoRedraw = False
End Function