Skip to content
Snippets Groups Projects
Commit 31ef44cc authored by Rene's avatar Rene
Browse files

Einfügen des -help command

parent 41caa85c
Branches
No related tags found
No related merge requests found
No preview for this file type
...@@ -38,6 +38,10 @@ int main (int argc, char **argv) ...@@ -38,6 +38,10 @@ int main (int argc, char **argv)
{ {
evaluateArguments(argc, argv); evaluateArguments(argc, argv);
if(debug) {
printf("running in debug mode!\n");
}
unsigned width, height; unsigned width, height;
int screenID; int screenID;
XImage *image; XImage *image;
...@@ -65,8 +69,8 @@ int main (int argc, char **argv) ...@@ -65,8 +69,8 @@ int main (int argc, char **argv)
Bool picked = False; Bool picked = False;
if(pickColor) { if(pickColor) {
while (!picked) { while (!picked) {
XNextEvent(display, &ev);
printf("select a color!\n"); printf("select a color!\n");
XNextEvent(display, &ev);
if(ev.type == ButtonPress) { if(ev.type == ButtonPress) {
x = ev.xbutton.x; x = ev.xbutton.x;
y = ev.xbutton.y; y = ev.xbutton.y;
...@@ -116,13 +120,27 @@ void evaluateArguments (int argc, char **argv) ...@@ -116,13 +120,27 @@ void evaluateArguments (int argc, char **argv)
#define OPTION argv[0] #define OPTION argv[0]
#define NEXTOPT ++argv, --argf>0 #define NEXTOPT ++argv, --argf>0
{ {
const char *argt = argv[0];
#define PROGRAMNAME argt
int argf= ARG; int argf= ARG;
while (NEXTOPT) while (NEXTOPT)
{ {
if (!strcmp(OPTION, "-help"))
{
printf(
"Usage: %s [OPTION]...\nSearch for a Rectangle pattern with a specific color return the startpixel and the width and height.\n%s\n" ,
PROGRAMNAME ,
"return-pattern is [x y width height] while x and y are the topleft corner of the rectangle");
printf("viable Options are \n%s \n%s \n%s \n%s \n",
"-c, -color color Searches the window for a specific color in hex RGB type. For Example -color ff39ad",
"-f, -find x y returns the value of the color on that pixel and atfer that works like -color",
"-p, -pick let you pick a specific color with your mouse cursor and works just like -color after picking. Excludes -find and -color",
"-debug gives extra output messages\n");
exit(0);
}
if (!strcmp(OPTION, "-debug")) if (!strcmp(OPTION, "-debug"))
{ {
debug = True; debug = True;
printf("running in debug mode!\n");
continue; continue;
} }
...@@ -200,8 +218,8 @@ rectangle searchForColorRectII (uint32_t color, XImage *image, unsigned width, u ...@@ -200,8 +218,8 @@ rectangle searchForColorRectII (uint32_t color, XImage *image, unsigned width, u
rectangle rect; rectangle rect;
int count = 0; int count = 0;
uint32_t extractedColor; uint32_t extractedColor;
int *countX = malloc(sizeof(int) * width);
int *countY = malloc(sizeof(int) * height); int *countY = malloc(sizeof(int) * height);
int *countX = malloc(sizeof(int) * width);
Bool foundColor = False; Bool foundColor = False;
for (int i = 0; i < width; i++) for (int i = 0; i < width; i++)
...@@ -262,6 +280,35 @@ rectangle searchForColorRectII (uint32_t color, XImage *image, unsigned width, u ...@@ -262,6 +280,35 @@ rectangle searchForColorRectII (uint32_t color, XImage *image, unsigned width, u
} }
} }
/* Testscript */
/*
int *amount;
int *temp;
int entrys = 0;
for (int i = 0; i < width; i++)
{
if(countX[i] == 0)
continue;
realloc(amount, sizeof(int) * entrys);
realloc(temp,sizeof(int) * entrys);
temp[entrys] = countX[entrys];
for (int j = i; j < width - i; j++) {
if (countX[i] == countX[j])
{
amount[i]++;
}
}
}
*/
rowMiddle = (rowMax - rowMin)/2; rowMiddle = (rowMax - rowMin)/2;
columnMiddle = (columnMax - columnMin)/2; columnMiddle = (columnMax - columnMin)/2;
...@@ -435,6 +482,7 @@ unsigned long extractIntFromString(char *intString) { ...@@ -435,6 +482,7 @@ unsigned long extractIntFromString(char *intString) {
void throwError (char *errorMSG) { void throwError (char *errorMSG) {
fprintf(stderr, "ERROR: %s\n" ,errorMSG); fprintf(stderr, "ERROR: %s\n" ,errorMSG);
printf("Use -help for more Informations!\n");
exit(0); exit(0);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment