diff --git a/documents/references.md b/documents/references.md index 0962eb92070342fd4de1395fabb7d5d3f91dea87..6766a310513366055ebdb9464967c82d6b6f8cd5 100644 --- a/documents/references.md +++ b/documents/references.md @@ -7,8 +7,9 @@ Various references used in project. ## C++ References -### Book Reference -"A Tour of C++", by Bjarne Stroustrup +### Book References +* "A Tour of C++", by Bjarne Stroustrup +* "Introduction to Parallel Programming", by Peter S Pancheco. ### File and Directory Handling @@ -62,7 +63,7 @@ Various references used in project. ## CUDA References -### Book Reference +### Book References "Cuda by Example", by Jason Sanders & Edward Kandrot ### First CUDA Program diff --git a/part_1/image.cu b/part_1/image.cu index 15dd08a9aefc42f22b71e9f79c953a1bc837866b..c013135a6e609b517ee9ec6b225c61b02d3745c2 100644 --- a/part_1/image.cu +++ b/part_1/image.cu @@ -31,6 +31,80 @@ const Image::PixelStruct Image::pixelPink = Image::PixelStruct(1,0,1); const Image::PixelStruct Image::pixelLiBlue = Image::PixelStruct(0,1,1); +//region Constructors. + +/** + * Base constructor. + */ +Image::Image() { + logger.debug("Image::Image Constructor():"); + logger.debug(""); + + // Currently test logic. + + // Essentially creates a 10x10 pixel test image. + input_path = "../input/pbm/400x300/hallway_00.pbm"; + output_path = "../output/test_00.pbm"; + width = 10; + height = 10; + bit_depth = 255; + PixelStruct c = pixelBlack; // Default color. Can select based on below preset colors. + + // Create and populate image. + pixel_arr = new PixelStruct[width * height]; + for (int index = 0; index < (width * height); index++) { + pixel_arr[index] = c; + } +} + + +/** + * Constructor that takes input path to image file. + * Output path is determined based on parsing input path. + */ +Image::Image(std::string user_path) { + logger.debug("Image::Image Constructor():"); + logger.debug(" user_path: " + user_path); + logger.debug(""); + + logger.info("Constructing image class."); + + // Re-validate path for saving to class. + path_validator_struct* return_struct = validate_path(user_path); + int path_type = return_struct->file_type; + if (return_struct->err_code) { + logger.error("Error verifying file type: " + return_struct->err_code.message()); + return; + } + free_path_validator_struct(return_struct); + if (path_type == TYPE_FILE) { + input_path = user_path; + calculate_paths(user_path); + import_image_file(); + } else { + logger.error("Provided path is not an image file. Class initialization failed."); + return; + } + + logger.info("Image class created."); +} + + +/** + * Deconstructor. + */ +Image::~Image() { + logger.debug("Deconstructing image class"); + + // Deallocate memory objects. + delete[] pixel_arr; +} + +//endregion Constructors. + + +//region Private Methods. + /** * Calculates class input_path and output_path values. * @@ -149,78 +223,7 @@ void Image::import_image_file() { input_file.close(); } - - -//region Constructors. - -/** - * Base constructor. - */ -Image::Image() { - logger.debug("Image::Image Constructor():"); - logger.debug(""); - - // Currently test logic. - - // Essentially creates a 10x10 pixel test image. - input_path = "../input/pbm/400x300/hallway_00.pbm"; - output_path = "../output/test_00.pbm"; - width = 10; - height = 10; - bit_depth = 255; - PixelStruct c = pixelBlack; // Default color. Can select based on below preset colors. - - // Create and populate image. - pixel_arr = new PixelStruct[width * height]; - for (int index = 0; index < (width * height); index++) { - pixel_arr[index] = c; - } -} - - -/** - * Constructor that takes input path to image file. - * Output path is determined based on parsing input path. - */ -Image::Image(std::string user_path) { - logger.debug("Image::Image Constructor():"); - logger.debug(" user_path: " + user_path); - logger.debug(""); - - logger.info("Constructing image class."); - - // Re-validate path for saving to class. - path_validator_struct* return_struct = validate_path(user_path); - int path_type = return_struct->file_type; - if (return_struct->err_code) { - logger.error("Error verifying file type: " + return_struct->err_code.message()); - return; - } - free_path_validator_struct(return_struct); - if (path_type == TYPE_FILE) { - input_path = user_path; - calculate_paths(user_path); - import_image_file(); - } else { - logger.error("Provided path is not an image file. Class initialization failed."); - return; - } - - logger.info("Image class created."); -} - - -/** - * Deconstructor. - */ -Image::~Image() { - logger.debug("Deconstructing image class"); - - // Deallocate memory objects. - delete[] pixel_arr; -} - -//endregion Constructors. +//endregion Private Methods. //region Public Methods.