|
Thanks for that link, I just discovered Natural Docs. It was created with exactly what I had in mind, generate help files from human readable in code comments!
Doxygen comments where cryptic to read in code with all its //! \bried /** */ stuff going on but Natural Docs has a very natural layout. I changed a few wordings in my existing comments and I got nice clean output. Also it has a proper walk through which is nice.
I recommend you guys check it out.
http://www.naturaldocs.org/[^]
|
|
|
|
|
Hi,
I have bitmap with a white background and a yellow arrow I would like to convert the background to gray
So I have the following code
CBitmap *bm = new CBitmap;
bm->LoadBitmap((UINT) IDD_BITMAP);
CDC *cdcwindow = this->GetDC();
CDC cdcimage;
cdcimage.CreateCompatibleDC(cdcwindow);
CBitmap *oldbit = cdcimage.SelectObject(bm);
cdcimage1.CreateCompatibleDC(&cdcimage);
cdcimage1.SelectObject(bm);
cdctrans.CreateCompatible(&cdcimage);
CBitmap bmask;
bmask.CreateBitmap(bm_struct.bmWidth,bm_struct.bmHeight,1,1,NULL);
cdctrans.SelectObject(&bmask);
COLORREF clr = cdcimage1.GetPixel(0,0);
cdcimage1.SetBkColor(clr);
cdctrans.BitBlt(0,0,bm_struct.bmWidth,bm_struct.bmHeight,&cdcimage1,0,0,SRCCOPY);
cdcimage.SetBkColor(RGB(125,125,125));
cdcimage.SetTextColor(RGB(255,255,0));
cdcimage.BitBlt(0,0,bm_struct.bmWidth,bm_struct.bmHeight,&cdctrans,0,0,SRCCOPY);
stgm.hBitmap = (HBITMAP)*bm; get bit map handle
later on when I use the bit map handle in "OLE" it sets the bitmap as all yellow
|
|
|
|
|
Would not CDC::FloodFill() be easier to use?
Select your image into a device context, FloodFill it, unselect it from DC.
|
|
|
|
|
unchaged still has white background
here is my code
CBitmap *bm = new CBitmap;
bm->LoadBitmap((UINT) IDD_BITMAP);
CDC *cdcwindow = this->GetDC();
CDC cdcimage;
cdcimage.CreateCompatibleDC(cdcwindow);
CBitmap *oldbit = cdcimage.SelectObject(bm);
cdcimage.SetDCBrushColor(RGB(125,125,125));
COLORREF cr = cdcimage.GetPixel(0,0);
cdcimage.FloodFill(0,0,cr);
bm = cdcimage.SelectObject(oldbit);
later stgm.hBitmap = (HBITMAP)*bm;
|
|
|
|
|
You are filling it with the color you had at (0, 0). That will change nothing.
The color (last arg in FloodFill) should be the new color value. As far as I see, you dont need the GetPixel() call at all.
|
|
|
|
|
Thought it filled it with the Brush okay thankx
|
|
|
|
|
How does it know How much to fill I only want to fill the BackGround
|
|
|
|
|
It will fill every pixel adjacent to the given pixel that has the same original color recursively. It will not touch pixels containing other colors, and not groups of pixels not 'connected' to the original 'pixel group'.
|
|
|
|
|
Thakx I appreciate your help
|
|
|
|
|
Filled the entire bitmap all white
from the MSDN doc says that area will be filled with the current brush till the color boudry
I would think boudry is the RGB of the yellow arrow
Here is the code
CBitmap *bm = new CBitmap;
bm->LoadBitmap((UINT) IDD_BITMAP);
CDC *cdcwindow = this->GetDC();
CDC cdcimage;
cdcimage.CreateCompatibleDC(cdcwindow);
CBitmap *oldbit = cdcimage.SelectObject(bm);
cdcimage.SetDCBrushColor(RGB(125,125,125));
clr = RGB(125,125,125);
cdcimage.FloodFill(0,0,clr);
bm = cdcimage.SelectObject(oldbit);
MFC Library Reference
CDC::FloodFill
Fills an area of the display surface with the current brush.
Copy
BOOL FloodFill(
int x,
int y,
COLORREF crColor
);
Parameters
x
Specifies the logical x-coordinate of the point where filling begins.
y
Specifies the logical y-coordinate of the point where filling begins.
crColor
Specifies the color of the boundary.
reading the doc on MSDN for Flood fill says it will fill the Color with the Current
brush
|
|
|
|
|
ForNow wrote: reading the doc on MSDN for Flood fill says it will fill the Color with the Current brush
The brush they speak of is the pattern. In your case you want a solid brush (filling every pixel) which is the default brush of a DC. You don't need the SetDCBrushColor call for FloodFill to work.
|
|
|
|
|
commentend out the SetDCBrushColor still getting a all white picture I am going to
CBitMap::GetBitmapBits and look at memory to see whats the bitmap looks like GetPixel just got the first byte
there is something strange here
thankx again
|
|
|
|
|
Hello,
I'm trying to write a asynchronous server that accepts (non-blocking) clients receives data from the client and reponds.
I have managed to write and get it to work a single threaded server blocking & a multithreaded server that blocks also. But now I have to make one that doesn't block and only a single thread.
I know that I setup the socket to async mode with ioctlsocket(). but after that how do I do a non-blocking
listen() & accept(). Also I have been reading that I need to use select() for when a client needs to read, write, etc...
I have been staring at the following example at CP (Code Project) at Programming Windows TCP Sockets in C++ for the Beginner[^]
which is a great example, but mine is console based. So I understand that code for the most part. But since I'm not use MFC with it just C or C++ it is a little a different and I could really use some help. any help will be greatly appreciate, and ty in advance.
Gemini S....
|
|
|
|
|
This[^] isn't a bad example of how to use select() in a traditional C application. There's only one non-portable thing in there as far as I can tell and that could be easily replaced.
Hope that helps,
Cheers,
Ash
|
|
|
|
|
Hi, can you tell if you have a specific question or rather want to be pointed to some examples?
/M
|
|
|
|
|
If I could get a specific example of how to use an asynchronous socket ( I know how to create), but how do I use it to get/send information to the client and it has to be non-blocking. That would help greatly thank you.
Gemini S.
|
|
|
|
|
Here is the theory: An asynchronous server will notify you when something interesting happens, e.g. about a new incoming connection, when data could be sent, or data could be received on a socket. So you do not have to to start a new thread for every incoming client connection. Instead you can handle many sockets within a single thread context, on Windows for example WSAAsyncSelect[^] will notify you if any of your socket status changes (see FD_READ and FD_WRITE ).
Here are two practical examples with source code:
- Programming Windows TCP Sockets in C++ for the Beginner[^]
- CAsyncSocketEx - Replacement for CAsyncSocket with proxy and SSL support[^]
Btw, there are also a couple of C++ network libraries with asynchronous sockets. You sounded like you wanted to implement it on you own, so just wanted to let you know that there are working solutions.
Happy coding
/M
|
|
|
|
|
nice kicka$$ that is what I thought needed to hear it to have it clear it up now I just need to get the syntax down and learn how to implement it and that will work. Thanks for the help /M
Gemini S...
|
|
|
|
|
Hi,
With select you check if you can write to a socket or read data from it. But there are some things about performance...
If you target Linux... it is best to use poll.
If you can, group many sockets in one select call (usually max is 64 sockets).
It you target Win2000 or later... try advanced io completion ports. The best thing.
Best regards,
Mauro H. Leggieri
P.D.: Check setsockopt to make a socket non-blocking.
|
|
|
|
|
thaanks alot this is helpful too... Mauro preciate the help.
Gemini S...
|
|
|
|
|
Hi everyone
I've a project where i have webBrowser control to display web page contents. When a user wants to save pictures(image(s)) to hard drive instead of he/she right clicking the picture(image) and clicking 'Save Picture As...', I have a button the user click that button and programatically saves the picture(image).
I googled, post my question at MSDN, here, for a year and half no luck. I found some codes but they only save the portion of picture (image) which is displayed by screen. When ever the picture(image) is larger than the computer's physical screen size, I endes up saving partial picture(image).
This forum seems more live than any other forum I know. Please help. Help.
|
|
|
|
|
By image, do you mean the rendered html page as an image, or individual images on the page (img tags)?
I assume the first since the latter is not very difficult.
Have you tried IHTMLElementRender.DrawToDC on the root element, and supplying your own DC with a selected bitmap?
Edit: maybe it was the latter case anyway. I looked to see if there was an easy way, but it seems you cannot easily get a handle to the actual bitmap of the image. But you could still use IHTMLElementRender.DrawToDC on the img element itself I suppose.
See also:
Capture an HTML document as an image[^]
http://www.nathanm.com/ihtmlelementrender-opacity/[^]
home
modified on Sunday, June 6, 2010 4:21 PM
|
|
|
|
|
Actually, I'm tring to save individual images in a web page. The problem is if any individual image is larger than the physical size of my computr's screen, IHTMLElementRender::DrawToDC() only draws to the size of my computer screen size.
So I ended up with partial image. Do you konw how to save an entire image?
|
|
|
|
|
|
Ive tried to capture a particular area of the screen to the memory dc.
CDC dcDisplay, dcMem;
CBitmap btmDisplay, *pbtmOld;
int nWidth = GetSystemMetrics( SM_CXSCREEN );
int nHeight = GetSystemMetrics( SM_CYSCREEN );
dcDisplay.CreateDCW( (LPCTSTR)"DISPLAY", NULL, NULL, NULL );
btmDisplay.CreateCompatibleBitmap( &dcDisplay, nWidth, nHeight );
dcMem.CreateCompatibleDC( &dcDisplay );
pbtmOld = dcMem.SelectObject( &btmDisplay );
ClientToScreen( &rc );
dcMem.BitBlt( 0, 0, rc.Width(), rc.Height(), &dcDisplay, rc.left, rc.top, SRCCOPY );
dcMem.SelectObject( pbtmOld );
Now i wanna paint this bitmap to the dialog dc. But i dunno how to write the codes. Can anyone help?
PS: the above codes may have faults
|
|
|
|