Модератор: Mikle
Public Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Public Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long
Public Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hScreenRectcDC As Long, ByVal xScreenRectc As Long, ByVal yScreenRectc As Long, ByVal nScreenRectcWidth As Long, ByVal nScreenRectcHeight As Long, ByVal dwRop As Long) As Long
Public Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
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
Type BITMAP
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
Public Sub LoadBitmapFile(DDS As DirectDrawSurface7, ByVal FileName As String)
Dim StorePic As StdPicture
Dim Bmp As BITMAP
Dim hDCPicture As Long, hDCSurface As Long
Set StorePic = LoadPicture(FileName)
Call GetObject(StorePic.Handle, Len(Bmp), Bmp)
hDCPicture = CreateCompatibleDC(ByVal 0&)
Call SelectObject(hDCPicture, StorePic.Handle)
ddsd.lFlags = DDSD_CAPS Or DDSD_WIDTH Or DDSD_HEIGHT
ddsd.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
ddsd.lHeight = Bmp.bmHeight
ddsd.lWidth = Bmp.bmWidth
Set DDS = g_DD.CreateSurface(ddsd)
Call DDS.restore
hDCSurface = DDS.GetDC
Call StretchBlt(hDCSurface, 0, 0, Bmp.bmWidth, Bmp.bmHeight, hDCPicture, 0, 0, Bmp.bmWidth, Bmp.bmHeight, &HCC0020)
Call DDS.ReleaseDC(hDCSurface)
Call DeleteDC(hDCPicture)
ddck.low = 0
ddck.high = 0
Call DDS.SetColorKey(DDCKEY_SRCBLT, ddck)
End Sub
Dim ddck as DDCOLORKEY
Dim surf as DirectDrawSurface7 ' твоя картинка
ddck.low=цвет фона, на котором изображение рисовалось в редакторе
ddck.high=ddck.low
surf.SetColorKey DDCKEY_SRCBLT, ddck
backbuffer.BltFast x,y,surf, rect, DDBLTFAST_SRCCOLORKEY
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 54