Skip to content
Snippets Groups Projects
Commit c9680c19 authored by Brandon Rodriguez's avatar Brandon Rodriguez
Browse files

Reorganize image.cu file

parent 82c7c1b9
Branches
No related merge requests found
......@@ -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
......
......@@ -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.
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment