]> git.seodisparate.com - EN605.617.81.FA21_StephenSeo_DitheringProject/commitdiff
clang-tidy/clang-format fixes
authorStephen Seo <seo.disparate@gmail.com>
Tue, 16 Nov 2021 08:36:51 +0000 (17:36 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Tue, 16 Nov 2021 08:36:51 +0000 (17:36 +0900)
src/image.cc
src/image.h
src/main.cc
src/opencl_handle.cc

index 1b227fb7ac3c4ddf06a9247c2efa25ef56e398ee..6ee3abf895bae5465c3632ce7f59fb68f8a874bf 100644 (file)
@@ -272,7 +272,6 @@ void Image::DecodePNG(const std::string &filename) {
   // pass the FILE pointer to libpng
   png_init_io(png_ptr, file);
 
-  // TODO BEGIN
   // have libpng process the png data
   png_read_png(png_ptr, png_info_ptr, PNG_TRANSFORM_IDENTITY, nullptr);
 
@@ -404,7 +403,7 @@ void Image::DecodePGM(const std::string &filename) {
                   << '"' << std::endl;
         return;
       }
-      value = (float)int_input / max_value;
+      value = static_cast<float>(int_input) / max_value;
       data_.push_back(std::round(value * 255.0F));
     }
   } else if (str_input.compare("P5") == 0) {
@@ -453,7 +452,7 @@ void Image::DecodePGM(const std::string &filename) {
         std::cout << "WARNING: File data after PGM max is not whitespace "
                      "(filename \""
                   << filename << "\")"
-                  << " value is " << (int)c << std::endl;
+                  << " value is " << c << std::endl;
       }
 
       if (!ifs.good()) {
@@ -557,7 +556,7 @@ void Image::DecodePPM(const std::string &filename) {
                   << '"' << std::endl;
         return;
       }
-      value = (float)int_input / max_value;
+      value = static_cast<float>(int_input) / max_value;
       data_.push_back(std::round(value * 255.0F));
       if (i % 3 == 2) {
         // PPM is RGB but Image stores as RGBA
@@ -609,7 +608,7 @@ void Image::DecodePPM(const std::string &filename) {
       if (c != '\n' && c != ' ') {
         std::cout
             << "WARNING: File data after PPM max is not whitespace (filename \""
-            << filename << "\") value is " << (int)c << std::endl;
+            << filename << "\") value is " << c << std::endl;
       }
 
       if (!ifs.good()) {
index 66f453a54151c9f2f725737b99756ceb4f748e0a..ed4701e524007a64b8ce714abfac0e354e4554cd 100644 (file)
@@ -17,10 +17,10 @@ class Image {
    * Image supports decoding .png, .pgm, and .ppm . Decoding only checks the
    * filename suffix as a guide on which file-type to expect.
    */
-  Image(const char *filename);
+  explicit Image(const char *filename);
 
   /// Same constructor as Image(const char *filename)
-  Image(const std::string &filename);
+  explicit Image(const std::string &filename);
 
   // allow copy
   Image(const Image &other) = default;
index c5d069f005de6fee37f9b34b693b9b961dc5029f..c4244587b9fa6979e2665c5bf93ce673f16370e3 100644 (file)
@@ -1,8 +1,8 @@
 #include "image.h"
 
 int main(int argc, char **argv) {
-  //Image image("testin.ppm");
-  //image.SaveAsPNG("testout.png", true);
+  // Image image("testin.ppm");
+  // image.SaveAsPNG("testout.png", true);
 
   return 0;
 }
index d3b5b8fb0e6d682f4a9fbeb80344280a46c0a457..17104144600cfeb4a548da7b7d1ca9026f0de391 100644 (file)
@@ -562,7 +562,8 @@ OpenCLContext::OpenCLContext() : context_(nullptr), queue_(nullptr) {
   }
 
   cl_context_properties context_properties[] = {
-      CL_CONTEXT_PLATFORM, (cl_context_properties)first_platform_id, 0};
+      CL_CONTEXT_PLATFORM,
+      static_cast<cl_context_properties>(first_platform_id), 0};
 
   context_ = clCreateContextFromType(context_properties, CL_DEVICE_TYPE_GPU,
                                      nullptr, nullptr, &err_num);