diff options
author | artemp <artem@mapnik.org> | 2014-11-13 15:43:35 +0000 |
---|---|---|
committer | artemp <artem@mapnik.org> | 2014-11-13 15:44:03 +0000 |
commit | 9fd9ced95647a721e9c2f7f539ce9dfac3356f43 (patch) | |
tree | 4235a9dacb3dc7b01fce0b60f864556ab1f9a1a8 /platform | |
parent | 5d29742e1c9b944599c100a76a2aecbf87cefa50 (diff) | |
download | qtlocation-mapboxgl-9fd9ced95647a721e9c2f7f539ce9dfac3356f43.tar.gz |
cleanups
Diffstat (limited to 'platform')
-rw-r--r-- | platform/default/jpeg_reader.cpp | 3 | ||||
-rw-r--r-- | platform/default/png_reader.cpp | 23 |
2 files changed, 10 insertions, 16 deletions
diff --git a/platform/default/jpeg_reader.cpp b/platform/default/jpeg_reader.cpp index de93cfad25..3f69337927 100644 --- a/platform/default/jpeg_reader.cpp +++ b/platform/default/jpeg_reader.cpp @@ -278,9 +278,8 @@ void jpeg_reader<T>::read(unsigned x0, unsigned y0, unsigned width, unsigned hei g = r; b = r; } - out_row[x] = (0xff << 24) | (b << 16) | (g << 8) | r;//color(r, g, b, a).rgba(); + out_row[x] = (0xff << 24) | (b << 16) | (g << 8) | r; } - //image.setRow(row - y0, out_row.get(), w); std::copy((char*)out_row.get(), (char*)out_row.get() + w*4, image + (row - y0)*width_*4); } ++row; diff --git a/platform/default/png_reader.cpp b/platform/default/png_reader.cpp index 1780ecf23c..580c174303 100644 --- a/platform/default/png_reader.cpp +++ b/platform/default/png_reader.cpp @@ -173,13 +173,11 @@ void png_reader<T>::init() png_set_sig_bytes(png_ptr,8); png_read_info(png_ptr, info_ptr); - png_uint_32 width, height; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth_, &color_type_,0,0,0); + png_uint_32 w, h; + png_get_IHDR(png_ptr, info_ptr, &w, &h, &bit_depth_, &color_type_,0,0,0); has_alpha_ = (color_type_ & PNG_COLOR_MASK_ALPHA) || png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS); - width_=width; - height_=height; - - //MAPNIK_LOG_DEBUG(png_reader) << "png_reader: bit_depth=" << bit_depth_ << ",color_type=" << color_type_; + width_=w; + height_=h; } template <typename T> @@ -195,7 +193,7 @@ unsigned png_reader<T>::height() const } template <typename T> -void png_reader<T>::read(unsigned x0, unsigned y0, unsigned width, unsigned height, char * image) +void png_reader<T>::read(unsigned x0, unsigned y0, unsigned w, unsigned h, char * image) { stream_.clear(); stream_.seekg(0, std::ios_base::beg); @@ -238,7 +236,7 @@ void png_reader<T>::read(unsigned x0, unsigned y0, unsigned width, unsigned heig if (png_get_gAMA(png_ptr, info_ptr, &gamma)) png_set_gamma(png_ptr, 2.2, gamma); - if (x0 == 0 && y0 == 0 && width >= width_ && height >= height_) + if (x0 == 0 && y0 == 0 && w >= width_ && h >= height_) { if (png_get_interlace_type(png_ptr,info_ptr) == PNG_INTERLACE_ADAM7) { @@ -258,21 +256,18 @@ void png_reader<T>::read(unsigned x0, unsigned y0, unsigned width, unsigned heig else { png_read_update_info(png_ptr, info_ptr); - //unsigned w=std::min(width, width_ - x0); - unsigned h=std::min(height, height_ - y0); + w=std::min(w, width_ - x0); + h=std::min(h, height_ - y0); unsigned rowbytes=png_get_rowbytes(png_ptr, info_ptr); const std::unique_ptr<png_byte[]> row(new png_byte[rowbytes]); - //START read image rows for (unsigned i = 0; i < height_; ++i) { png_read_row(png_ptr,row.get(),0); if (i >= y0 && i < (y0 + h)) { -////image.setRow(i-y0,reinterpret_cast<unsigned*>(&row[x0 * 4]),w); - //std::copy(image, buf + size, pData_ + i * width); + std::copy(&row[x0 * 4], &row[x0 * 4] + w, image + i * width_* 4); } } - //END } png_read_end(png_ptr,0); } |