#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define uint unsigned int
#define WIDTH  40
#define HEIGHT 40
#define BLOCK_SIZE 5

void create_checker_row(uint* row, uint size_block, uint nb_col, uint offset )
{
    uint ic;
    for (ic = size_block*offset ; ic < nb_col; ic+= 2*size_block )
    {
    	memset( (row + ic) , 0, size_block*sizeof(uint) );
    }
}

int main()
{
	uint ir,ic;
    
	// image creation
    uint* pixels = (uint*) malloc(WIDTH*HEIGHT*sizeof(uint));
    for (ir = 0; ir < WIDTH; ir++)
    {
    	for ( ic = 0; ic < HEIGHT; ic++)
    	{
    		// arbitrary numbers
    		pixels[ir*WIDTH + ic] = (ir*WIDTH + ic) % 57 ;
    		printf("%d,", pixels[ir*WIDTH + ic] );
    	}
    	printf("\n");
    } 

    for (ir = 0; ir < WIDTH; ir++)
    {
        create_checker_row( pixels + ir*WIDTH   , // pointer at the beggining of n-th row
                            BLOCK_SIZE          , // horizontal length for square
                            WIDTH               , // image width
                            (ir/BLOCK_SIZE) % 2   // offset to create the checker pattern
                            );
    }
    
    // validation
    printf("\n");
    printf("Validation \n");
    printf("\n");
    for (ir = 0; ir < WIDTH; ir++)
    {
        for ( ic = 0; ic < HEIGHT; ic++)
    	{
    		printf("%d,", pixels[ir*WIDTH + ic] );
    	}
    	printf("\n");
    }

    return 0;
}