/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Copyright 2011-2015 Danny Robson */ #ifndef __UTIL_IMAGE_HPP #define __UTIL_IMAGE_HPP #include #include #include #include namespace util { namespace image { template struct buffer { typedef T value_type; buffer (size_t w, size_t h); buffer (size_t w, size_t h, size_t s); buffer (size_t w, size_t h, size_t s, std::unique_ptr &&data); buffer (const buffer&) = delete; buffer (buffer &&) = default; void fill (T); template buffer alloc (void) const; template buffer clone (void) const; buffer downsample (float factor) const; size_t w; size_t h; size_t s; std::unique_ptr data; }; } struct pgm { static image::buffer read (const boost::filesystem::path&); static void write (const image::buffer &src, const boost::filesystem::path &); static void write (const uint8_t *restrict pixels, size_t width, size_t height, size_t stride, const boost::filesystem::path &path); }; struct ppm { static void write (const uint8_t *restrict pixels, size_t width, size_t height, size_t stride, const boost::filesystem::path &path); }; } #endif