|
Oh...Thanks guys~I will check out on the site provided...really thanks!!!
|
|
|
|
|
Hi all,
i have write an application that create a movie from series of images. but i have some problem when writing the sample to the writer for the second times. It's return with error code NS_E_INVALID_DATA (0xc00d002f).
my complete code is like below :
// Aduuuuuuh.cpp : main project file.
#include "stdafx.h"
//#include <memory.h>;
#include "resource.h"
using namespace System;
using namespace System::Drawing;
int main(array<System::String ^> ^args)
{
IWMProfileManager *manager = NULL;
IWMProfile *profile = NULL;
IWMCodecInfo *codecInfo = NULL;
IWMMediaProps *mediaProps = NULL;
IWMStreamConfig *streamConfig = NULL;
WM_MEDIA_TYPE *mediaType = NULL;
WMVIDEOINFOHEADER *infoHeader = NULL;
IWMPropertyVault *propertyVault = NULL;
IWMWriter *writer = NULL;
IWMInputMediaProps *inputProps = NULL;
HRESULT hr = S_OK;
LONG vHeight = 240;
LONG vWidth = 320;
CoInitialize(NULL);
hr = WMCreateProfileManager(&manager); THROW_EXCEPTION(hr);
hr = manager->QueryInterface(IID_IWMCodecInfo, (void**)&codecInfo); THROW_EXCEPTION(hr);
hr = codecInfo->GetCodecFormat(WMMEDIATYPE_Video, 6, 0, &streamConfig); THROW_EXCEPTION(hr);
hr = streamConfig->QueryInterface(IID_IWMMediaProps, (void**)&mediaProps); THROW_EXCEPTION(hr);
DWORD count = 0;
hr = mediaProps->GetMediaType(NULL, &count); THROW_EXCEPTION(hr);
mediaType = (WM_MEDIA_TYPE*) new BYTE[count];
hr = mediaProps->GetMediaType(mediaType, &count); THROW_EXCEPTION(hr);
infoHeader = (WMVIDEOINFOHEADER*)mediaType->pbFormat;
infoHeader->dwBitRate = 100000;
infoHeader->AvgTimePerFrame = ((LONGLONG)10000000 / (LONGLONG) 30);
infoHeader->bmiHeader.biWidth = vWidth;
infoHeader->bmiHeader.biHeight = vHeight;
infoHeader->bmiHeader.biSizeImage = vWidth * vHeight * 3;
infoHeader->rcSource.right = vWidth;
infoHeader->rcSource.bottom = vHeight;
infoHeader->rcTarget.right = vWidth;
infoHeader->rcTarget.bottom = vHeight;
mediaProps->SetMediaType(mediaType);
//delete[] mediaType;
//hr = streamConfig->QueryInterface<IWMPropertyVault>(&propertyVault);
//BOOL isVBR = FALSE;
//hr = propertyVault->SetProperty(g_wszVBREnabled, WMT_TYPE_BOOL, (BYTE*)&isVBR, sizeof(isVBR)); THROW_EXCEPTION(hr);
hr = manager->CreateEmptyProfile(WMT_VER_9_0, &profile); THROW_EXCEPTION(hr);
hr = streamConfig->SetStreamNumber(1); THROW_EXCEPTION(hr);
hr = streamConfig->SetBitrate(100000);THROW_EXCEPTION(hr);
hr = streamConfig->SetBufferWindow(3000);THROW_EXCEPTION(hr);
hr = profile->AddStream(streamConfig); THROW_EXCEPTION(hr);
CoInitialize(NULL);
hr = WMCreateWriter(NULL, &writer); THROW_EXCEPTION(hr);
hr = writer->SetProfile(profile); THROW_EXCEPTION(hr);
hr = writer->GetInputProps(0, &inputProps);THROW_EXCEPTION(hr);
count = 0;
hr = inputProps->GetMediaType(NULL, &count);THROW_EXCEPTION(hr);
mediaType = (WM_MEDIA_TYPE*) new BYTE[count];
hr = inputProps->GetMediaType(mediaType, &count); THROW_EXCEPTION(hr);
mediaType->subtype = WMMEDIASUBTYPE_VIDEOIMAGE;
hr = inputProps->SetMediaType(mediaType);THROW_EXCEPTION(hr);
infoHeader = (WMVIDEOINFOHEADER*) mediaType->pbFormat;
hr = inputProps->SetMediaType(mediaType);THROW_EXCEPTION(hr);
//delete[] mediaType;
//------------------- writing
hr = writer->SetOutputFilename(L"C:\\Pliiiis.wmv");THROW_EXCEPTION(hr);
hr = writer->BeginWriting(); THROW_EXCEPTION(hr);
#pragma region convert bitmap to byte*
Bitmap ^gambar = gcnew Bitmap("C:\\source.bmp");
array<unsigned char, 1>^ memStr = gcnew array<unsigned char, 1>(vWidth * vHeight * 3 + 54);
System::IO::MemoryStream ^ms = gcnew System::IO::MemoryStream(memStr);
gambar->Save(ms, Imaging::ImageFormat::Bmp);
BYTE* bmp = new BYTE[vWidth * vHeight * 3];
for(int i = 54; i < ((vWidth * vHeight * 3) + 54); i ++)
{
*(bmp + i - 54) = memStr[i];
}
#pragma endregion
#pragma region Sample header 1
WMT_VIDEOIMAGE_SAMPLE2 *sample = (WMT_VIDEOIMAGE_SAMPLE2*) new BYTE[sizeof(WMT_VIDEOIMAGE_SAMPLE2)];
sample->dwMagic = WMT_VIDEOIMAGE_MAGIC_NUMBER_2;
sample->dwStructSize = sizeof(WMT_VIDEOIMAGE_SAMPLE2);
sample->dwViewportWidth = vWidth;
sample->dwViewportHeight = vHeight;
sample->dwCurrImageWidth = vWidth;
sample->dwCurrImageHeight = vHeight;
sample->fCurrRegionX0 = 0;
sample->fCurrRegionY0 = 0;
sample->fCurrRegionWidth = (FLOAT)vWidth;
sample->fCurrRegionHeight = (FLOAT)vHeight;
sample->dwPrevImageWidth = vWidth;
sample->dwPrevImageHeight = vHeight;
sample->fPrevRegionX0 = 0;
sample->fPrevRegionY0 = 0;
sample->fPrevRegionWidth = (FLOAT)vWidth;
sample->fPrevRegionHeight = (FLOAT)vHeight;
sample->dwEffectType = 0;
sample->dwNumEffectParas = 0;
sample->bKeepPrevImage = FALSE;
sample->dwControlFlags = WMT_VIDEOIMAGE_SAMPLE_INPUT_FRAME;
//TODO : create blending transision here
sample->fCurrBlendCoef = 1;
sample->fPrevBlendCoef = 0;
#pragma endregion
INSSBuffer *buffer = NULL;
QWORD timeCounter = 0;
QWORD vidTime = 0;
DWORD len = vHeight * vWidth * 3;
for(int i = 0; i < 60; i ++)
{
#pragma region first photo
if(i == 0)
{
BYTE *loc = NULL;
DWORD sampleSize = sizeof(WMT_VIDEOIMAGE_SAMPLE2);
DWORD size = len + sampleSize;
hr = writer->AllocateSample(size, &buffer);THROW_EXCEPTION(hr);
DWORD bufferLength = 0;
buffer->GetBufferAndLength(&loc, &bufferLength);
errno_t err = memcpy_s(loc, sampleSize, sample, sampleSize);THROW_EXCEPTION(hr);
err = memcpy_s((loc + sampleSize), len, bmp, len);
hr = buffer->SetLength(size);
THROW_EXCEPTION(hr);
hr = writer->WriteSample(0, vidTime, 0, buffer);THROW_EXCEPTION(hr);
//delete loc;
//loc = NULL;
buffer->Release();
buffer = NULL;
}
#pragma endregion
#pragma region the next
else
{
sample->dwControlFlags = WMT_VIDEOIMAGE_SAMPLE_OUTPUT_FRAME |
WMT_VIDEOIMAGE_SAMPLE_USES_CURRENT_INPUT_FRAME;
BYTE *loc = NULL;
DWORD size = sizeof(WMT_VIDEOIMAGE_SAMPLE2);
hr = writer->AllocateSample(size, &buffer);THROW_EXCEPTION(hr);
buffer->GetBuffer(&loc);
memcpy_s(loc, size, sample, size);
hr = buffer->SetLength(size);THROW_EXCEPTION(hr);
//------------------------Error appears here with code NS_E_INVALID_DATA
hr = writer->WriteSample(0, vidTime, 0, buffer);THROW_EXCEPTION(hr);
buffer->Release();
buffer = NULL;
}
#pragma endregion
vidTime = (++timeCounter * 1000)/30;
}
hr = writer->EndWriting();THROW_EXCEPTION(hr);
return 0;
}
|
|
|
|
|
Sir,
I amd Suresh Kumar want to know the differences between the VC++ and .Net. Please send me the differences I request. I referred many books but i didn't get any information regarding this and also searched on internet in many sites
including Microsoft.
Regards,
S.Suresh Kumar
Suresh Kumar
|
|
|
|
|
http://www.codepedia.com/2/FAQ-VCDOTNET-VC6-VCDOTNET-Differences
|
|
|
|
|
Sriram Suresh wrote: I referred many books but i didn't get any information regarding this and also searched on internet in many sitesincluding Microsoft.
WHat type information are you looking for?
|
|
|
|
|
f:\installation\vc98\include\xmemory(37) : warning C4100: '_P' : unreferenced formal parameter
f:\installation\vc98\include\xmemory(68) : see reference to function template instantiation 'void __cdecl std::_Destroy(unsigned int *)' being compiled
Error.cpp
I also got this error. It seems that it caused by the include header. How can i solve this?
Thanks again.
|
|
|
|
|
That is only a warning so you don't have to fix anything. The warning says that the function std::_Destroy(unsigned int *) did not use the one parameter.
John
|
|
|
|
|
unexpected end of file while looking for precompiled header directive
i have this error when i compile my project on debug mode but when i compile it in release mode it doesn't have this problem. Please help me. i don't know how to debug this and how come the error occurs when I compile it in debug mode and not when I compile it in release mode. What probably is the cause? Does it mean that i have a missing file? I'm new to Visual C++ Programming.
|
|
|
|
|
Put this at the top of every cpp file:
#include "stdafx.h"
John
-- modified at 21:25 Friday 10th March, 2006
|
|
|
|
|
i did what you have suggested. It resulted to another error. here it is:
fatal error C1853: 'Debug/CMMITool.pch' is not a precompiled header file created with this compiler
the file which i included the stdafx.h header file is a C source file. this must have caused the other error.
|
|
|
|
|
Delete Debug/CMMITool.pch and try again. A pch file may not be used on two different versions of VC++.
John
|
|
|
|
|
delete Debug directory, and delete .clw, .opt, .NCB files.
then compile again.
libo
|
|
|
|
|
|
I am writing BHO for now, which dynamically changes the document.
I faced that thing, that if I do next (after the 'documentcomplete' event in browser)
//Code:
CComQIPtr<IHTMLElement> piSpanElement;
hr = pHtmlDocument->createElement(L"span", &piSpanElement);
BSTR innerHtml = L" <u>This is string with leading space"</u>";
//leading space is happily ignored, when I'm inserting that text:
hr = piSpanElement->put_innerHTML(innerHtml);
//Ok-ok, I beleive, it is with the good intentions
//of MSHTML, I will try to insert some text...
//I even do not put a whitespace there...
//Ok, I will try to insert some text...
//(In MSDN it is said, that InsertAdjancedText inserts plain text.
hr = piSpanElement->insertAdjacentText(L"beforeEnd",L"Some text");
//OK, text is in element, but... I needed before content, ok, mistake - I try to correct:
hr = piSpanElement->insertAdjacentText(L"afterBegin",L"!I WANNA SEE THIS TEXT IN ELEMENT before content!");
//It does return S_OK... I do not see that text, WTH!?
//I insert this element simply querying interface and
//substituting the DOM node. After that html element tortures.
May be I'm "stupido", but I cannot convert IHTMLDomNode element to the IHTMLElement. If there is any method - please tell..
then - one more...
we have "this node", reference node, and node to substitute
Substituting node is IHTMLDomNode pointer, former IHTMLDOMTextNode with text " " or any other - the result was same.
CComQIPtr<IHTMLDomNode> resultNode;
VARIANT refNode;
refNode.vt = VT_DISPATCH;
refNode.pdispVal = rNode; //reference node pointer
hr = thisNode->get_parentNode(&pNode); //parent node pointer
//OK, pNode is not null.
hr = pNode->InsertBefore(substitutingNode,refNode,&newNode);
//Why hr is EINVALIDARG???
or just simply - is there any way to insert that eaten leaded space.
Or what I do incorrectly?
|
|
|
|
|
1) You should NOT use unicode strings in place of BSTR's. Use SysAllocString() and SysFreeString(). Or better yet, use ATL::CComBSTR.
2) Use QueryInterface() to get IHTMLElement from IHTMLDOMNode. Or better yet use ATL::CComQIPtr<IHTMLElement> spIHTMLElement(piHTMLDOMNode). This calls QueryInterface() automatically.
3) You should NOT use raw VARIANT. Use VariantInit(), VariantChangeType(), and VariantClear(). Better yet, use ATL::CComVariant.
|
|
|
|
|
Problems:
QueryInterface() returns null and E_NOINTERFACE (or smth like).
So it seems to me, that the circle closed...
If somebody know, howto do that, please answer
|
|
|
|
|
Hello!
y Build an application using visual studio, but i don´t know what extra files do i need for execute de applicatión in a different machine
Sergio
|
|
|
|
|
Which version of VC++ are you using?
For most applications, they will have dependency on the C Run-time dlls.
In VC++ 2003 and earlier, those CRT dlls are dropped to system32 folder and they just need to be on the path. You can figure out the names of the dlls by using depends.exe.
In VC++ 2005, the CRT dlls are now distributed through Msms that needs to be merged into an Msi to get installed on the user's machine. You can search for VCRedist.exe on the microsoft website. Again - depends.exe should help you figure out those dlls.
gmileka
|
|
|
|
|
hi guys,
im using ReadProcessMemory to read out 4 bytes of a process. The value is a DWORD. Yesterday a friend said to that I should use a Pointer opperation to read out the memory. I read a bit about Pointer and Memory allocation but i didn´t get it working.
I tried this:
DWORD dwAddress = 0x01234567;
DWORD *dwValue = *(DWORD*)dwAddress; // got the address of dwAddress
DWORD dwValue = *(&dwAddress); // got the address ( 0x01234567 )
How can i read out the value ?
|
|
|
|
|
Is this value in the process that is doing the 'read' or is it in a different process?
If it's in the same process, then assuming that 0x0BADC0DE is the virtual address of the DWORD you want to fetch, the following code will get it:
<br />
DWORD dwAddress = 0x0BADC0DE;<br />
DWORD dwValue = * reinterpret_cast<DWORD *>( dwAddress );<br />
If you specify an invalid virtual address, you will generate an access fault at runtime. This technique is generally used only in very low-level code that does not run in a virtual memory space to access memory-mapped hardware devices. It's not something that is very useful in a Windows Application and it would generally be considered very poor programming style.
If you need to read memory in a different process, then you must use ReadProcessMemory(). Each process has it's own self-contained virtual address space. There is no way to define a simple pointer into the address space of another process.
If you are in control of the source for both processes then you could set up shared memory between the two, or possibly some other mechanism for getting the value. Can you tell us a little more about what the value represents, how often you need to read it, etc? More information might let us suggest a better method of sharing this value.
Dan
Remember kids, we're trained professionals. Don't try this at home!
|
|
|
|
|
i have an app with a login dialog box, with login button, when the button is pressed the login dialog box hides and new dialog box opens. When i click cancel in the new main dialog box, the dialog box disappears but the app is still running in the background in taskmanager. is it becuase the login dialog box is hidden and not closed or ??? how do i close the hidden dialog box if that is the problem or is it summit else?
regards
keith
void CKeithDlg::OnLogin()
{
ShowWindow(SW_HIDE);
CMainDlg Dlg;
Dlg.DoModal();
}
========================================
void CMainDlg::OnCancel()
{
CDialog::OnCancel();
}
|
|
|
|
|
CKeithDlg hides itself but doesn't close itself, so the app is running with a hidden main window. IIUC you want the app to exit after CMainDlg closes, right? At the end of CKeithDlg::OnLogin() , add EndDialog(IDOK);
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
|
void CKeithDlg::OnLogin()
{
ShowWindow(SW_HIDE);
CMainDlg Dlg;
Dlg.DoModal();
EndDialog(IDOK);
}
Manish Rastogi
|
|
|
|
|
Is it true that if GetActiveView() returns NULL then Our Application Does not Support Doc/view.or how can know
or how can check that Our Appliction Supports Doc/View
pls help me.
Fly Like An Eagle With MIGHTY POWER.
|
|
|
|
|