diff --git a/examples/common/bitmap/bitmap.cpp b/examples/common/bitmap/bitmap.cpp index 2b862e0..9e6e137 100644 --- a/examples/common/bitmap/bitmap.cpp +++ b/examples/common/bitmap/bitmap.cpp @@ -19,7 +19,7 @@ * the necessary headers to turn it into a bitmap image. */ void render_bitmap( - char * img, unsigned int w, unsigned int h, std::string fname + unsigned char * img, unsigned int w, unsigned int h, std::string fname ) { /* @@ -51,7 +51,7 @@ void render_bitmap( * This is the definition of the BMP header... It's rather esoteric, but it * is necessary. */ - char header[54] = { + unsigned char header[54] = { /* * Bytes [0:1]: The BMP magic numbers. */ @@ -60,10 +60,10 @@ void render_bitmap( /* * Bytes [2:5]: The total size of this file. */ - static_cast(filesize), - static_cast(filesize >> 8), - static_cast(filesize >> 16), - static_cast(filesize >> 24), + static_cast(filesize), + static_cast(filesize >> 8), + static_cast(filesize >> 16), + static_cast(filesize >> 24), /* * Bytes [6:9]: Reserved bytes which nobody uses. */ @@ -74,10 +74,10 @@ void render_bitmap( /* * Bytes [10:13]: The starting position of the image segment. */ - static_cast(offset), - static_cast(offset >> 8), - static_cast(offset >> 16), - static_cast(offset >> 24), + static_cast(offset), + static_cast(offset >> 8), + static_cast(offset >> 16), + static_cast(offset >> 24), /* * Bytes [14:17]: This identifies the size of the DIB header, which in * this case identifies it as BITMAPINFOHEADER. @@ -89,17 +89,17 @@ void render_bitmap( /* * Bytes [18:21]: The width of the image. */ - static_cast(w), - static_cast(w >> 8), - static_cast(w >> 16), - static_cast(w >> 24), + static_cast(w), + static_cast(w >> 8), + static_cast(w >> 16), + static_cast(w >> 24), /* * Bytes [22:25]: The height of the image. */ - static_cast(h), - static_cast(h >> 8), - static_cast(h >> 16), - static_cast(h >> 24), + static_cast(h), + static_cast(h >> 8), + static_cast(h >> 16), + static_cast(h >> 24), /* * Bytes [26:27]: The number of color planes, which is always 1. */ @@ -145,12 +145,12 @@ void render_bitmap( * Bitmap rows must be padded to multiples of 4, so we will keep these * padding zeros handy for when we need to do that. */ - char padding[3] = {0, 0, 0}; + unsigned char padding[3] = {0, 0, 0}; /* * Start off by writing the 54 byte header to the file. */ - bmp.write(header, 54); + bmp.write(reinterpret_cast(header), 54); /* * Here we compute the colour palette. Each byte identifies one of 256 @@ -189,14 +189,14 @@ void render_bitmap( * For each of the 256 colours, write the output RGB colour to the file * in four bytes. */ - char cmap[4] = { - static_cast((rp + q) * 255), - static_cast((gp + q) * 255), - static_cast((bp + q) * 255), + unsigned char cmap[4] = { + static_cast((rp + q) * 255), + static_cast((gp + q) * 255), + static_cast((bp + q) * 255), 0, }; - bmp.write(cmap, 4); + bmp.write(reinterpret_cast(cmap), 4); } /* @@ -208,14 +208,14 @@ void render_bitmap( /* * Retrieve the magnitude from the image, and write it. */ - char r = img[h * x + y]; - bmp.write(&r, 1); + unsigned char r = img[h * x + y]; + bmp.write(reinterpret_cast(&r), 1); } /* * If necessary, write the appropriate padding to the file. */ - bmp.write(padding, (4 - (w % 4)) % 4); + bmp.write(reinterpret_cast(padding), (4 - (w % 4)) % 4); } bmp.close(); diff --git a/examples/common/bitmap/bitmap.hpp b/examples/common/bitmap/bitmap.hpp index 5e9289b..a27cf50 100644 --- a/examples/common/bitmap/bitmap.hpp +++ b/examples/common/bitmap/bitmap.hpp @@ -13,5 +13,5 @@ #include void render_bitmap( - char * img, unsigned int w, unsigned int h, std::string fname + unsigned char * img, unsigned int w, unsigned int h, std::string fname ); diff --git a/examples/cpu/render_image.cpp b/examples/cpu/render_image.cpp index dc61470..3fb80b0 100644 --- a/examples/cpu/render_image.cpp +++ b/examples/cpu/render_image.cpp @@ -90,8 +90,8 @@ int main(int argc, char ** argv) covfie::utility::nd_size<2> im_size = f.backend().get_configuration(); - std::unique_ptr img = - std::make_unique(im_size[1] * im_size[0]); + std::unique_ptr img = + std::make_unique(im_size[1] * im_size[0]); BOOST_LOG_TRIVIAL(info) << "Rendering vector field to image..."; @@ -99,7 +99,7 @@ int main(int argc, char ** argv) for (std::size_t y = 0; y < im_size[0]; ++y) { field_t::view_t::output_t p = fv.at(x, y); - img[im_size[1] * y + x] = static_cast(std::lround( + img[im_size[1] * y + x] = static_cast(std::lround( 255.f * std::min( std::sqrt(p[0] * p[0] + p[1] * p[1] + p[2] * p[2]), 1.0f diff --git a/examples/cpu/render_slice.cpp b/examples/cpu/render_slice.cpp index a56d83c..82d811f 100644 --- a/examples/cpu/render_slice.cpp +++ b/examples/cpu/render_slice.cpp @@ -117,7 +117,7 @@ int main(int argc, char ** argv) BOOST_LOG_TRIVIAL(info) << "Allocating memory for output image..."; - std::unique_ptr img = std::make_unique( + std::unique_ptr img = std::make_unique( vm["width"].as() * vm["height"].as() ); @@ -156,7 +156,7 @@ int main(int argc, char ** argv) } img[vm["height"].as() * x + y] = - static_cast(std::lround( + static_cast(std::lround( 255.f * std::min( std::sqrt( std::pow(p[0] / 0.000299792458f, 2.f) + diff --git a/examples/cuda/render_slice.cu b/examples/cuda/render_slice.cu index 4a57817..89b593d 100644 --- a/examples/cuda/render_slice.cu +++ b/examples/cuda/render_slice.cu @@ -80,7 +80,7 @@ void parse_opts( template __global__ void render( typename field_t::view_t vf, - char * out, + unsigned char * out, unsigned int width, unsigned int height, float z @@ -95,7 +95,7 @@ __global__ void render( typename field_t::output_t p = vf.at(fx * 20000.f - 10000.f, fy * 20000.f - 10000.f, z); - out[height * x + y] = static_cast(std::lround( + out[height * x + y] = static_cast(std::lround( 255.f * std::min( std::sqrt( std::pow(p[0] / 0.000299792458f, 2.f) + @@ -138,10 +138,11 @@ int main(int argc, char ** argv) BOOST_LOG_TRIVIAL(info) << "Allocating device memory for output image..."; - char * img_device; + unsigned char * img_device; cudaErrorCheck(cudaMalloc( - reinterpret_cast(&img_device), width * height * sizeof(char) + reinterpret_cast(&img_device), + width * height * sizeof(unsigned char) )); BOOST_LOG_TRIVIAL(info) << "Rendering magnetic field strength to image..."; @@ -172,14 +173,15 @@ int main(int argc, char ** argv) BOOST_LOG_TRIVIAL(info) << "Allocating host memory for output image..."; - std::unique_ptr img_host = std::make_unique(width * height); + std::unique_ptr img_host = + std::make_unique(width * height); BOOST_LOG_TRIVIAL(info) << "Copying image from device to host..."; cudaErrorCheck(cudaMemcpy( img_host.get(), img_device, - width * height * sizeof(char), + width * height * sizeof(unsigned char), cudaMemcpyDeviceToHost )); diff --git a/examples/cuda/render_slice_texture.cu b/examples/cuda/render_slice_texture.cu index f5553f8..3f00d12 100644 --- a/examples/cuda/render_slice_texture.cu +++ b/examples/cuda/render_slice_texture.cu @@ -81,7 +81,7 @@ void parse_opts( template __global__ void render( typename field_t::view_t vf, - char * out, + unsigned char * out, unsigned int width, unsigned int height, float z @@ -96,7 +96,7 @@ __global__ void render( typename field_t::output_t p = vf.at(fx * 20000.f - 10000.f, fy * 20000.f - 10000.f, z); - out[height * x + y] = static_cast(std::lround( + out[height * x + y] = static_cast(std::lround( 255.f * std::min( std::sqrt( std::pow(p[0] / 0.000299792458f, 2.f) + @@ -141,10 +141,11 @@ int main(int argc, char ** argv) BOOST_LOG_TRIVIAL(info) << "Allocating device memory for output image..."; - char * img_device; + unsigned char * img_device; cudaErrorCheck(cudaMalloc( - reinterpret_cast(&img_device), width * height * sizeof(char) + reinterpret_cast(&img_device), + width * height * sizeof(unsigned char) )); BOOST_LOG_TRIVIAL(info) << "Rendering magnetic field strength to image..."; @@ -175,14 +176,15 @@ int main(int argc, char ** argv) BOOST_LOG_TRIVIAL(info) << "Allocating host memory for output image..."; - std::unique_ptr img_host = std::make_unique(width * height); + std::unique_ptr img_host = + std::make_unique(width * height); BOOST_LOG_TRIVIAL(info) << "Copying image from device to host..."; cudaErrorCheck(cudaMemcpy( img_host.get(), img_device, - width * height * sizeof(char), + width * height * sizeof(unsigned char), cudaMemcpyDeviceToHost ));