|
Is there an API for burning files to DVD in a similar way as IMAPI?
|
|
|
|
|
|
Hi all:
Visual Studio 2005 gave me an error warning: "Too many initializers" when I tried to compile my codes:
ifstream in(argv[1], ios_base::binary);
I really do not know why?
Can any one help?
Thank you
|
|
|
|
|
Do you have
#include <fstream>
using namespace std;
somewhere before that line of code?
If so, what is argv?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi Mark:
Thank you. I forgot about #include<fstream>
Thank you again
|
|
|
|
|
Hi,
When I use
AVISaveOptions(*phFrameWnd, 0, 1, &m_pStream, m_aopts);
to bring up a dialog to choose Avi compressor options, got the following debug error:
First-chance exception in AviMaker.exe (DIVX.DLL): 0xC0000005: Access Violation
Do you know why? DivX codec 6.6 is installed.
|
|
|
|
|
If you continue after the first-chance exception does it run normally (meaning the exception was
caught and handled in the dll)??
If not...
What is m_aopts?
m_pStream points to a valid IAVIStream interface?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Yes. The exception was possibly handled in the dll. I got the same violation in the AVIStreamSetFormat() but it returned AVIERR_OK. The real problem is the AVIStreamWrite(), which returned AVIERR_BADFORMAT.
The code is pasted. This problem happens for Divx 6.6.1 Codec. it works fine for others like Huffyuv. Any thought?
Thanks a lot,
--------Code sample--------
int CVideoWriter::SaveAviFrame(HWND *phFrameWnd, HBITMAP *phBitmap)
{
AVISTREAMINFO sAviStreamInfo;
HRESULT hResult;
DIBSECTION sDibSection;
int iSizeDIBSection;
AVICOMPRESSOPTIONS m_opts;
AVICOMPRESSOPTIONS *m_aopts[1];
iSizeDIBSection = GetObject((*phBitmap),sizeof(sDibSection),&sDibSection);
if (iSizeDIBSection != sizeof(DIBSECTION))
return OPERATION_ERROR;
if (m_pStream == NULL)
{
ZeroMemory(&sAviStreamInfo, sizeof(AVISTREAMINFO));
sAviStreamInfo.fccType = streamtypeVIDEO;
sAviStreamInfo.fccHandler = 0;
sAviStreamInfo.dwScale = m_dwPeriod;
sAviStreamInfo.dwRate = 1000;
sAviStreamInfo.dwQuality = -1;
sAviStreamInfo.dwSuggestedBufferSize = sDibSection.dsBmih.biSizeImage;
SetRect(&sAviStreamInfo.rcFrame, 0, 0, sDibSection.dsBmih.biWidth,
sDibSection.dsBmih.biHeight);
hResult = AVIFileCreateStream(m_pAviFile, &m_pStream, &sAviStreamInfo);
if (hResult != AVIERR_OK)
return OPERATION_ERROR;
}
if (!(*m_pbIsCompressionOptionDone))
{
ZeroMemory(&m_opts,sizeof(AVICOMPRESSOPTIONS));
m_aopts[0] = &m_opts;
BOOL bPressOk = (BOOL) AVISaveOptions(*phFrameWnd, 0, 1, &m_pStream,
(LPAVICOMPRESSOPTIONS *) m_aopts);
if (!bPressOk)
{
AVISaveOptionsFree(1,m_aopts);
(*m_pbIsCompressionOptionDone) = TRUE;
return OPERATION_CANCEL;
}
}
if (m_pCompressedStream == NULL)
{
m_opts.fccType = streamtypeVIDEO;
m_opts.dwFlags = AVICOMPRESSF_VALID;
hResult = AVIMakeCompressedStream(&m_pCompressedStream, m_pStream,
&m_opts, NULL);
if (hResult != AVIERR_OK)
return OPERATION_ERROR;
hResult = AVIStreamSetFormat(m_pCompressedStream, 0, &sDibSection.dsBmih,
sDibSection.dsBmih.biSize + sDibSection.dsBmih.biClrUsed*sizeof(RGBQUAD));
if (hResult != AVIERR_OK)
return OPERATION_ERROR;
}
if (!(*m_pbIsCompressionOptionDone))
{
AVISaveOptionsFree(1,m_aopts);
(*m_pbIsCompressionOptionDone) = TRUE;
}
hResult = AVIStreamWrite(m_pCompressedStream, m_iFrameNumber, 1,
sDibSection.dsBm.bmBits, sDibSection.dsBmih.biSizeImage, 0, NULL, NULL);
if (hResult != AVIERR_OK)
return OPERATION_ERROR;
return NO_ERROR;
}
|
|
|
|
|
I'm not seeing anything wrong in your code.
I am suspicious of this line before the AVIMakeCompressedStream() call:
m_opts.dwFlags = AVICOMPRESSF_VALID;
What is the value of m_opts.dwFlags BEFORE this line executes? It seems to me you may be erasing
important flags there.
Also, with the way you are getting a BITMAPINFOHADER, this call isn't necessarily good:
hResult = AVIStreamSetFormat(m_pCompressedStream, 0, &sDibSection.dsBmih,
sDibSection.dsBmih.biSize + sDibSection.dsBmih.biClrUsed*sizeof(RGBQUAD));
This should be
hResult = AVIStreamSetFormat(m_pCompressedStream, 0, &sDibSection.dsBmih, sizeof(BITMAPINFOHEADER));
since there won't be any color table in a DIBSECTION structure unless
sDibSection.dsBmih.biCompression is BI_BITFIELDS.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks for the nice observation. I did the 2 changes to erase possible defects. Somehow, the problem seems not gone yet. I tried to decrease the frame rate to
sAviStreamInfo.dwScale = 1;
sAviStreamInfo.dwRate = 30;
it happened to work. But the dwRate can not be larger than 30. and the image size must be less than 580x580. Otherwise, problem holds. It sounds really strange since no rate or size limitation for DivX Codec is known about.
If more comments, I like to know.
|
|
|
|
|
What about 720x576 25 fps ?
I'm not sure where to find an accurate description of valid formats for that codec
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
im trying to get my window to update using update UpdateLayeredWindow, but no luck so far.
this is the function im using:
void update(HWND hwnd){<br />
HDC pDC = GetDC(hwnd);<br />
HDC dcMem;<br />
dcMem = CreateCompatibleDC(pDC);<br />
COLORREF colour;<br />
colour = RGB(255,255,255);<br />
HBITMAP bmp;<br />
bmp = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP1));<br />
if(!bmp)MessageBox(NULL,"FAIL TO LOAD IMAGE", "ERROR",NULL);<br />
<br />
HBITMAP pOldBitmap = (HBITMAP) SelectObject(dcMem, bmp);<br />
<br />
<br />
BLENDFUNCTION blend;<br />
blend.BlendOp = AC_SRC_OVER;<br />
blend.BlendFlags = 0;<br />
blend.SourceConstantAlpha = 255;<br />
blend.AlphaFormat = AC_SRC_ALPHA;<br />
<br />
POINT ptSrc = {10, 10 };<br />
SIZE sz = { 100, 100 };<br />
UpdateLayeredWindow(hwnd, NULL, NULL, &sz, dcMem, &ptSrc, colour, &blend, ULW_COLORKEY );<br />
DWORD dwError = GetLastError();
<br />
DeleteDC(dcMem);<br />
DeleteObject(pDC);<br />
}
it compiles and runs fine is just that UpdateLayeredWindow is doing nothing.
thank you
|
|
|
|
|
Maybe a silly question - Is the HWND a handle to a window created as a layered window?
If so...
Is the window a child window?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
yes is the handle to the window and no is not a child window.
i've also posted on this forum the code:
http://www.gamedev.net/community/forums/topic.asp?topic_id=449081
thank you
|
|
|
|
|
Cool thanks for the link!
I don't think you should be calling SetLayeredWindowAttributes().
Try commenting out that call.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
hehe the window does not show if i do that.
|
|
|
|
|
OK but they are not meant to be used together - they cause the window updates to be done
two different ways.
If you must use both, the docs state "Note that once SetLayeredWindowAttributes has been called
for a layered window, subsequent UpdateLayeredWindow calls will fail until the layering style bit
is cleared and set again."
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
without the SetLayeredWindowAttributes i dont get the 87 error code form getlast error which is a good news, but the window is not showing and UpdateLayeredWindow is returning 0;
|
|
|
|
|
Lamefif wrote: the window is not showing and UpdateLayeredWindow is returning 0;
If it's returning 0 then it's still failing, right? Or do you mean GetLastError() returns 0?
ACK I just noticed in your code on the other site - you are destroying the memDC. I'm pretty
sure the system is going to need that to draw the window! Try keeping it around for the life of
the window instead.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks mark you've been a great help, the window is now showing. it was blend.SourceConstantAlpha = 255; set to 0 i think.
but i still have some problems
im using this image,
http://mathforum.org/library/drmath/gifs/analog_clock.jpg
the white part of the image is showing the blue part is transparent.
and mouse clicks go through the window, regardless where i click on it.
|
|
|
|
|
using LWA_COLORKEY gets around that it seems, but the window comes out pixilated .
now i have to figure out how to use an alpha channel
|
|
|
|
|
Lamefif wrote: the window comes out pixilated
Because you've sized the window bigger than the bitmap??
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
To hide the white you'll need to use
UpdateLayeredWindow(hwnd, NULL, NULL, NULL, dcMem, NULL, RGB(255,255,255), 0, ULW_COLORKEY);
To use alpha blending on the entire bitmap you'd use
UpdateLayeredWindow(hwnd, NULL, NULL, NULL, dcMem, NULL, 0, &blend, LWA_ALPHA);
To use both alpha and color key, you need to use SetLayeredWindowAttributes() instead of
UpdateLayeredWindow()...
SetLayeredWindowAttributes(hwnd, RGB(255,255,255), alphavalue, LWA_COLORKEY | LWA_ALPHA);
Then you'd have to draw the bitmap yourself in response to WM_PAINT.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
im having trouble with the pixilated edge, i tried adding a png file with an alpha cannel as a resource but it came out as row data.. ups.
i want to use perpixilalpha as you can tell, whats the best way to go about this?
thanks again
|
|
|
|
|
Have you tried using CImage or the GdiPlus::Bitmap class to load the png?
Then you should be able to use the associated HBITMAP, selected into the dcMem and use
UpdateLayeredWindow() like this:
blend.BlendOp = AC_SRC_OVER;
blend.BlendFlags = 0;
blend.SourceConstantAlpha = 255;
blend.AlphaFormat = AC_SRC_ALPHA;
UpdateLayeredWindow(hwnd, NULL, NULL, NULL, dcMem, NULL, 0, &blend, LWA_ALPHA);
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|