xtd - Reference Guide  0.1.2
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
image.h
Go to the documentation of this file.
1
4#pragma once
5#include <any>
6#include <cstdint>
7#include <memory>
8#include <iostream>
9#include <xtd/object.h>
10#include <xtd/ustring.h>
11#include "../drawing_export.h"
14#include "imaging/image_flags.h"
18#include "graphics.h"
19#include "rectangle.h"
20#include "size.h"
21#include "size_f.h"
22
24namespace xtd {
26 namespace drawing {
34 class drawing_export_ image : public object {
35 public:
37 image() = default;
38 image(const image& image) = default;
39 image& operator=(const image& image) = default;
40 ~image();
41 bool operator==(const image& image) const {return data_->handle_ == image.data_->handle_;}
42 bool operator!=(const image& image) const {return !operator==(image);}
44
65 int32_t flags() const {return static_cast<int32_t>(data_->flags_);}
66
72 const std::vector<guid>& frame_dimentions_list() const {return data_->frame_dimentions_list_;}
73
76 intptr_t handle() const {return data_->handle_;}
77
80 int32_t height() const {return data_->size_.height();}
81
84 float horizontal_resolution() const {return data_->horizontal_resolution_;}
85
89 imaging::color_palette palette() const {return data_->palette_;}
92 void palette(const imaging::color_palette& palette) {data_->palette_ = palette;}
93
97 const size_f& physical_dimension() const {return data_->physical_dimension_;}
98
101 imaging::pixel_format pixel_format() const {return data_->pixel_format_;}
102
106 const std::vector<int32_t>& property_id_list() const {return data_->property_id_list_;}
107
111 const std::vector<imaging::property_item>& property_items() const {return data_->property_ityems_;}
112
115 const imaging::image_format& raw_format() const {return data_->raw_format_;}
116
119 const drawing::size& size() const {return data_->size_;}
120
123 const std::any& tag() const {return data_->tag_;}
126 void tag(const std::any& tag) {data_->tag_ = tag;}
127
130 float vertical_resolution() const {return data_->vertical_resolution_;}
131
134 int32_t width() const {return data_->size_.width();}
135
139 graphics create_graphics() {return graphics::from_image(*this);}
140
141 static image from_hbitmap(intptr_t hbitmap) {return image(hbitmap);}
142
146 static image from_file(const xtd::ustring& filename) {return image(filename);}
147
148 static image from_stream(std::istream& stream) {return image(stream);}
149
150 static image from_data(const char* const* bits) {return image(bits);}
151
152 void save(const xtd::ustring& filename) const;
153 void save(const xtd::ustring& filename, const imaging::image_format& format) const;
154 void save(std::ostream& stream, const imaging::image_format& format) const;
155
156 static image empty;
157
158 protected:
159 explicit image(intptr_t hbitmap);
160 explicit image(const xtd::ustring& fileName);
161 explicit image(std::istream& stream);
162 explicit image(const char* const* bits);
163 image(int32_t width, int32_t height);
164 image(const image& image, int32_t width, int32_t height);
165 image(const image& image, const rectangle& rect);
166 void update_properties();
167
168 struct data {
169 imaging::image_flags flags_ = imaging::image_flags::none;
170 std::vector<guid> frame_dimentions_list_;
171 intptr_t handle_ = 0;
172 float horizontal_resolution_ = .0f;
173 imaging::color_palette palette_;
174 imaging::pixel_format pixel_format_ = imaging::pixel_format::undefined;
175 size_f physical_dimension_;
176 std::vector<int32_t> property_id_list_;
177 std::vector<imaging::property_item> property_ityems_;
178 imaging::image_format raw_format_;
179 drawing::size size_;
180 std::any tag_;
181 float vertical_resolution_ = .0f;
182 };
183 std::shared_ptr<data> data_ = std::make_shared<data>();
184 };
185 }
186}
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition graphics.h:48
An abstract base class that provides functionality for the bitmap and metafile descended classes.
Definition image.h:34
void palette(const imaging::color_palette &palette)
Sets the color palette used for this image.
Definition image.h:92
const size_f & physical_dimension() const
Gets the width and height of this image.
Definition image.h:97
const drawing::size & size() const
Gets the width and height, in pixels, of this image.
Definition image.h:119
static image from_file(const xtd::ustring &filename)
Creates an image from the specified file.
Definition image.h:146
int32_t flags() const
Gets attribute flags for the pixel data of this Image.
Definition image.h:65
imaging::color_palette palette() const
Gets the color palette used for this image.
Definition image.h:89
const std::vector< int32_t > & property_id_list() const
Gets IDs of the property items stored in this image.
Definition image.h:106
imaging::pixel_format pixel_format() const
Gets the pixel format for this image.
Definition image.h:101
const imaging::image_format & raw_format() const
Gets the file format of this image.
Definition image.h:115
int32_t width() const
Gets the width, in pixels, of this image.
Definition image.h:134
const std::vector< imaging::property_item > & property_items() const
Gets all the property items (pieces of metadata) stored in this image.
Definition image.h:111
void tag(const std::any &tag)
Sets an object that provides additional data about the image.
Definition image.h:126
float horizontal_resolution() const
Gets the horizontal resolution, in pixels per inch, of this image.
Definition image.h:84
const std::any & tag() const
Gets an object that provides additional data about the image.
Definition image.h:123
intptr_t handle() const
Get the handle of this image.
Definition image.h:76
int32_t height() const
Gets the height, in pixels, of this image.
Definition image.h:80
const std::vector< guid > & frame_dimentions_list() const
Gets an array of GUIDs that represent the dimensions of frames within this image.
Definition image.h:72
float vertical_resolution() const
Gets the vertical resolution, in pixels per inch, of this image.
Definition image.h:130
Defines an array of colors that make up a color palette. The colors are 32-bit ARGB colors....
Definition color_palette.h:29
Specifies the file format of the image. Not inheritable.
Definition image_format.h:25
Stores an ordered pair of floating-point, which specify a height and width.
Definition size_f.h:24
Stores an ordered pair of integers, which specify a height and width.
Definition size.h:25
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:26
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:48
Contains xtd::drawing::imaging::color_palette class.
Contains xtd::drawing::imaging::frame_dimension class.
Contains xtd::drawing::graphics class.
graphics create_graphics()
Creates the xtd::drawing::graphics for the image.
Definition image.h:139
#define drawing_export_
Define shared library export.
Definition drawing_export.h:13
image_flags
Specifies the attributes of the pixel data contained in an xtd::drawing::image object....
Definition image_flags.h:22
pixel_format
Specifies the format of the color data for each pixel in the image.
Definition pixel_format.h:25
Contains xtd::drawing::imaging::image_flags class.
Contains xtd::drawing::imaging::image_format class.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition system_report.h:17
Contains xtd::object class.
Contains xtd::drawing::imaging::pixel_format enum class.
Contains xtd::drawing::imaging::property_item class.
Contains xtd::drawing::rectangle class.
Contains xtd::drawing::size class.
Contains xtd::drawing::size_f class.
Definition image.h:168
Contains xtd::ustring class.