Reputation:
I am working with C and I have an array that I work on. The values being 0 or 1.
For the time being, since this array serves as the prerequisite for anything I do with my program, I am manually creating it from a file, where file contains the Row Column coordinates for starting and ending point and a vertical or horizontal line is filled with value 1 in the array.
I want only horizontal and vertical line for now. But I want to improve the efficiency of the whole array initialisation process.It is really tedious specifying the coordinates in a file. I want to have a GUI where each pixel corresponds to a cell of array and when I draw something in the window, the corresponding cell gets the value 1 in my array and once I have the array with me, I pass it to my C program.
Now, I can make use of some already existing software, or maybe some other quick fix for array initialisation, since my main program starts once the array has been initialised properly.
Thanks.
*Addition
Operating System : Ubuntu. Size OF Array For Now : 100*100 but that is because I am manually filling it up and I like to keep it small. But I dont see it extending beyond a normal computer screen, say a 1000*800
Upvotes: 0
Views: 67
Reputation: 249394
Just use an image format. Like TIFF, which does have a 1-bit variant which would be ideal for your case. I suspect the image editing software known as GIMP can save 1-bit TIFFs, and even if not, you could create 8-bit ones and just count pixels as on or off based on some threshold. There are plenty of libraries for dealing with TIFF, but you could also use BMP or something else if you want a simpler/dumber format (yet one that commodity software will help you edit).
Upvotes: 1