int main(int argc, char *argv[]){ // storing arguments from the comman line int filter_width = parseWidth(argv); float filter_weight[filter_width*filter_width]; char *inputName = parseIn(argv); char *outputName = parseOut(argv); // parses the input weights from positional parameters parseWeight(filter_weight, argv, argc); // opening the files FILE *imageIn = fopen(inputName, "rb"); FILE *imageOut = fopen(outputName, "wb"); // initialize the before modification and after modification arrays unsigned char before[imageSize(imageIn)]; unsigned char after[imageSize(imageIn)]; // loading the raw data in to the before array loadBMP(imageIn, before); // apply the filter doFiltering(before, filter_weight, filter_width, after); // write to the new file fwrite(after, sizeof(unsigned char), imageSize(imageIn), imageOut); // closing the file. fclose(imageIn); fclose(imageOut); }
bool EScale::ReadWeight(void) { unsigned char wcmd[] = {0x02, 0x52, 0x44, 0x53, 0x01, 0xEA, 0x0D}; unsigned char wrsp[WEIGHTLENGTH]; int size; write(wcmd, sizeof(wcmd)); size = read(wrsp, WEIGHTLENGTH); return parseWeight(wrsp, size, nWeight, tWeight); }