Title^. So far I have a general progress made, as I have the ability to do the following (during runtime/app execution):
read/write a pixel in the struct based upon the block_size (word_size)
read/write a pixel in the struct based upon the order (row major vs column major)
read/write a pixel based upon the width and height of the image
successfully open a file write out the following fields to a file(get some output):
name
order
block_size
width
height
The way I've written out the fields are in logical order, although the name
field is probrably unecessary, but can be used during runtime or identification.
1 2 3 4 5 6 7 8 9
|
struct ExampleImage{
char* ex_name;
unsigned long long ex_order;
unsigned long long ex_block_size;
unsigned long long ex_width;
unsigned long long ex_height;
//bytes written to file will be implicit...
void* ex_data;
};
|
My Secondary problems are:
How do I integrate a file header (with a magic number and version)?
I want to be able to have different algorithms for each major version
of the image format. I also want the minor version of the format to be
tied to the update (minor bug fix/enhancement).
1 2 3 4 5 6 7 8 9
|
struct ExampleVersion{
union{
unsigned int version;
struct{
unsigned short ver_maj;
unsigned short ver_min;
}
}u_ver;
}
|
Am I on a good track with the above structures? I don't put my header up here because right now it isn't necessary as I am having problems writing the image i generate up.
My Primary Problems:
Should I be writing the bytes of the image in binary form, instead of text? Each individual pixel is distinct during runtime, but when I write each pixel in a format they all appear the same. (Basically it definitely isn't my image generation algorithm, its has something to do with file IO).
Should I be writing entire image file in binary mode instead? I cannot write my image reader algorithm until I finish this up.
EDIT 1: I fixed the problem where my image data was not reading in correctly XD. The image
file now looks like a binary file (when i use monochrome generation), even though it is opened in text mode.
EDIT 2: Now that I fixed the problem where it wouldn't output bytes properly. I still have the issue of formatting.
Is it a good idea to use the " " character as a delimiter for bytes so that I can check to see
if the image file data is corrupt? Or is this an unecessary thing to do?
EDIT 3: THANKS very much in advance for anyone who can answer any of my questions.