Как сделать Регион из Bitmap с прозрачными обл. ?
От: BugMan  
Дата: 11.03.02 19:11
Оценка:
Делал так (на VB):

Private Sub Command1_Click()
Dim bmp As IPictureDisp
Dim oldbmp As Long
Dim destbmp As Long
Dim memDC As Long
Dim RetVal As Long
 
Dim destDC As Long
Dim destHeight As Long
Dim destWidth As Long
Dim srcDC As Long
Dim srcHeight As Long
Dim srcWidth As Long
 
 Form1.Show
 DoEvents
 
 
 memDC = CreateCompatibleDC(Form1.hdc)
 Set bmp = Picture2.Picture   'LoadPicture(App.Path & "\Loading.jpg")
 oldbmp = SelectObject(memDC, bmp.Handle)
 
 
 destDC = Form1.hdc
 destHeight = Form1.ScaleHeight / 2 
 destWidth = Form1.ScaleWidth / 2 
 
 srcDC = memDC
 srcHeight = Picture2.ScaleHeight 
 srcWidth = Picture2.ScaleWidth 

 BeginPath destDC
 
 RetVal = TransparentBlt(destDC, _
          0, 0, _
          destWidth, destHeight, _
          srcDC, _
          0, 0, _
          srcWidth, srcHeight, _
          RGB(255, 255, 255))
          
 EndPath destDC

 Dim hRgn As Long
 hRgn = PathToRegion(destDC)
 SetWindowRgn destDC, hRgn, True
 DeleteObject hRgn
 
          
 Debug.Print RetVal
 RetVal = SelectObject(memDC, oldbmp)
End Sub


В описании ф-ии Path2Region() сказано что между скобками (BeginPath и EndPath) надо сделать Select Path'а в Device Context. Как именно это сделать — непонятно В случае с TextOut() — т.е. когда Path делается из текста — всё понятно, а вот как такую же фигню провернуть с картинкой ???
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.