|
Can you post your error message.
Sudhir Kumar
|
|
|
|
|
Dude, please see before posting! you might be get flamed down in this forum, if you are not careful!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
C2061 syntax error, something about using enumerated types in function arguments but I'm not sure I fully understand it. Sorry for leaving that out.
|
|
|
|
|
And I suppose I should mention, I have 2 projects on the same machine, both of which use this file, and are MFC apps (dialog based) - only 1 gives me this error..
|
|
|
|
|
bulg wrote: but one of them gives me a syntax error...
Compiler is not able to find a declaration for class CEvent , make sure you have the necessary header files included or forward declare CEvent if you are including necessary header files in a .cpp file. As a good practice do include necessary headers(afxmt.h) in a header file.
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Nibu babu thomas wrote: As a good practice do include necessary headers(afxmt.h) in a header file.
Good Practice ???
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
ThatsAlok wrote: Good Practice ??? [Smile]
One of our company's coding standards mentions this. The reason being, so that the users of your library don't have to keep including necessary header files to work with your library. I do try to follow this hence suggested!
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Hai,
please don't mind, i am just kiddin, we do include afxmt.h file, but in stdafx.h, instead of any single header files.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
ThatsAlok wrote: please don't mind, i am just kiddin,
Not at all
ThatsAlok wrote: we do include afxmt.h file, but in stdafx.h,
Me too since it doesn't change frequently, but if these classes are appearing in public interface functions I would include them to avoid having users include them just for the sake of using my function or may be just forward declare.
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Hi there,
I am programming in fields using C++ for a security extension header for subnetwork data units. One of the fields is the MAC (message authentication code) field which I am hoping to implement with HMAC-SHA-1-96.
I have found one or two good examples of implementing the HMAC-SHA algorithm class to produce a digest for some data.
I am also looking for example code that shows the receiver processing. I.e how the receiver also calculates its digest on the data and compares this to the digest sent to it by the sender...and then produces an error or discards the packets if the digests dont match.
Is there any open source code examples of this that I could use?
Thanks!
|
|
|
|
|
From my webcam i get the videobuffer through a callback function.
I convert this array into a bitmap and display it on my dialog.
So far so good. With the mouse i can draw a rubberband over this
video. no i want to copy the marked area out of the buffer.
#define RGB 3
for(int iLine = 0; iLine < 480; iLine++)
{
for(int iElement = 0; iElement < 640 * RGB; iElement++)
{
m_pBuffer[iLine * 640 * RGB + iElement] = pHdr->lpData[iLine * 640 * RGB + iElement];
}
}
So far so good, that works. And could do this also with memcpy, I know.
For instance I want to copy an area that is 300 * 200 pixels from the origin,
means 0,0 ; 300,200. So the code above looks like this
#define RGB 3
for(int iLine = 0; iLine < 200; iLine++)
{
for(int iElement = 0; iElement < 300 * RGB; iElement++)
{
m_pBuffer[iLine * 300 * RGB + iElement] = pHdr->lpData[iLine * 640 * RGB + iElement];
}
}
Well this should copy the correct bytes.
In my dialog i create bitmaps with a method and then set the bits with SetDiBits(...)
When I do copy the whole area (640 * 480) it works, the created bitmap is correct.
When i copy an area thats 640 pixels width and some lines long, it also works.
But when i copy an area thats smaller than 640 pixels it doesnt work. the created bitmap then is
pure chaos.
Thats what i do
void CDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
m_AreaRect.SetRect(m_RectStart.x,m_RectStart.y,point.x,point.y);
CPoint Begin,End, Offset;
Begin.SetPoint(m_AreaRect.TopLeft().x,m_AreaRect.TopLeft().y);
End.SetPoint(m_AreaRect.BottomRight().x,m_AreaRect.BottomRight().y);
Offset.SetPoint(m_LivePosition.TopLeft().x,m_LivePosition.TopLeft().y);
Begin -= Offset;
End -= Offset;
m_RectWithOffset.SetRect(Begin.x,Begin.y,End.x,End.y);
Width = m_RectWithOffset.Width();
Height = m_RectWithOffset.Height();
m_MarkBitmapinfo.bmiHeader.biBitCount = 24;
m_MarkBitmapinfo.bmiHeader.biWidth = Width;
m_MarkBitmapinfo.bmiHeader.biHeight = Height;
m_MarkBitmapinfo.bmiHeader.biPlanes = 1;
m_MarkBitmapinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
m_MarkBitmapinfo.bmiHeader.biSizeImage = Width * Height * 3; m_MarkBitmapinfo.bmiHeader.biCompression = BI_RGB;
CClientDC dc(this);
m_HBitmapMark = CreateDDBFromPixel(dc.m_hDC,Width,Height,24,NULL);
m_ImgProc.CopyData(Begin,End);
}
The CreateDDBFromPixel method
CreateDDBFromPixel( HDC hDC, UINT uWidth, UINT uHeight, UINT uBitsPerPixel, LPVOID pBits )
{
HBITMAP HBitmap = NULL;
if ( !uWidth || !uHeight || !uBitsPerPixel )
{
return HBitmap;
}
LONG lBmpSize = uWidth * uHeight * uBitsPerPixel / 8;
BITMAPINFO bmpInfo = { 0 };
bmpInfo.bmiHeader.biBitCount = uBitsPerPixel;
bmpInfo.bmiHeader.biHeight = uHeight;
bmpInfo.bmiHeader.biWidth = uWidth;
bmpInfo.bmiHeader.biPlanes = 1;
bmpInfo.bmiHeader.biSizeImage = uWidth * uHeight * (uBitsPerPixel / 8);
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmpInfo.bmiHeader.biCompression = BI_RGB;
UINT * pPixels = NULL;
HBitmap = CreateDIBitmap(hDC,(BITMAPINFOHEADER*)&bmpInfo.bmiHeader,
0,pBits,(BITMAPINFO*)&bmpInfo,DIB_RGB_COLORS);
if (!HBitmap)
{
return HBitmap;
}
return HBitmap;
}
As i mentioned above, it works when i keep the width at 640pixels.
But if i change the width it doesnt work. When I've marked an area
on my dialog, i get the rect, compute the offset, create a bitmapinfoheader according to the new
information like width height imagesize and so on. but it wont work.
I can see something but its chaos. sometimes it looks like an interlaced video
sometimes its jsut a chaos of colors.
greetings,
cmos
|
|
|
|
|
do you need to include a BITMAPFILEHEADER?
you made sure m_pBuffer is UCHAR or BYTE or something (8 bit image) or a short* for 16 bit image, etc.?
how about trying to grab the lines backwards (and as lines, instead of bytes)?
<br />
for iLine=LastRow-1,iLine>=FirstRow,iLine--){<br />
line = m_pBuffer+iLine*Width+FirstCol;<br />
}<br />
.. I know that sounds silly but my bitmap storing alg. is written so that I grab the bits starting from the last row, so maybe it'll work
|
|
|
|
|
Thank you, I use the BITMAPINFO that also contains the BITMAPINFOHEADER
"m_MarkBitmapinfo.bmiHeader"
It's kinda strange. For my live video i "precreate" a HBITMAP variable.
m_HBitmap = CreateDDBFromPixel(..x,y,bpp...);
Guess, after that memory has been allocated somewhere.
Then i can use SetDiBits(....)
For Testing i fixed the size of the rubberband and set it to
(0,0); (200,200). Means, that i have to copy from origin 200 bytes per line.
I will check out ur suggestions.
I cant explain myself why its not working.
In the same way I create my live video for my dialog.
In my Dialog constructor i allocate memory for my livevideo bitmap
m_HBitmap = CreateDDBFromPixel(...).
I get the videobuffer and in the OnPaint i draw the captures image ( video)
::SetDIBits(NULL,m_HBitmap,0,480,pBuffer,&m_Bitmapinfo,DIB_RGB_COLORS);
CBitmap* pBitmap = CBitmap::FromHandle(m_HBitmapLive);
CDC cdc;
cdc.CreateCompatibleDC(&dc);
CBitmap* pOldBitmap = cdc.SelectObject(pBitmap);
dc.BitBlt(m_LivePosition.TopLeft().x,m_LivePosition.TopLeft().y,m_LivePosition.Width(),m_LivePosition.Height(),&cdc,0,0,SRCCOPY);
cdc.SelectObject(pOldBitmap);
ReleaseDC(&cdc);
cdc.DeleteDC();
So, when i mark an area on this live video, copy the bits and create the image and set the bits on the same way i do for my live video, why it does not work ???
It's the same, except that it's small in resolution. I set the BITMAPINFOHEADER according to this smaller esolution and so on. Even if i had copied the wrong bits the created image would have contained bytes of an other area. But very often the pictures are pure chaos.
cmos
|
|
|
|
|
Did you ever figure this out?
|
|
|
|
|
"Did you ever figure this out? "
What ?
By the way, can anybody tell me what is the byteorder in the
VIDEOHDR buffer (lpData).
My Pictures are not upside down. But if i copy
240 lines instead of 480 lines, the upper half of my pictures
isnt there. For me it looks like, the line are stored buttom up in the
bytearray.
im totally confused with this.
|
|
|
|
|
|
hi
i have created adialog based application where each of them call the other using DoModal().
my question is : if Dialog A is in some position on the screen and then called Dialog B...i want for Dialog B to take the same exactly position as Dialog A .(to be on top of it )...
how can i do that??
thanks
|
|
|
|
|
you want to..
<br />
RECT rect;<br />
CWhateverDlg nextDlg;<br />
...<br />
GetWindowRect(&rect);<br />
nextDlg.SetWindowPos(...) <br />
<br />
and then maybe you'll have to..
<br />
nextDlg.RedrawWindow(&rect,NULL,RDW_UPDATENOW);<br />
this is in the InitDialog function of one of your Dlg's.
modified on Tuesday, June 3, 2008 7:53 PM
|
|
|
|
|
I am having trouble with gethostname(). The code compiles correctly but the function returns an unknown error. I have compiled on VC6 and .Net2005 platforms. While in VC6, the buffer remains empty, in .Net2005, it gives me unknown error. Why does this occur?
char myname[256];
memset((void*)myname,0,sizeof(myname);
if(!gethostname(myname, sizeof(myname)))
{
int _temp = WSAGetLastError();
if(_temp == WSAEFAULT)
MessageBox(NULL,"Socket creation failed; Attempt to get host name failed; WSAEFAULT ","Lamia",MB_OK);/* who are we? */
if(_temp == WSANOTINITIALISED)
MessageBox(NULL,"Socket creation failed; Attempt to get host name failed; WSANOTINITIALISED ","Lamia",MB_OK);
if(_temp == WSAENETDOWN)
MessageBox(NULL,"Socket creation failed; Attempt to get host name failed; WSAENETDOWN ","Lamia",MB_OK);
if(_temp == WSAEINPROGRESS)
MessageBox(NULL,"Socket creation failed; Attempt to get host name failed; WSAEINPROGRESS ","Lamia",MB_OK);
else
MessageBox(NULL,"Socket creation failed; Attempt to get host name failed; error unknown","Lamia",MB_OK);
}
|
|
|
|
|
That is because there is no error!! You should look carefully at the value retuned by gethostname. From MSDN - "If no error occurs, gethostname returns zero. Otherwise, it returns SOCKET_ERROR and a specific error code can be retrieved by calling WSAGetLastError". So you should not use if(!gethostname()) it will go into if when function is successful.
-Saurabh
|
|
|
|
|
Did you called WSAStartup() ? See the code block.
WORD wVersionRequested;
wVersionRequested = MAKEWORD( 2, 2 );
WSADATA wsaData;
int err = WSAStartup( wVersionRequested, &wsaData );
koumodaki wrote: char myname[256];
memset((void*)myname,0,sizeof(myname);
BTW, one more suggestion, Instead of using memset, you can directly initialize the array. For instance,
char myname[256] = { 0 };
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
The Problem is only with the intialization of WINSOCK.
Sudhir Kumar
|
|
|
|
|
|
Hi,
In my application LoadString works fine for English resource and fails for Japanese resource.
Could some one give me some info regarding this?
Thanks.
|
|
|
|
|
Member 1003415 wrote: ...fails for Japanese resource.
Have you tried calling GetLastError() to find out why?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|