YoungBuck
Jun 15th, 2000, 10:17 AM
Anybody know how to get a picture loaded from a file directly into a DC without having to display it in a picturebox and bitblt it to the dc.
Fox
Jun 15th, 2000, 11:41 AM
See the demo project (http://orion.spaceports.com/~mccloud/coding/graphical.htm#Offscreen DCs) on my website ;)
Illuminator
Jun 16th, 2000, 04:35 AM
In your module declare these functions and variables:
________________________________
'API FUNCTIONS
Public Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Public Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Public Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
'Variables
Public MyPicture_DC as long
_________________________________
Then write a function to load the image:
_________________________________
Sub Create_DC()
MyPicture_DC = CreateCompatibleDC(0)
SelectObject MyPicture_DC, LoadPicture("C:\MyPic.BMP")
End Sub
_________________________________
Now now MyPicture_DC contains the image and you can use Bitblt with it later.
Also in you form unload method use
DeleteDC MyPicture_dc
so that you free up image memory when your done the program.