API Documentation
Loading...
Searching...
No Matches
ImageFactory.h
Go to the documentation of this file.
1/**--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Design
28File: ImageFactory
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/Dictionary.h>
35#include <NDEVR/String.h>
36#include <NDEVR/LABColor.h>
37#include <NDEVR/File.h>
38#include <NDEVR/RWLock.h>
39namespace NDEVR
40{
41 class RLock;
42 class FileFormat;
57 {
58 virtual bool readFromFormat(ImageDataStream& data) = 0;
59 virtual bool writeToFormat(ImageDataStream& data) = 0;
60 virtual Buffer<String> supportedFormats() const = 0;
61 };
63 {
64 public:
67 void addImageFile(const String& image_id, const File& file, bool clear_other);
68 void addImageUncompressed(const String& image_id, const Buffer<uint01>& uncompressed, bool clear_other);
69 void addImageUncompressed(const String& image_id, const Buffer<uint01>& uncompressed, const Vector<2, uint04>& size, bool clear_other);
70 void addImageCompressed(const String& image_id, const String& extension, const Buffer<uint01>& compressed, bool clear_other);
71 void addImageCompressed(const String& image_id, const Buffer<uint01>& compressed, bool clear_other);
72 void readFromFile(const String& image_id);
73 void readFromFile(const String& image_id, String format_extension);
74 void writeToFile(const String& image_id, const File& file);
75 static void WriteToFile(const uint01* data, Vector<2, uint04> size, uint04 px_size, const File& file, fltp08 write_quality = 1.0);
76 void readFromCompressed(const String& image_id);
77 Time modifiedTime(const String& image_id) const;
78 void convertDirectory(const File& directory, const String& from_ext, const String& to_ext);
79 bool hasImage(const String& image_id);
80 void copyImage(const String& image_id_destination, const String& image_id_source);
81 const Buffer<uint01>& getUncompressed(const String& image_id);
82 const Buffer<uint01>& getCompressed(const String& image_id, const String& default_extension = ".png");
83 const Buffer<uint01>& getCompressedInFormat(const String& image_id, const String& default_extension);
84 const File& getFile(const String& image_id);
85 void convertColorTheme(const Buffer<std::pair<LABColor, LABColor>, uint04, ObjectAllocator<true>>& color, String& image, bool preserve_brightness, bool preserve_alpha);
86 String optimizedWriteFileName(const String& image_id, const Buffer<String>& optional_extenstions = Buffer<String>());
87 bool hasTransparency(const String& image_id);
88 const Vector<2, uint04>& getSize(const String& image_id);
91 bool canRead(const File& file);
92 void setWriteQuality(fltp08 quality);
94 static void ReadJPG(const uint01* input, uint04 input_length, uint01* buffer, bool has_alpha, uint04 dst_line_span, const Vector<2, uint04>& offset);
95 void readFromBMP(const String& image_id);
96 protected:
105 fltp08 m_write_quality = 1.0;
106 };
108 {
109 public:
110 ImageData(const String& id, ImageFactory& image_factory);
111 ImageData(const ImageData& data);
112 ImageData(ImageData&& data) noexcept;
114 [[nodiscard]] const File& file() const;
115 [[nodiscard]] const Buffer<uint01>& getUncompressed() const;
116 [[nodiscard]] const Buffer<uint01>& getCompressed(const String& default_image_format) const;
117 [[nodiscard]] const Vector<2, uint04>& size() const;
118 [[nodiscard]] Time modifiedTime() const;
119 [[nodiscard]] String compressionFormat() const;
120 protected:
123 };
124}
125
126
127
#define NDEVR_DESIGN_API
Definition DLLInfo.h:77
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
Definition Dictionary.h:48
Definition FileFormat.h:38
Definition File.h:47
Definition ImageFactory.h:108
const Vector< 2, uint04 > & size() const
const Buffer< uint01 > & getUncompressed() const
String compressionFormat() const
const String m_id
Definition ImageFactory.h:122
ImageData(ImageData &&data) noexcept
const File & file() const
ImageData(const String &id, ImageFactory &image_factory)
Time modifiedTime() const
const Buffer< uint01 > & getCompressed(const String &default_image_format) const
ImageFactory & m_image_factory
Definition ImageFactory.h:121
ImageData(const ImageData &data)
Definition ImageFactory.h:63
void copyImage(const String &image_id_destination, const String &image_id_source)
static void WriteToFile(const uint01 *data, Vector< 2, uint04 > size, uint04 px_size, const File &file, fltp08 write_quality=1.0)
const Buffer< uint01 > & getCompressed(const String &image_id, const String &default_extension=".png")
void readFromFile(const String &image_id)
Dictionary< String, File > m_image_files
Definition ImageFactory.h:102
Dictionary< String, Buffer< uint01 > > m_image_decompressed_data
Definition ImageFactory.h:99
static ImageFactory & DefaultFactory()
bool canRead(const File &file)
void addImageUncompressed(const String &image_id, const Buffer< uint01 > &uncompressed, const Vector< 2, uint04 > &size, bool clear_other)
const Vector< 2, uint04 > & getSize(const String &image_id)
Dictionary< String, Time > m_image_modified_time
Definition ImageFactory.h:97
void convertColorTheme(const Buffer< std::pair< LABColor, LABColor >, uint04, ObjectAllocator< true > > &color, String &image, bool preserve_brightness, bool preserve_alpha)
void convertDirectory(const File &directory, const String &from_ext, const String &to_ext)
Dictionary< String, Vector< 2, uint04 > > m_image_size
Definition ImageFactory.h:98
Dictionary< String, String > m_image_compression_format
Definition ImageFactory.h:101
Dictionary< String, ImageFormatHandler * > m_format_handlers
Definition ImageFactory.h:104
void addImageCompressed(const String &image_id, const Buffer< uint01 > &compressed, bool clear_other)
void writeToFile(const String &image_id, const File &file)
void readFromCompressed(const String &image_id)
bool hasImage(const String &image_id)
Time modifiedTime(const String &image_id) const
const File & getFile(const String &image_id)
virtual void getSupportedFormats(Buffer< FileFormat, uint04, ObjectAllocator< false > > &formats) const
bool hasTransparency(const String &image_id)
void addImageUncompressed(const String &image_id, const Buffer< uint01 > &uncompressed, bool clear_other)
void setWriteQuality(fltp08 quality)
void addImageCompressed(const String &image_id, const String &extension, const Buffer< uint01 > &compressed, bool clear_other)
Dictionary< String, Buffer< uint01 > > m_image_compressed_data
Definition ImageFactory.h:100
String optimizedWriteFileName(const String &image_id, const Buffer< String > &optional_extenstions=Buffer< String >())
void readFromBMP(const String &image_id)
void readFromFile(const String &image_id, String format_extension)
String compressionFormat(const String &image_id)
void addImageFile(const String &image_id, const File &file, bool clear_other)
const Buffer< uint01 > & getUncompressed(const String &image_id)
Dictionary< String, bool > m_has_transparency
Definition ImageFactory.h:103
static void ReadJPG(const uint01 *input, uint04 input_length, uint01 *buffer, bool has_alpha, uint04 dst_line_span, const Vector< 2, uint04 > &offset)
const Buffer< uint01 > & getCompressedInFormat(const String &image_id, const String &default_extension)
Definition ImageFactory.h:57
Definition MemoryManager.h:283
Definition RWLock.h:80
Definition String.h:40
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
Definition RWLock.h:99
Definition ACIColor.h:37
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:98
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
Definition ImageFactory.h:44
uint01 * compressed_data
Definition ImageFactory.h:47
Vector< 2, uint04 > image_size
Definition ImageFactory.h:52
fltp08 quality
Definition ImageFactory.h:53
File file
Definition ImageFactory.h:45
uint01 * bitmap_data
Definition ImageFactory.h:49
Vector< 2, uint04 > bitmap_offset
Definition ImageFactory.h:51
bool has_alpha
Definition ImageFactory.h:54
uint04 bitmap_line_span
Definition ImageFactory.h:50
uint04 compressed_length
Definition ImageFactory.h:48
String format
Definition ImageFactory.h:46