VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Store and read a picture from memory.

by MOhanand Sulaiman Abu Sall (1 Submission)
Category: Graphics
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 21st September 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

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


Rate Store and read a picture from memory.




command button 1:
SetPictureIntoMemory MainPic, MainPic, frmLoaded

command button 2:
CopyPictureFormMemory MainPic, BackUpSrcDC(frmLoaded)

Download this snippet    Add to My Saved Code

Store and read a picture from memory. Comments

No comments have been posted about Store and read a picture from memory.. Why not be the first to post a comment about Store and read a picture from memory..

Post your comment

Subject:
Message:
0/1000 characters