// Copyright 2009-2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 #pragma once #include "../../../common/sys/platform.h" #include "../../../common/sys/ref.h" #include "../../../common/sys/filename.h" #include "../../../common/math/color.h" #include #include namespace embree { /* virtual interface to image */ class Image : public RefCount { public: Image (size_t width, size_t height, const std::string& name) : width(width), height(height), name(name) {} virtual ~Image() {} virtual Color4 get(size_t x, size_t y) const = 0; virtual void set(size_t x, size_t y, const Color4& c) = 0; void set(size_t x, size_t y, const Color& c) { set(x,y,Color4(c.r,c.g,c.b,1.0f)); } void convertToRGBA8(unsigned char *dest) { for (size_t y=0;y class ImageT : public Image { public: /*! create empty image */ ImageT (size_t width = 0, size_t height = 0, const std::string& name = "") : Image(width,height,name) { data = new T[width*height]; memset(data,0,width*height*sizeof(T)); } /*! create image of constant color */ ImageT (size_t width, size_t height, const T& color, const std::string& name = "") : Image(width,height,name) { data = new T[width*height]; for (size_t i=0; i Image3uc; typedef ImageT Image3f; typedef ImageT Image4uc; typedef ImageT Image4f; /*! Generate a JPEG encoded image from a RGB8 buffer in memory. */ void encodeRGB8_to_JPEG(unsigned char *image, size_t width, size_t height, unsigned char **encoded, unsigned long *capacity); /*! compare two images */ double compareImages(Ref image0, Ref image1); /*! Loads image from file. Format is auto detected. */ Ref loadImage(const FileName& filename, bool cache = false); /*! Loads image from JPEG file. */ Ref loadJPEG(const FileName& fileName); /*! Loads image using OpenImageIO. */ Ref loadOIIO(const FileName& fileName); /*! Loads image using stb_image. */ Ref loadSTB(const FileName& fileName); /*! Loads image from EXR file. */ Ref loadEXR(const FileName& fileName); /*! Loads image from PFM file. */ Ref loadPFM(const FileName& fileName); /*! Loads image from PNG file. */ Ref loadPNG(const FileName& fileName); /*! Loads image from PPM file. */ Ref loadPPM(const FileName& fileName); /*! Loads image from TGA file. */ Ref loadTGA(const FileName& fileName); /*! Loads image from TIFF file. */ //Ref loadTIFF(const FileName& fileName); /*! Store image to file. Format is auto detected. */ void storeImage(const Ref& image, const FileName& filename); /*! Store image to JPEG file. */ void storeJPEG(const Ref& img, const FileName& fileName); /*! Store image to file using OpenImageIO. */ void storeOIIO(const Ref& img, const FileName& fileName); /*! Store image to file using stb_image. */ void storeSTB(const Ref& img, const FileName& fileName); /*! Store image to EXR file. */ void storeEXR(const Ref& img, const FileName& fileName); /*! Store image to PFM file. */ void storePFM(const Ref& img, const FileName& fileName); /*! Store image to PNG file. */ //void storePNG(const Ref& img, const FileName& fileName); /*! Store image to PPM file. */ void storePPM(const Ref& img, const FileName& fileName); /*! Store image to TGA file. */ void storeTga(const Ref& img, const FileName& fileName); /*! Store image to TIFF file. */ //void storeTIFF(const Ref& img, const FileName& fileName); }