Hi i got the following in my main file:
Code:
#include <stdio.h>
#include <ep100lib.h>
int main(int argc, char **argv)
{
ep100_lib_init();
FILE * output = stdout;
FILE * input = stdin;
char *filename=NULL;
int image_data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y];
filename = argv[argc-1];
int width;
int height;
ep100_lib_init();
if (argc <= 1)
{
fprintf(output,"ERROR: Not enough arguments entered");
return(0);
}
else if (strcmp(argv[1],"-i") == 0)
{
ep100_lib_open_image(filename);
width = ep100_lib_get_image_width();
height = ep100_lib_get_image_height();
ep100_lib_get_data(image_data);
ep100_lib_print_data(image_data);
invert_image(image_data, width, height);
ep100_lib_set_data(image_data);
sleep(10);
ep100_lib_display_image();
ep100_lib_close();
return(0);
}
Now in another c file i have a function as follows:
Code:
#include <ep100lib.h>
#include <stdio.h>
int **invert_image(int image_data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y], int width, int height)
{
int image_data_change[width][height];
int row, column;
for(row=0; row<height; row++)
{
for(column=0; column<width; column++)
{
int red = ((image_data[column][row]>>16)&0xff);
int green = ((image_data[column][row]>>8)&0xff);
int blue = ((image_data[column][row])&0xff);
int new_red = 255 - red;
int new_blue = 255 - blue;
int new_green = 255 - green;
image_data_change[column][row] = ((new_red<<16) | (new_green<<8) | (new_blue));
}
}
return (int **)image_data_change;
}
Now it doesnt quiet work, not sure why.
Could someone please advise?
Thanks