From 36081f6486201d9bd316f3a8ceb5a38ad2e97310 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 23 Nov 2015 13:37:00 -0800 Subject: [core] For binary image data use uint8_t, not char --- include/mbgl/map/still_image.hpp | 8 +++----- include/mbgl/platform/default/image_reader.hpp | 4 ++-- include/mbgl/platform/default/jpeg_reader.hpp | 4 ++-- include/mbgl/platform/default/png_reader.hpp | 4 ++-- include/mbgl/util/image.hpp | 8 ++++---- 5 files changed, 13 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/mbgl/map/still_image.hpp b/include/mbgl/map/still_image.hpp index b9ce0620fa..36922fe95a 100644 --- a/include/mbgl/map/still_image.hpp +++ b/include/mbgl/map/still_image.hpp @@ -3,17 +3,15 @@ #include -#include #include namespace mbgl { class StillImage : util::noncopyable { public: - uint16_t width = 0; - uint16_t height = 0; - using Pixel = uint32_t; - std::unique_ptr pixels; + size_t width = 0; + size_t height = 0; + std::unique_ptr pixels; }; } diff --git a/include/mbgl/platform/default/image_reader.hpp b/include/mbgl/platform/default/image_reader.hpp index 52a67a2830..8e293d8be3 100644 --- a/include/mbgl/platform/default/image_reader.hpp +++ b/include/mbgl/platform/default/image_reader.hpp @@ -31,11 +31,11 @@ struct ImageReader : private noncopyable virtual unsigned height() const=0; virtual bool hasAlpha() const=0; virtual bool premultipliedAlpha() const=0; - virtual void read(unsigned x,unsigned y, unsigned width, unsigned height, char* image)=0; + virtual void read(unsigned x, unsigned y, unsigned width, unsigned height, uint8_t* image)=0; virtual ~ImageReader() {} }; -std::unique_ptr getImageReader(char const* data, size_t size); +std::unique_ptr getImageReader(const uint8_t* data, size_t size); }} diff --git a/include/mbgl/platform/default/jpeg_reader.hpp b/include/mbgl/platform/default/jpeg_reader.hpp index 3e64ce291b..d877005354 100644 --- a/include/mbgl/platform/default/jpeg_reader.hpp +++ b/include/mbgl/platform/default/jpeg_reader.hpp @@ -51,13 +51,13 @@ private: unsigned width_; unsigned height_; public: - JpegReader(char const* data, size_t size); + JpegReader(const uint8_t* data, size_t size); ~JpegReader(); unsigned width() const; unsigned height() const; inline bool hasAlpha() const { return false; } inline bool premultipliedAlpha() const { return true; } - void read(unsigned x,unsigned y, unsigned w, unsigned h, char *image); + void read(unsigned x, unsigned y, unsigned w, unsigned h, uint8_t* image); private: void init(); static void on_error(j_common_ptr cinfo); diff --git a/include/mbgl/platform/default/png_reader.hpp b/include/mbgl/platform/default/png_reader.hpp index 5cbbc51e77..9d6af91daa 100644 --- a/include/mbgl/platform/default/png_reader.hpp +++ b/include/mbgl/platform/default/png_reader.hpp @@ -49,13 +49,13 @@ private: int color_type_; bool has_alpha_; public: - PngReader(char const* data, std::size_t size); + PngReader(const uint8_t* data, std::size_t size); ~PngReader(); unsigned width() const; unsigned height() const; inline bool hasAlpha() const { return has_alpha_; } bool premultipliedAlpha() const { return true; } // png_set_alpha_mode(png, PNG_ALPHA_PREMULTIPLIED, 2.2) - void read(unsigned x,unsigned y, unsigned width, unsigned height, char * image); + void read(unsigned x,unsigned y, unsigned width, unsigned height, uint8_t* image); private: void init(); static void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length); diff --git a/include/mbgl/util/image.hpp b/include/mbgl/util/image.hpp index f58c2c0989..fc4078501e 100644 --- a/include/mbgl/util/image.hpp +++ b/include/mbgl/util/image.hpp @@ -7,14 +7,14 @@ namespace mbgl { namespace util { -std::string compress_png(int width, int height, const void *rgba); +std::string compress_png(size_t width, size_t height, const uint8_t* rgba); class Image { public: - explicit Image(const std::string &img); + explicit Image(const std::string& img); - inline const char *getData() const { return img.get(); } + inline const uint8_t* getData() const { return img.get(); } inline uint32_t getWidth() const { return width; } inline uint32_t getHeight() const { return height; } inline operator bool() const { return img && width && height; } @@ -24,7 +24,7 @@ private: uint32_t width = 0, height = 0; // the raw image data - std::unique_ptr img; + std::unique_ptr img; }; -- cgit v1.2.1