1141cc406Sopenharmony_ci/* sane - Scanner Access Now Easy. 2141cc406Sopenharmony_ci 3141cc406Sopenharmony_ci Copyright (C) 2019 Povilas Kanapickas <povilas@radix.lt> 4141cc406Sopenharmony_ci 5141cc406Sopenharmony_ci This file is part of the SANE package. 6141cc406Sopenharmony_ci 7141cc406Sopenharmony_ci This program is free software; you can redistribute it and/or 8141cc406Sopenharmony_ci modify it under the terms of the GNU General Public License as 9141cc406Sopenharmony_ci published by the Free Software Foundation; either version 2 of the 10141cc406Sopenharmony_ci License, or (at your option) any later version. 11141cc406Sopenharmony_ci 12141cc406Sopenharmony_ci This program is distributed in the hope that it will be useful, but 13141cc406Sopenharmony_ci WITHOUT ANY WARRANTY; without even the implied warranty of 14141cc406Sopenharmony_ci MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15141cc406Sopenharmony_ci General Public License for more details. 16141cc406Sopenharmony_ci 17141cc406Sopenharmony_ci You should have received a copy of the GNU General Public License 18141cc406Sopenharmony_ci along with this program. If not, see <https://www.gnu.org/licenses/>. 19141cc406Sopenharmony_ci*/ 20141cc406Sopenharmony_ci 21141cc406Sopenharmony_ci#ifndef BACKEND_GENESYS_IMAGE_H 22141cc406Sopenharmony_ci#define BACKEND_GENESYS_IMAGE_H 23141cc406Sopenharmony_ci 24141cc406Sopenharmony_ci#include "image_pixel.h" 25141cc406Sopenharmony_ci#include <vector> 26141cc406Sopenharmony_ci 27141cc406Sopenharmony_cinamespace genesys { 28141cc406Sopenharmony_ci 29141cc406Sopenharmony_ciclass Image 30141cc406Sopenharmony_ci{ 31141cc406Sopenharmony_cipublic: 32141cc406Sopenharmony_ci Image(); 33141cc406Sopenharmony_ci Image(std::size_t width, std::size_t height, PixelFormat format); 34141cc406Sopenharmony_ci 35141cc406Sopenharmony_ci std::size_t get_width() const { return width_; } 36141cc406Sopenharmony_ci std::size_t get_height() const { return height_; } 37141cc406Sopenharmony_ci PixelFormat get_format() const { return format_; } 38141cc406Sopenharmony_ci std::size_t get_row_bytes() const { return row_bytes_; } 39141cc406Sopenharmony_ci 40141cc406Sopenharmony_ci std::uint8_t* get_row_ptr(std::size_t y); 41141cc406Sopenharmony_ci const std::uint8_t* get_row_ptr(std::size_t y) const; 42141cc406Sopenharmony_ci 43141cc406Sopenharmony_ci Pixel get_pixel(std::size_t x, std::size_t y) const; 44141cc406Sopenharmony_ci void set_pixel(std::size_t x, std::size_t y, const Pixel& pixel); 45141cc406Sopenharmony_ci 46141cc406Sopenharmony_ci RawPixel get_raw_pixel(std::size_t x, std::size_t y) const; 47141cc406Sopenharmony_ci std::uint16_t get_raw_channel(std::size_t x, std::size_t y, unsigned channel) const; 48141cc406Sopenharmony_ci void set_raw_pixel(std::size_t x, std::size_t y, const RawPixel& pixel); 49141cc406Sopenharmony_ci 50141cc406Sopenharmony_ci void resize(std::size_t width, std::size_t height, PixelFormat format); 51141cc406Sopenharmony_ciprivate: 52141cc406Sopenharmony_ci std::size_t width_ = 0; 53141cc406Sopenharmony_ci std::size_t height_ = 0; 54141cc406Sopenharmony_ci PixelFormat format_ = PixelFormat::UNKNOWN; 55141cc406Sopenharmony_ci std::size_t row_bytes_ = 0; 56141cc406Sopenharmony_ci std::vector<std::uint8_t> data_; 57141cc406Sopenharmony_ci}; 58141cc406Sopenharmony_ci 59141cc406Sopenharmony_civoid convert_pixel_row_format(const std::uint8_t* in_data, PixelFormat in_format, 60141cc406Sopenharmony_ci std::uint8_t* out_data, PixelFormat out_format, std::size_t count); 61141cc406Sopenharmony_ci 62141cc406Sopenharmony_civoid write_tiff_file(const std::string& filename, const void* data, int depth, 63141cc406Sopenharmony_ci int channels, int pixels_per_line, int lines); 64141cc406Sopenharmony_ci 65141cc406Sopenharmony_civoid write_tiff_file(const std::string& filename, const Image& image); 66141cc406Sopenharmony_ci 67141cc406Sopenharmony_ci} // namespace genesys 68141cc406Sopenharmony_ci 69141cc406Sopenharmony_ci#endif // ifndef BACKEND_GENESYS_IMAGE_H 70