Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subtitle over VIDEO playback

Status
Not open for further replies.

codecref

Programmer
Dec 8, 2003
118
0
0
US
hi guys
I have a picturebox playing avi file through ActiveMovie Control (These calls)

Private m_objBasicAudio As IBasicAudio
Private m_objBasicVideo As IBasicVideo
Private m_objMediaEvent As IMediaEvent
Private m_objVideoWindow As IVideoWindow
Private m_objMediaControl As IMediaControl
Private m_objMediaPosition As IMediaPosition

and now I am going play subtitle (sourced from either text or bmp file), which is easier to do ? display bmp overlay on that picturebox and color key the background?

how do I send it to DirectShow and play it somehow like playing subtitle by PowerDVD

any help is highly appreciated.
 
Could you just use a lable on the picture box...?

*Might not work if you want it to be muliti color text (i.e. A Border)

Have Fun, Be Young... Code BASIC
-Josh

cubee101.gif


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
well label could be good but it does not have stroke which is soemthing I am looking for it later... I could manage to fetch a code to make picturebox transparent, now I am stuck somewhere else:

now I am generating a bmp on the fly and put it into a picturebox and then put back again into a stdpicture value.

Question one: how do I change the text and add stroke?

Question two: how do I change the text color and apply underline or italic to it partially and alignment (center,left,right)

Question three: it does not act to chr(10) or chr(13) or vbCrLf to go to next line, how to do that?

Code:
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
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
Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As Long) As Long
Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private 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
Private Const SRCCOPY = &HCC0020
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As Long
Private Const BLACK_PEN = 6
Private Const WHITE_BRUSH = 0
Private Const NULL_BRUSH = 5
Private Declare Function Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

Private Declare Function CreateFont Lib "gdi32" Alias "CreateFontA" (ByVal H As Long, ByVal W As Long, ByVal E As Long, ByVal O As Long, ByVal W As Long, ByVal I As Long, ByVal u As Long, ByVal S As Long, ByVal C As Long, ByVal OP As Long, ByVal CP As Long, ByVal Q As Long, ByVal PAF As Long, ByVal F As String) As Long
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Private Const ANSI_CHARSET = 0
Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
Private Declare Function GetBkMode Lib "gdi32" (ByVal hdc As Long) As Long
Private Const TRANSPARENT = 1

Public Function Txt2Image(ByVal Text As String) As StdPicture

Dim mem_dc As Long
Dim mem_bm As Long
Dim orig_bm As Long
Dim wid As Long
Dim hgt As Long
Dim old_font As Long
Dim new_font As Long
Dim old_bk_mode As Long
'GoTo Here
    wid = 720
    hgt = 200
    ' Create the device context.
    mem_dc = CreateCompatibleDC(hdc)

    ' Create the bitmap.
    mem_bm = CreateCompatibleBitmap(mem_dc, wid, hgt)

    ' Make the device context use the bitmap.
    orig_bm = SelectObject(mem_dc, mem_bm)

    ' Give the device context a white background.
    SelectObject mem_dc, GetStockObject(WHITE_BRUSH)
    Rectangle mem_dc, 0, 0, wid, hgt
    SelectObject mem_dc, GetStockObject(NULL_BRUSH)

    ' Draw the on the device context.
    SelectObject mem_dc, GetStockObject(BLACK_PEN)
    MoveToEx mem_dc, 0, 0, ByVal 0&
    
    MoveToEx mem_dc, 0, hgt, ByVal 0&
    

    ' Do not fill the background.
    old_bk_mode = GetBkMode(mem_dc)
    SetBkMode mem_dc, TRANSPARENT

    ' Give the DC a font.
    new_font = CreateFont(25, 0, 0, 0, _
        700, 0, 0, 0, ANSI_CHARSET, _
        0, 0, 0, 0, "Tahoma")
    old_font = SelectObject(mem_dc, new_font)

    ' Draw some text.
    TextOut mem_dc, 10, 20, Text, Len(Text)

    ' Destroy the new font.
    SelectObject mem_dc, old_font
    DeleteObject new_font

    ' Restore the original background fill mode.
    SetBkMode mem_dc, old_bk_mode
    ImportQuestion.Picture1.AutoRedraw = True
    ' Copy the device context into the PictureBox.
    BitBlt ImportQuestion.Picture1.hdc, 0, 0, wid, hgt, _
        mem_dc, 0, 0, SRCCOPY
    ImportQuestion.Picture1.Picture = ImportQuestion.Picture1.Image
    
Here:
    With ImportQuestion
        '.ForeColor = vbGreen
        'TextOut .hdc, 5, 10, Text, Len(Text)
        Set Txt2Image = .Picture1.Picture
    End With
    
    ' Delete the bitmap and dc.
    SelectObject mem_dc, orig_bm
    DeleteObject mem_bm
    DeleteDC mem_dc
End Function
 
Nope ;-)

If I were in your place, I would start hitting google with queries involving Direct X, Direct Play, VB, Subtitles, and other relavent criteria... (including words like tutorial & example help too)

I've, personally, never had to do this... and from the way it looks, no one else here has either...(?)

If you do find a way to accomplish what you are looking for, you could post the solution back here in case anyone else runs accross the same dilema. In the mean time, if anyone else finds a solution, I'm sure they will post it...

Good Luck,
-Josh

Have Fun, Be Young... Code BASIC
-Josh

cubee101.gif


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top