|
If you refer to Registry... I tip not to use CRegKey, and use the "search comments" in forum, I asked about accesing the registry few days ago and the people solved my problem. To start you have a reference.
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
|
|
|
|
|
Can anybody help me in converting a 16 bit RGB (555)to 8 bit grayscale bmp.
I got 5 bits of red ,green and blue pixels.
Thanks in advance
|
|
|
|
|
Have a look at the following Christian Graus article, here at CP [^]. Porting the grayscale filter algo C# to C++ is straightforward.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Thanks for helping me it is useful to me
|
|
|
|
|
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
In the 8 bit bmp a color table is used (of size 256 colors). So after you convert the color to gray (using the formula, Y = 0.3R + 0.59G + 0.11B) you have to keep it in a 256 element COLORREF array as a new color if it not added to the array yet. And the index of this array should be saved as the bitmap data. If the color idex is getting overflown ( > 255 ), then the index of a nearest existing color should be identified and the index should be used. For better result, when finding the nearest color, the occurance of that color should be considered. Means if 80% gray is coming 1 time and 81% is coming 20 times, then replacing the 80% to 81% is better. And dont forget to save the created color table also.
- NS -
|
|
|
|
|
Can u make it more clear please..
|
|
|
|
|
What could you do for this so far?
- NS -
|
|
|
|
|
i seperated red green and blue bits.Thus i have 5 bits of each.then i make it to 8 bit each by shifting them to the left by 3 bits.Then i used the
conversion formula .299*R+.587*G+.114*B .But lost of information is observed.
Is ther is any method to diectly converting it 8 bit grayscale
|
|
|
|
|
How do you expect to preserve data when converting RGB to
grayscale? It's not going to happen.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Actually i converted 555 RGB to 888 RGB.Then i converted it to grayScale.Is there is any direct method to convert it to grayscale
|
|
|
|
|
Deepu Antony wrote: Is there is any direct method to convert it to grayscale
Not that I know of.
My point was, you're going to lose your RGB data (unless, of course,
you keep it separately).
You stated: "But lost of information is observed"
You can't get the RGB data back once you've converted it.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i convert 5 bit Green ,5 bit red ,5 bit blue to each 8 bit (24 bit RGB) by shifting it to left by three bits.while doing this loss of information is observed.I know only to convert 24 bit rgb to gray scale.
is there is any direct method to convert 16 bit RBG to 8 bit gray sale.
Can you help me please
|
|
|
|
|
Deepu Antony wrote: to each 8 bit (24 bit RGB) by shifting it to left by three bits.while doing this loss of information is observed.
There's no loss of information there. You only had 5 bits precision for each color
component to begin with. Widening to 8-bits you still have the same precision.
The image will appear the same on a 16,24,or 32-bitsperpixel display.
Deepu Antony wrote: s there is any direct method to convert 16 bit RBG to 8 bit gray sale.
The only way I know is the usual luminence formula
intensity = 0.2989*red + 0.5870*green + 0.1140*blue It yields an eye-pleasing grayscale representation of an RGB image but
no RGB data is preserved.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all,
I have a char buffer and a char*
Lets call it:
char buffer[1024];
char* point;
If I perform a strcpy() , and copy the value of the point into the buffer . If the value of the point changes there after, will the value of the buffer change too??
Many Thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
No, because the pointers points to two different locations. Except if you do something like that:
char* point = &buffer[0];
But then of course, you don't need to use strcpy anymore. strcpy just copy bytes from one memory location to another, it is similar as memcpy (except that it works for null-terminated strings).
|
|
|
|
|
|
Programm3r wrote: If the value of the point changes there after, will the value of the buffer change too??
Why don't you try it and see?
"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
|
|
|
|
|
Hi all,
In my MFC application I've create two buttons, OPEN and CLOSE, used to open a text file and close it. I do it as follows.
<br />
void CSRFToolDlg::OnBnClickedOpen()<br />
{<br />
char* ReadFileName = "G:\\Work On\\CPP\\SRFTool\\text_file.txt" ; <br />
<br />
if(openFile.Open(ReadFileName, CFile::modeCreate | CFile::modeReadWrite))<br />
{<br />
AfxMessageBox("File creates successfully", MB_OK) ;<br />
}<br />
else<br />
{<br />
AfxMessageBox("Error in file opening", MB_OK) ;<br />
}<br />
}<br />
<br />
<br />
void CSRFToolDlg::OnBnClickedClose()<br />
{<br />
openFile.Close() ;<br />
}<br />
What I want to do is, until user click the Open button the Close button should be disable. How should I do it. Those stuff really new for me.
Thanks
-- modified at 6:08 Thursday 11th October, 2007
I appreciate your help all the time...
|
|
|
|
|
Stablish a control member variable to the with the class assistant (ctrl + w, second propertie page) or
use CWindow::GetDlgControl (nID) in order to have access.
Then use EnableWindow (TRUE); //or false as you want
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
|
|
|
|
|
Can you explain it with my code. What you mean second property page. I'm unable to found that.
I appreciate your help all the time...
|
|
|
|
|
hi,
Try this one...
Disable the button in OnInitDialog of your dialog class
eg:
GetDlgItem(UR_CLOSE_BUTTON_ID)->EnableWindow(FALSE);
Enable that button in OnBnClickedOpen function
void CSRFToolDlg::OnBnClickedOpen()
{
char* ReadFileName = "G:\\Work On\\CPP\\SRFTool\\text_file.txt" ;
if(openFile.Open(ReadFileName, CFile::modeCreate | CFile::modeReadWrite))
{
AfxMessageBox("File creates successfully", MB_OK) ;
GetDlgItem(UR_CLOSE_BUTTON_ID)->EnableWindow(TRUE);
}
else
{
AfxMessageBox("Error in file opening", MB_OK) ;
}
}
Again Disable the button in OnBtnClickedClose()
void CSRFToolDlg::OnBnClickedClose()
{
openFile.Close() ;
GetDlgItem(UR_CLOSE_BUTTON_ID)->EnableWindow(FALSE);
}
If you the control variable of Close button, the user that variable in place of GetDlgItem(UR_CLOSE_BUTTON_ID)
|
|
|
|
|
Lakshmi_p wrote: If you the control variable of Close button, the user that variable in place of GetDlgItem(UR_CLOSE_BUTTON_ID)
Do you mean that the ID of the control(button ID). I'll do it in that way, it's disable after clicking the Open button.
If I can load
GetDlgItem(UR_CLOSE_BUTTON_ID)->EnableWindow(FALSE);
in form load, it will work. How to access to the form load.
I appreciate your help all the time...
|
|
|
|
|
form load function you can find it in visual basic.
but in vc++6.0, the analogous function is init dialog.
you can write the code as suggested by lakshmi there.
and also in the buttons.
any more doubts?
get back.
|
|
|
|
|
Actually I found a way to do it. Just define in OnInitDialog(). It works. What you think about that.
I appreciate your help all the time...
|
|
|
|