|
Perhaps you're after the GetPixel API.
Steve
|
|
|
|
|
In a bitmap file type BMP?
Documentation of the layout of a BMP file is here[^].
The format of each "pixel" of image data varies, depending on bits-per-pixel, planes, etc.
Do you have a certain type of bitmap or does it need to work on any bitmap?
Mark
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
any bitmap image i guess it a picture take from a webcam that is save a a bitmap.
|
|
|
|
|
Same answer as my first reply.
Basically you need to
1) load the bitmap file into memory
2) get a pointer to the pixel bits
3) scan the pixel bits for the attributes you are looking for
All three of these steps vary depending on file type and image bits format.
Have you tried anything so far?
Mark
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
how would u do the pixel bits i not sure of how to do that??
|
|
|
|
|
Depends on the pixel format.
Assuming you are working with RGB data (24-bit/32-bit):
Are you looking for an exact color or fairly close to a color? Using red as an example...
The easiest method is to look for an exact color. Say you want to find bright red - just look
for pixels with value RGB(0xFF,0x00,0x00).
Somewhere in the middle of complexity would be to look for pixels with the red component a
certain percentage higher than the green and blue components. For example, a pixel with value
of RGB(0xFF,0x21,0x32) would be considered red but one with value RGB(0xFF,0x84,0xA8) wouldn't.
This method kind of finds the "redest" pixels.
Then you can get complex with images that are similar but maybe vary in intensity (microscope
slides stained with a certain color comes immediately to mind ). You could create a histogram
using all the pixels in the image and use the result to help automagically detect the proper
percentage mentioned in method 2.
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
Anyone know how to create a application that can intercept output from another application? Any help is appreciated.
|
|
|
|
|
What kind of output to you wish to intercept? Perhaps this[^] will help.
Steve
|
|
|
|
|
shatterstar6457 wrote:
Anyone know how to create a application that can intercept output from another application? Any help is appreciated.
console or UI based app
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
I am using Visual C++ 6.0 MFC. I downloaded the Universal Progress Dialog Demo/Source project from the article written by P. GopalaKrishna. I tried to compile the project on my machine and received an "error C2664: 'DialogBoxParamA' : cannot convert parameter 4 from 'long (struct HWND__ *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(struct HWND__ *,unsigned int,unsigned i
nt,long)'
None of the functions with this name in scope match the target type"
Does anyone recognize what I am missing in order to compile and execute this demo?
Thanks,
Buck
Buck
|
|
|
|
|
It would be helpful if you showed the actual code that generated this message! It looks like a calling convention mismatch to me.
Steve
|
|
|
|
|
Here is the code snippet that generated the compilation error. The entire project can be downloaded from the codeproject article "Universal Progress Dialog".
INT_PTR CUPDialog::DoModal()
{
Cleanup(); //If this not first time, Terminate any previous instance Threads !!
return DialogBoxParam(NULL,MAKEINTRESOURCE(IDD),m_hParentWnd,ProgressDlgProc,(LPARAM)this);
}
I am not an experienced Windows programmer comming from the UNIX world so there is a lot of things that the author of the code is doing that I have never seen in MFC. One being that the function ProgressDlgProc (which is the fouth argument that is is puking on) is used without parameters being passed with it. Considering that the project compiled and ran on the authors machine I think there may be a library or include file or some parameter that needs to be set in the compiler settings. I just don't know. By the way, I am using Windows 2000.
Buck
|
|
|
|
|
I need to see the declaration and definition of "ProgressDlgProc" too.
Steve
|
|
|
|
|
ProgressDlgProc appears in only three places.
Here it is in the UPDialog.h file,
class CUPDialog
{
static struct _tagInitCommonControls
{
_tagInitCommonControls(); // Constructor to call the InitCommonControlsEx() function
}
m_InitCommonControls; // Static Variable
HWND m_hParentWnd; //The Window that Requested the Progress Operation; Needed to Create the DialogBox
bool m_bAllowCancel; //Should the Dialog allow PreEmtption by user before Completion?
HANDLE m_hThread; //Holds the Handle to the Created Thread
TCHAR m_szDialogCaption[256]; //Fill up with the Title of the DialogBox
CUPDUPDATA m_ThreadData;
friend INT_PTR CALLBACK ProgressDlgProc(HWND,UINT,WPARAM,LPARAM); //The Windows Message Procedure for the DialogBox
void Cleanup();
public:
enum { IDD = CUPDIALOG_DIALOG_ID };
CUPDialog(HWND hParentWnd,LP_CUPDIALOG_USERPROC lpUserProc,LPVOID lpUserProcParam,LPCTSTR lpszDlgTitle=_T("Please Wait.."),bool bAllowCancel=true);
virtual ~CUPDialog();
INT_PTR DoModal(); //Returns: IDOK => Sucessful; (IDCANCEL && HIWORD(wParam)==0) => Some Error in UserProc; (IDCANCEL && HIWORD(wParam)==1) =>User Cancelled the Dialog;
};
It also appears as the function itself,
INT_PTR CALLBACK ProgressDlgProc(HWND hDlg,UINT Message,WPARAM wParam,LPARAM lParam)
{
switch(Message)
{
case WM_INITDIALOG:
{
CUPDialog *pProgressDialog = (CUPDialog*) lParam;
if(pProgressDialog->m_bAllowCancel == false)
and also as a part of a return value which is what I posted and the compiler crashes on.
|
|
|
|
|
Firstly, the error seems to indicate that the return types don't match. Change all the INT_PTR return types in your "ProgressDlgProc" functions to int . After you’ve done that let me know the effect it has. It still looks a calling convention mismatch may remain.
Steve
|
|
|
|
|
Thanks, that took care of the typing problem with the compiler. There are two functions that are not defined. One is named SetWindowLongPtr(hDlg,GWL_USERDATA,(LONG_PTR)pProgressDialog); and the other is named GetWindowLongPtr(hDlg,GWL_USERDATA); But after looking at the Microsoft docs and that these functions superceded the 32 bit versions, I lopped off the Ptr part of the function name and everything was okay. Just a note, the docs mention that the declarations are in Windows.h but if you put the include in the StdAfx.h file the compiler complains that it has already included the file. There also is a User32.lib file in my library directory that visual studio is looking in.
|
|
|
|
|
It's strange that INT_PTR had to be replaced with int , although that was what the error message indicated. I suspect that the fact you had to do this indicates a fault in the library you're using. Have you got a link to the code for this "Universal Progress Dialog"?
Steve
|
|
|
|
|
I am trying to use pointers to create 3 list boxes in the main window of an application. I can get the first list to work fine, but if I even try to allocate memory for the second pointer (CListBox *Ptr2 = new CListBox(); ), the program gives me a run-time error. Anyone have any ideas?
|
|
|
|
|
If the denominator is zero you will get a divide by zero runtime error, check the denominator before calling the division operator.
(Or was it some other runtime error, you did not specify which so I just took a wild ass guess)
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
I'm not entirely sure what the runtime error is. A dialog pops up that says:
The instruction at "0x7c910e03" referenced memory at "0x00000001". The memory could not be "written"
Click on OK to terminate the program.
|
|
|
|
|
That would have been so cool if you were right
"Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens. It's a dumb question... skip it."
|
|
|
|
|
Show some code......
Steve
|
|
|
|
|
Here is the function:
void CRatiosWin::InitializeVariables()
{
SetFilePath("");
SetTimeParameterStatus(false);
SetFilePathStatus(false);
CListBox* listPtr = new CListBox();
listPtr->Create(WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_HSCROLL,CRect(0,0,400,400),this,IDC_LIST);
CListBox* listPtr2 = new CListBox();
listPtr2->Create(WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_HSCROLL,CRect(410,0,800,400),this,IDC_LIST);
fstream infile;
infile.open("VariableNames.txt",ios::in);
string var_name, rType;
VariableStringsListLength = 0;
while(infile>>var_name>>rType)
{
VariableStringsList[VariableStringsListLength++] = new CRatiosVariableStrings(var_name,rType);
}
}
If I make only one list box, it works fine, but if I add a second one, it screws up.
|
|
|
|
|
Another potential error is that both your list boxes have the same ID; IDC_LIST. They should be different.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
SON OF A B****!!!
I was looking through other parts of the code and found the problem somewhere else! As it turns out, that run-time error simply refers to an array index out of bounds error (not quite a divide-by-zero, but )
I don't even know why this only came up when I added list boxes, the array had nothing to do with them.
Anyway, sorry for wasting your time.
|
|
|
|