|
Ok so i have put my bitmaps in DIB's and placed them in seperate dc's but what function do i use now instaed of getPixel()?
|
|
|
|
|
There is no specific function. If you have downloaded and integrated one of the DIB wrapper classes, derive a new class from it and add a new member.
Lets say you are scanning a web-cam image and you want to get every 10th pixel. In your new function, get the images-bits from the base class which is just one big array of pixels. Calculate the bitmaps paramaters, then in a loop calculate which pixels you want ( y * bitmapwidth_inbytes + x ) and read them from the array.
Just remember, with a DIB, the pixels are not always a 32 value like you get back from GetPixel. They could be:
1 Bits ( 0 == black, 1 == white )
4 Bits ( 1 byte with two indexes into the color table )
8 Bits ( an array of bytes each representing an index into the color table )
16 Bits ( an array of WORD each representing an index into the color table )
24 Bits ( an array of DWORD look on MSDN for RGBQUAD )
32 Bits ( an array of DWORD look on MSDN for RGBQUAD )
64 Bits ( only windows vista supports these I think )
By far, the easiest to deal with are 24 and 32 bit images, all of the others use a color table. If you need the actual COLORREF value, then you must calculate it from whatever value you get from the array.
|
|
|
|
|
Hi !!
I have one main method and now i want to call this main method in another method..
for example...
void NORMAL()
{
}
void MAJOR ()
{
Here i want to call void NORMAL() method
}
In void MAJOR () method, I want to call void NORMAL ()..
how can i call it ??
Both are in same .cpp file..n i have no class.
Thanking you..
Shah
|
|
|
|
|
what about :
void MAJOR()
{
NORMAL();
}
This is rrrreeeaaallllyyyy basic stuff, or I did not understood the question.
|
|
|
|
|
oppsss..Really really sorry.. i have Problem in my code..
|
|
|
|
|
and what might be the problem ?
|
|
|
|
|
void MAJOR ()
{
NORMAL();
}
Come on, this is really beginner stuff! Aren't you calling your MAJOR() function from somewhere else? Where's it getting called from?
|
|
|
|
|
oppsss..Really sorry..Problem in my code..
|
|
|
|
|
Is this a specifc question or simple question?
|
|
|
|
|
Heee heee..This is not Specific nor Simple.. but its stupid question..Actually i tried same code but it was not working.. problem was in my code but in method.
|
|
|
|
|
Not problem,one thing is important that you could find your problem Its good;)
|
|
|
|
|
I'm getting a bad value when doing a drag-right-click ( doing a selection with the right mouse button) in a CTreeCtrl.
This is the callback for the NM_RCLICK notification.
void CAboutDlg::OnTreeRclick( NMHDR* pNMHDR, LRESULT* pResult )
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
HTREEITEM hSelItem = pNMTreeView->itemNew.hItem;
if ( hSelItem == NULL )
{
return;
}
}
Sometimes, the hSelItem tree item is not a valid item ( for example : 0x0000008d ) which is not valid.
I alse tried this where ptDrag is supposed to be the "structure that contains the client coordinates of the mouse at the time the event occurred that caused the notification message to be sent. (from MSDN) "
CPoint point( pNMTreeView->ptDrag );
UINT uHF;
HTREEITEM hItem;
hItem = m_Tree.HitTest( point, &uHF );
But the point is mostly invalid.
I also use which works, but seems not to be the right way to do it.
UINT uHF;
HTREEITEM hItem;
CPoint point;
GetCursorPos( &point );
m_Tree.ScreenToClient( &point );
hItem = m_Tree.HitTest( point, &uHF );
Thanks for you help and/or suggestions.
Max.
|
|
|
|
|
Some of the tree notifications don't set the itemNew element in the NM_TREEVIEW structure. As a result, it can be filled with random garbage.
Another thing to remember is that the right click notification happens whenever you right click on the tree control. If you're doing that over an area that doesn't include an item, you'll need to detect that.
IIRC, the last time I did this kind of stuff with a tree control, I ended up with a similar approach.
Sorry I'm not giving you more definite answers here. I'm working from memory, and don't have access to the code where I was dealing with this stuff.
Software Zen: delete this;
|
|
|
|
|
I tried to export a static member in one of my classes.
All other methods and operators of the same class can be successfully exported and then linked by another program excepte all static data member(declared as public static const in .hpp and implemented in .cpp, according to msdn guild on the dllexport part, it should work). I wonder why?
I am not the 1st one who's suffering from this, I did a simple research with google, some other guys also had this kind of problem and posted it on the web but never got a response.
Hopefully some one here could help me out, thanks.
|
|
|
|
|
Btw, by "unable to export" I mean the program can be compiled but get a link error generated.
|
|
|
|
|
Hello,
For a CDBVariant MFC class, how do I assign value to an object of type CDBVariant?
If
CDBVariant V;
V.m_dwtype = DBVT_SHORT;
V.m_iVal = 5;
Is this the right way to do ?
Priya
|
|
|
|
|
Does anyone know what happens when you have a socket bound to INADDR_ANY and then have a second socket (both TCP or both UDP sockets) bound to a specific address?
I am trying to add something to an existing program that has a TCP socket bound to INADDR_ANY. I need to add a TCP socket that listens to 127.5.0.1 (within the same executable). Will messages sent to 127.5.0.1 be handled by my new socket or will everything go through the existing socket bound to INADDR_ANY?
I guess I can check the address on the existing socket and handle the messages based on that but I'd still like to understand how this works.
Thanks,
Dave
|
|
|
|
|
INADDR_ANY indicates that the caller to bind() doesn't care what address the socket is bound
to. Typically this is used on client ends of TCP connections to let the system select an
unused port.
If you want to listen on a specific address/port then you have to bind to that specific
address.
Dave_ wrote: I need to add a TCP socket that listens to
What do you mean by "listens to"? This is very different on TCP and UDP.
|
|
|
|
|
When I use the listen() call, which socket (or will it be both?) will get the attempt to connect from the client? If I try to recv(), will the socket that is bound to the specific address get the data or will there be a race condition (first socket to read gets the data)?
|
|
|
|
|
A socket address consists of an address and a port.
listen() would be used on a connection-oriented protocol (like TCP) socket. You need to
create a socket to listen on and bind it to a specific address to listen on. Once a socket is
placed in the listen state you don't recv data on it. You receive connection attempts on it.
Accepting a connection creates a new, connected socket which will be used for send/recv of
data.
For UDP, which is connectionless, you'd create a socket and bind it to an address. Then you
can either use connect to set a default destination address on it and/or use sendto/recvfrom to
send and receive datagrams to/from multiple destination addresses.
Only one socket per protocol can be bound to a specific address so there's never a race
condition.
|
|
|
|
|
Not sure what your trying to do.
Normally you use INADDR_ANY to bind the socket to the IP address of your PC, which normally only has one IP address.
If you want multiple server sockets, you normally use INADDR_ANY for the IP and a different address for the port of each server. For example
Server 1
ServerAddress.sin_family = AF_INET;
ServerAddress.sin_addr.s_addr = INADDR_ANY;
ServerAddress.sin_port = htons((u_short)27015);
if(bind(ServerSocket, (struct sockaddr*)&ServerAddress, sizeof(ServerAddress)) != 0)
.........
Server 2
ServerAddress.sin_family = AF_INET;
ServerAddress.sin_addr.s_addr = INADDR_ANY;
ServerAddress.sin_port = htons((u_short)27016);
if(bind(ServerSocket, (struct sockaddr*)&ServerAddress, sizeof(ServerAddress)) != 0)
..........
Then the clients will send to port 27015 for server 1 and port 27016 for server 2. You
can definitely substitute
service.sin_addr.s_addr = inet_addr("127.5.0.1");
if you want to specify and exact IP address
|
|
|
|
|
I have compiled VC project which was created using VC compiler of version older than 6.0. There are some C files which if I change extension to .cpp many errors are happening. So I would like to keep those files .c and I want to read numbers from .CSV file and store in array.
Is it possible to read CSV file from .C file?
Any ideas would be greatly appreciated.
Thanks & Regards,
Suman
|
|
|
|
|
rp_suman wrote: Is it possible to read CSV file from .C file?
Certainly.
Which part are you having trouble with?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I want to read the numbers in csv file, cell by cell and assign it to the int array variable. The number count is not fixed. Which function is good for doing this.
Thanks & Regards,
Suman
|
|
|
|
|
rp_suman wrote: ...the numbers in csv file, cell by cell...
Files don't have cells.
There are several ways to do this, some better than others. One such way, although not very bullet-proof, is:
int num[25][3];
int x = 0;
FILE *pFile = fopen();
while (! feof(pFile))
{
fscanf(pFile, "%d,%d,%d\n", &num[x][0], &num[x][1], &num[x][2]);
x++;
} You can quickly see how this would not work too well if the file size changed. There are other solutions to address this, however.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|