Click here to Skip to main content
16,005,141 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Multi-tabbed window Pin
Jader8926-Sep-05 11:12
Jader8926-Sep-05 11:12 
GeneralRe: Multi-tabbed window Pin
Jose Lamas Rios26-Sep-05 16:16
Jose Lamas Rios26-Sep-05 16:16 
GeneralRe: Multi-tabbed window Pin
PJ Arends26-Sep-05 17:06
professionalPJ Arends26-Sep-05 17:06 
GeneralRe: Multi-tabbed window Pin
Jose Lamas Rios26-Sep-05 18:39
Jose Lamas Rios26-Sep-05 18:39 
GeneralRe: Multi-tabbed window Pin
Jader8927-Sep-05 6:43
Jader8927-Sep-05 6:43 
GeneralRe: Multi-tabbed window Pin
Jader8927-Sep-05 8:07
Jader8927-Sep-05 8:07 
QuestionMessage Deadlocks Pin
Ajay L D26-Sep-05 6:10
Ajay L D26-Sep-05 6:10 
QuestionProblem with Video Mixing Renderer 9 (VMR-9) Pin
tl0825426-Sep-05 5:37
tl0825426-Sep-05 5:37 
Hi, i'm trying to make an aplication to blend subtitles onto a video stream. The renderer i need to use is the Video Mixing Renderer 9. The application is based on one of the examples of the DirectX SDK, called Text9. I'm using parto of the code. I've build the filter graph, with the VMR-9 as renderer. When i try to add the bitmap to the VMR's input, the program says: "Unhandled exception in executable.exe:0xc0000005:Access Violation".

This is the code:

HRESULT CText::BlendText(TCHAR *szNewText)
{

LONG cx, cy;
HRESULT hr;
CSubtitlesDlg dialog;

// Read the default video size
// hr = pWC->GetNativeVideoSize(&cx, &cy, NULL, NULL);

// Create a device context compatible with the current window
HDC hdc= GetDC(dialog.GetSafeHwnd());
HDC hdcBmp = CreateCompatibleDC(hdc);

// Write with a known font by selecting it into our HDC
HFONT hOldFont = (HFONT) SelectObject(hdcBmp, g_hFont);

// Determine the length of the string, then determine the
// dimensions (in pixels) of the character string using the
// currently selected font. These dimensions are used to create
// a bitmap below.
int nLength, nTextBmpWidth, nTextBmpHeight;
SIZE sz={0};

nLength = (int) _tcslen(szNewText);
GetTextExtentPoint32(hdcBmp, szNewText, nLength, &sz);
nTextBmpHeight = sz.cy;
nTextBmpWidth = sz.cx;

// Create a new bitmap that is compatible with the current window
HBITMAP hbm = CreateCompatibleBitmap(hdc, nTextBmpWidth, nTextBmpHeight);
ReleaseDC(dialog.GetSafeHwnd(), hdc);

// Select our bitmap into the device context and save the old one
BITMAP bm;
HBITMAP hbmOld;
GetObject(hbm, sizeof(bm), &bm);
hbmOld = (HBITMAP)SelectObject(hdcBmp, hbm);

// Set initial bitmap settings
RECT rcText;
SetRect(&rcText, 0, 0, nTextBmpWidth, nTextBmpHeight);
SetBkColor(hdcBmp, RGB(255, 255, 255)); // Pure white background
SetTextColor(hdcBmp, g_rgbColors); // Write text with requested color

// Draw the requested text string onto the bitmap
TextOut(hdcBmp, 0, 0, szNewText, nLength);

// Configure the VMR's bitmap structure
VMR9AlphaBitmap bmpInfo;
ZeroMemory(&bmpInfo, sizeof(bmpInfo));
bmpInfo.dwFlags = VMRBITMAP_HDC;
bmpInfo.hdc = hdcBmp; // DC which has selected our bitmap

// Remember the width of this new bitmap
g_nImageWidth = bm.bmWidth;

// Save the ratio of the bitmap's width to the width of the video file.
// This value is used to reposition the bitmap in composition space.
g_fBitmapCompWidth = (float)g_nImageWidth / (float)cx;

// Display the bitmap in the bottom right corner.
// rSrc specifies the source rectangle in the GDI device context
// rDest specifies the destination rectangle in composition space (0.0f to 1.0f)
bmpInfo.rDest.left = 0.0f + X_EDGE_BUFFER;
bmpInfo.rDest.right = 1.0f - X_EDGE_BUFFER;
bmpInfo.rDest.top = (float)(cy - bm.bmHeight) / (float)cy - Y_EDGE_BUFFER;
bmpInfo.rDest.bottom = 1.0f - Y_EDGE_BUFFER;
bmpInfo.rSrc = rcText;

// Transparency value 1.0 is opaque, 0.0 is transparent.
bmpInfo.fAlpha = TRANSPARENCY_VALUE;

// Set the COLORREF so that the bitmap outline will be transparent
// SetColorRef(bmpInfo);

// Give the bitmap to the VMR for display
CFilterGraph Graph;
hr = Graph.m_pBMP->SetAlphaBitmap(&bmpInfo); <----This is the point where i get the problem.

// Select the initial objects back into our device context
DeleteObject(SelectObject(hdcBmp, hbmOld));
SelectObject(hdc, hOldFont);

// Clean up resources
DeleteObject(hbm);
DeleteDC(hdcBmp);

return hr;
}
QuestionPorting from Win2000 to WinXP Pin
mckavity26-Sep-05 5:31
mckavity26-Sep-05 5:31 
AnswerRe: Porting from Win2000 to WinXP Pin
David Crow26-Sep-05 5:41
David Crow26-Sep-05 5:41 
GeneralRe: Porting from Win2000 to WinXP Pin
mckavity26-Sep-05 5:51
mckavity26-Sep-05 5:51 
GeneralRe: Porting from Win2000 to WinXP Pin
Ravi Bhavnani26-Sep-05 5:57
professionalRavi Bhavnani26-Sep-05 5:57 
GeneralRe: Porting from Win2000 to WinXP Pin
mckavity26-Sep-05 6:53
mckavity26-Sep-05 6:53 
GeneralRe: Porting from Win2000 to WinXP Pin
Ravi Bhavnani26-Sep-05 7:07
professionalRavi Bhavnani26-Sep-05 7:07 
GeneralRe: Porting from Win2000 to WinXP Pin
David Crow26-Sep-05 5:58
David Crow26-Sep-05 5:58 
AnswerRe: Porting from Win2000 to WinXP Pin
Michael Dunn26-Sep-05 8:14
sitebuilderMichael Dunn26-Sep-05 8:14 
Questionusing CDatabase writing into excel files Pin
26-Sep-05 3:54
suss26-Sep-05 3:54 
AnswerRe: using CDatabase writing into excel files Pin
David Crow26-Sep-05 4:49
David Crow26-Sep-05 4:49 
GeneralRe: using CDatabase writing into excel files Pin
tejaswi-teja26-Sep-05 5:51
tejaswi-teja26-Sep-05 5:51 
GeneralRe: using CDatabase writing into excel files Pin
David Crow26-Sep-05 6:02
David Crow26-Sep-05 6:02 
GeneralRe: using CDatabase writing into excel files Pin
tejaswi-teja26-Sep-05 19:39
tejaswi-teja26-Sep-05 19:39 
GeneralRe: using CDatabase writing into excel files Pin
David Crow27-Sep-05 2:46
David Crow27-Sep-05 2:46 
GeneralRe: using CDatabase writing into excel files Pin
tejaswi-teja27-Sep-05 3:23
tejaswi-teja27-Sep-05 3:23 
QuestionEstimate distance Pin
bulgaa26-Sep-05 3:41
bulgaa26-Sep-05 3:41 
AnswerRe: Estimate distance Pin
David Crow26-Sep-05 4:50
David Crow26-Sep-05 4:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.