#include <stdio.h>


#define guint unsigned int
#define guint8 unsigned char

#include "1_line_for_lookup_table.c"


#define GRAPHIC_WIDTH gimp_image.width
#define GRAPHIC_HEIGHT gimp_image.height

int main(int argc, char ** argv)
{
    char default_var_name[] = "line_var";
    char *  var_name;
    if (argc == 2)
    {
        var_name = argv[1];
    } else {
        var_name = default_var_name;
    }
    guint x_index = 0;
    guint y_index = 0;
    char * data_ptr = gimp_image.pixel_data;
    char color_found = 0;
    unsigned int x_start = 0;
    unsigned int x_end = 0;
    //printf("Leading text "BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(byte));




    while(y_index<GRAPHIC_HEIGHT)
    {
        color_found = 0;
        if(x_index == 0)
        {
            x_start = 0;
            x_end = 0;
        }
        if(data_ptr[0] == 0xff || data_ptr[1] == 0 || data_ptr[2] == 0)
        {
            
            if(x_start == 0) 
            {
                    x_start = x_index;
            }
            x_end = x_index;
            
        }  
    
 
        data_ptr +=gimp_image.bytes_per_pixel;
        x_index++;
        if(x_index==GRAPHIC_WIDTH)
        {
            x_index = 0;
            
            if(!(x_start == 0 && x_end == 0)) {
                //printf("%s[%d] = %d;\n",var_name,y_index, (x_start + x_end)/2);
                printf("%d", (x_start + x_end)/2);
            } else {
                //printf("%s[%d] = %d;\n",var_name,y_index, -1);
                printf("%d", -1);
            }
            y_index++;
            if(y_index<GRAPHIC_HEIGHT)
            {
                printf(", ");
            }
        }      
        
    }
    printf("};\n");
	//    printf("expected_size: %d\n",y_index*4*2001);
}

