|
I deal with grayscale images which i convert to 32bit bitmaps to display...
I use CreateCompatibleBitmap () to create bitmap and bitblt () to display bitmap. But if i change the system display settings to other than 32 bit colors i get distorted images displayed
I use following code:
int k = 0;
for (int i = 0; i < bm_info.bmWidth * bm_info.bmHeight; i++)
{
tbmp [k++] = bmp[i];
tbmp [k++] = bmp[i];
tbmp [k++] = bmp[i];
tbmp [k++] = 0;
}
CDC pMemDC, *pDC;
CBitmap *pBitmap = new CBitmap;
BOOL res;
pDC = GetDC();
res = pBitmap->CreateCompatibleBitmap (pDC,bm_info.bmWidth,bm_info.bmHeight);
if (res > 0)
{
pBitmap->SetBitmapBits ( bm_info.bmWidth * bm_info.bmHeight*4,
(unsigned char *)tbmp );
pMemDC.CreateCompatibleDC ( pDC );
pMemDC.SelectObject ( pBitmap );
pDC->BitBlt ( 300 ,15 , bm_info.bmWidth,bm_info.bmHeight ,
&pMemDC ,0,0 ,SRCCOPY );
}
all help appreciated... ( sample code is more appreciated )
Sharath
|
|
|
|
|
Take a look in the site, there is articles to explain it.
If you want independant bitmaps, you should look for info about all this:
<br />
BITMAP bm;<br />
BITMAPINFOHEADER bmInfo;<br />
LPBITMAPINFOHEADER lpBmInfo;<br />
HANDLE hDIB;<br />
HDC hDC;<br />
HPALETTE hPal;<br />
because is needed to transform from one to the other
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Also, you may want to read about palettes and
device-independent-bitmap color tables.
Up-sampling an image to 4 times it's original size just to
display it is....well...kind of a waste of resources.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
But How do I Display grayscale Image... without up-sampling, i need to specify all RGB values to display ( I dont know to wat extent im right)
|
|
|
|
|
I don't remember it correctly, but I know there is a formule that converts from RGB to Grey scaled values. I have seen it in forum, but not shure if here on in "algorithms".
The fact is that you can go through like in a matrix (two "for"s) your image asking for the individual pixels, use GetRGB, apply the formule and then set the new grayed value to the pixel.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
actually wat i get is grayscale image, which i need to display using MFC, and with my little knowledge on MFC, it was takin only RGB values... for the display, u could see that in the code im using.... ,to put my question more specifically wat should i do to display my pixel ... which is only 8bits and i need 24 bit ( which is wat i do in my code).... which was displayin the image but when i change my system setting the display was goin for a toss.... thats the reason i wanted to make it deviceindependent... I hope i have put my question right this time... and thx for the help ( M.D.V)
|
|
|
|
|
Take a look to this link[^]
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Sharath Jagannath wrote: But How do I Display grayscale Image... without up-sampling
Your example was 8-bit grayscale, right? If you make a DIB with that data,
the DIB's color table should have 256 shades of gray, corresponding to the 256
possible pixel values. When you draw the bitmap to a 16,24,or 32-bitperpixel
display, the bitmap pixels will be mapped through the color table and the
resulting RGB value from the table will be drawn on the screen.
You only need to resample if you need to downsample, like to a palette based
video mode. These days, that is rare.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi frnds,
I'm writing an automation application...in that i need to take screenshots of some child windows and of others which are not child windows of a 3rd party application...
For doing this i want to know when that 3rd party app pops up the child window so that i can get the handle and take the screen shot...for this i need to know when the application sends the message to the system that the child window is created...
for doing this i need to track all the messages coming in and going out of the application... since its a 3rd party app i cannot use spy++
Can you guys bail me out of this...
|
|
|
|
|
You may need two things which you can look up on CP and elsewhere. DLL injection and Global Message Hooks. With these techniques you'll be able to intercept all the messages in an application before the application itself even knows about them.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
I hav an idea tht it can be done with Global Message Hooks...but dont how to go about it... because i dont know what messages the application is sending or receivin... is there any way to do that...
|
|
|
|
|
A Global Message Hook will get you all the Windows Messages in the process. How you filter them is up to you. The last time I did this I was adding my own Dll to the Microsoft Management Console and intercepting the Windows messages it uses internally to redraw its controls. It was 5 years ago and I don't have the code I'm afraid.
Any other kind of messaging is going to be much more tricky and require some other techniques. I'm not sure what you're trying to achieve?
With Dll injection you can, in theory at least, intercept WinSock messaging and create a COM interception framework.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
I have an application which displays its child windows one after other at random(i mean it does not have a specific time interval for that). The contro l doesnot return untill it finishes displayin all the windows... I want to capture the screen shots of the windows.. for that i have created a new thread to write the capture code... for now what im doin is for every 2 sec i get the foreground window and capturing it.
It has foll disadvantages:
1. The time i.e 2 sec which im waiting is not constant..so it may capture the same window or skip any window if it appers fast.
2. I cannot navigate from the window since by navigating the foreground window captures the window which i have opened...
As an alternative wht i intend to do is:
When ever the child window appears the focus is shifted from the main window to the child window. So i want to interpret all the messages of the message queue and whenever a WM_ACTIVATE message happens to be present i will read it and if it's hwnd matches with my app then i will capture it...
For this i need to read the messages of the queue and since im new to this field i donno howe to go about it.
|
|
|
|
|
Your approach sounds OK, message hooking will give you what you want. Spy++ can get you any window handles you need as a one off and remember you can also monitor the creation of the child windows to get handles and such. I'm afraid I don't have any more details, you'll need to break out the MS Samples and experiment to find out how to get what you want. Good luck.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
|
Hai,
I having an XML FIle , From this i am Passing port numbers to start a server on. Now the thing is 3 different port numbers i am passing..based on the 1st port the server is getting started...and waiting for clients incoming connections....
Now i want to run the 2nd server at the same console...and also ..the 3rd and so on...
How to do this...
Born to win...!
|
|
|
|
|
It sounds like you need a stub, launcher, application. Look up the docs on the CreateProcess API and have a look at the stuff on inheriting Console handles into child processes. A general launcher app is a useful thing anyway.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
hai,
Thanks for ur reply...I Solved it..
Born to win...!
|
|
|
|
|
Can anybody help me to edit,update and delete Microsoft Acess database through ODBC.
I connected the database and i can acess the contents of database by using SQL queries.
|
|
|
|
|
Deepu Antony wrote: Can anybody help me to edit,update and delete Microsoft Acess database through ODBC.
See here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello,
How can I stop the window to get merged with the main window when the maximize button is pressed?
The maximized button doesn't have the restore minimize button with window.
How can I get these buttons with the maximized window?
Regards,
Pritha
|
|
|
|
|
Hai..
one doubt..Urs is multiple document window (MDI) In mfc..or...?
Born to win...!
|
|
|
|
|
Hello,
Thanks for your reply.
Yes mine is MDI.
Prithaa
|
|
|
|
|
I guess you refer to the view that is attached with the document when you say window, and to the application frame when you say main window.
I access the different views of my document with the following
CMDIChildWnd* pMDIActive = MDIGetActive();
CDocument* pDoc = pMDIActive->GetActiveDocument();
CMyView* pMyView;
POSITION pos = pDoc->GetFirstViewPosition();
while (pos)
{ pMyView = (CMyView*) pDoc->GetNextView(pos);
if (pMyView ->IsKindOf(RUNTIME_CLASS(CMyView)))
{ CFrameWnd* pTempFrame = pMyView->GetParentFrame ();
pTempFrame->DestroyWindow ();
return;
}
}
return;
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Thanks for the reply
What I want is to write code so that when my child window is maximized the child window should have a minimizebox,a maximize box(restore box) and the destroy box ?
When I maximize my child window the window does not have the retore box so that I can now restore the window back to original position?
The child window sort of merges with the main window (frame window) leaving no scope for accessing other child windows.
Regards
Thanks.
Prithaa
|
|
|
|