|
Just to clarify, I think I've used monochrome incorrectly. With the method I suggest, I take the RGB values that I use to draw some custom controls and adjust the H channel only, giving me the ability to tint color-schemes to any color I want.
If you load your image into Gimp or Photoshop or whatever then desaturate the image, you'll get a perfect grey-scale image.
It's just a matter of understanding and then working in either HSL or HSV colorspace. By changing the S channel to 0 in either model, you effectively remove all color information, leaving only darkness/lightness information remaining.
Here, have a gander if you please: http://en.wikipedia.org/wiki/HSL_and_HSV
|
|
|
|
|
I realized what you said after a bit more fiddling it is a good idea and i just need to figure out how to do it ^.^
I'm starting to run out of time though so had to do a bit of a hack. I'll be working on this again when i find the time though i was enjoying it. Here's what i did just in case it helps anyone else.
I get the bytes one byte at a time so this is inside that loop. It could obviously be in a loop of its own just as easily though.
if(data[a] == 208)
{
data[a] = 75;
}
What this does is turn any colour that i what to suppress into black.
The black is somewhere between 192 and 208.
This Creates the bitmap once i have the raw pixels in the array
CClientDC dc(this);
BITMAPINFO bmi;
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = 208;
bmi.bmiHeader.biHeight = 208;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 8;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = 0;
bmi.bmiHeader.biXPelsPerMeter = 0;
bmi.bmiHeader.biYPelsPerMeter = 0;
bmi.bmiHeader.biClrUsed = 0;
bmi.bmiHeader.biClrImportant = 0;
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&dc,208,208);
::SetDIBits(dc.m_hDC,bitmap,0,208,rawImageArray,&bmi,DIB_RGB_COLORS);
CDC dcMemory;
dcMemory.CreateCompatibleDC(&dc);
CBitmap * pOldBitmap = dcMemory.SelectObject(&bitmap);
dc.StretchBlt(0,0, m_nW,m_nH, &dcMemory, 0,0,208,208 , SRCCOPY);
dcMemory.SelectObject(pOldBitmap);
|
|
|
|
|
This is a really delayed response but a bug caused me to revisit this code and with a little bit more experience in using MFC i approached it with a bit more confidence :P
Solved the problem though, it ended up being a really easy fix and i have "AlexFM" for his post on experts exchange to thank.
I needed to add a palette this solution eluded me because of the need for an array for the bitmap info.
here's my working code i hope it will help someone
CClientDC dc(this);
BITMAPINFO *bmi = (BITMAPINFO*)new char[sizeof(BITMAPINFO) + sizeof(RGBQUAD)*256];
bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi->bmiHeader.biWidth = 176;
bmi->bmiHeader.biHeight = 176;
bmi->bmiHeader.biPlanes = 1;
bmi->bmiHeader.biBitCount = 8;
bmi->bmiHeader.biCompression = BI_RGB;
bmi->bmiHeader.biSizeImage = 0;
bmi->bmiHeader.biXPelsPerMeter = 0;
bmi->bmiHeader.biYPelsPerMeter = 0;
bmi->bmiHeader.biClrUsed = 0;
bmi->bmiHeader.biClrImportant = 0;
for (int i = 0; i < 256; i++ )
{
bmi->bmiColors[i].rgbBlue = i;
bmi->bmiColors[i].rgbGreen = i;
bmi->bmiColors[i].rgbRed = i;
bmi->bmiColors[i].rgbReserved = 0;
}
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&dc,176,176);
::SetDIBits(dc.m_hDC,bitmap ,0 ,176 ,rawImageData ,bmi , DIB_RGB_COLORS);
CDC dcMemory;
dcMemory.CreateCompatibleDC(&dc);
CBitmap * pOldBitmap = dcMemory.SelectObject(&bitmap);
dc.StretchBlt(0,0, m_nW,m_nH, &dcMemory, 0,0,176,176 , SRCCOPY);
dcMemory.SelectObject(pOldBitmap);
|
|
|
|
|
Hi
To create installer (Install shield) please let me know if following files are sufficient or not
Project related files:
Exe file
*.BSC
Help file
Contents file
DLL’s:
ADVAPI32.DLL
COMCTL32.DLL
COMDLG32.DLL
GDI32.DLL
KERNEL32.DLL
MSVCRT.DLL
NTDLL.DLL
OLE32.DLL
OLEAUT32.DLL
OLEDLG.DLL
OLEPRO32.DLL
RPCRT4.DLL
SECUR32.DLL
SHELL32.DLL
SHLWAPI.DLL
USER32.DLL
WINMM.DLL
WINSPOOL.DRV
(Above DLLs I got from Dependency walker)
Do we need to include MFC runtime and .Net framework while creating installer?
Thanks
|
|
|
|
|
|
Thanks for the information. It helped me in identifying the DLLS used by the project.
Do .Net frame work and MFC runtime is required to run the exe developed using Microsoft Visual C++ 6.0.
Thanks
kavitha
|
|
|
|
|
Hello,
I want to convert char* to char[100]
how do i go about it
Pritha
|
|
|
|
|
char buf[100];
strncpy(buf, pChar, 99);
buf[99] = 0;
|
|
|
|
|
Why would you ever need such a conversion?! What are you trying to do and did the compiler give you such a conversion error? Give that context here and someone might be able to help you.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
yea, why would you need to do this?
David
|
|
|
|
|
Hi David,
You probably wanted to reply to the OP? Replying to a different message on the thread won't notify the OP about your post.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
yea .. F'd that up didn't i
David
|
|
|
|
|
char *charArray = new char[100];
char (*temp)[100]((char(*)[100])charArray); Then temp is a pointer to a char[100] array, so *temp is your array of 100 elements. The following should also work:
char (&temp)[100](*((char(*)[100])charArray)); In this case, temp is just an alias to the array, so you don't have to dereference it prior to accessing its members.
As for the reasons to do such a thing, they are many. One is if you have to create the array using a specialized memory allocation function, such as the case where you are using an external memory manager. For example, when coding for Matlab, you have to use mxAlloc to allocate ANY memory that will persist after your function is called. However, it may be more convenient in code to treat allocated memory as an array. As another example, suppose you create a template function that takes a 3D-array that you want to overload to take a 2D array. In this case, you would have to convert a TYPE[][] to a TYPE[1][][], which is a similar operation. For example,
template<size_t height, size_t width>
void doSomething(double (&darray)[height][width]) {
...
}
int main() {
const size_t height = 100;
const size_t width = 100;
double* memBlock2D = mxAlloc(height * width * sizeof(double));
double (&memArray2D)[height][width](*((double(*)[height][width])memBlock2D));
doSomething(memArray2D);
return 0;
} Hope this helps,
Sounds like somebody's got a case of the Mondays
-Jeff
modified on Tuesday, September 22, 2009 3:21 PM
|
|
|
|
|
Hi all,
I want to get cureent url from address bar of firefox.
Is there any snippet code to do this?
Thanx,
Jay
|
|
|
|
|
is there any way to get access to the details of the tasks show in the windows "task manager"? by c++.
|
|
|
|
|
Not with C++. Now if you were interested in some Windows API, there probably is. What did you have in mind?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
|
Hi
I just tried to call Sleep(1000) in a thread function
But when i tried to
Unit threadFun(LPVOID lparam)
{
while(1)
{
Sleep(1000); // When tried to give break point over here appliacation gets terminates
............
}
}
Can any one give me solution to this
Thanks
|
|
|
|
|
VVVimal wrote: Can any one give me solution to this
Remove the call to Sleep() . It's almost always unnecessary and usually indicates a design flaw.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
But i need a Sleep() function over there.
Because i need a function to be get called every 1000 milliseconds
|
|
|
|
|
VVVimal wrote: Because i need a function to be get called every 1000 milliseconds
Then use SetTimer(1000) .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Remember that Windows is not a real-time system, your function might or might not be called at every 1000 milliseconds, depending on what's happening on the OS.
This signature was proudly tested on animals.
|
|
|
|
|
VVVimal wrote: Unit threadFun(LPVOID lparam)
{
while(1)
{
Sleep(1000); // When tried to give break point over here appliacation gets terminates
............
}
}
I don't see why should the application "terminate" with this piece of code. (It might have probably helped us if you had given the remaining code within the thread function to see if anything is wrong)
With more than one thread running, may be the issue is somewhere else? Besides that, like David said, remove the unnecessary Sleep call and replace it with something that makes sense of some sort.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
does the application terminate or does it hang?
i would thing that statement would cause the app to hang... continuous loop with a defined wait time.. is that 1000 seconds or milliseconds it's library specific..??
David
|
|
|
|
|
David, you again replied to me instead of the OP. You should click reply on the specific message that you want to reply to.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|