xtd 1.0.0
Loading...
Searching...
No Matches
image.hpp
Go to the documentation of this file.
1
4#pragma once
14#include "graphics.hpp"
15#include "graphics_unit.hpp"
16#include "rectangle.hpp"
17#include "rotate_flip_type.hpp"
18#include "size.hpp"
19#include "size_f.hpp"
20#include <xtd/any_object>
21#include <xtd/iequatable>
22#include <xtd/object>
23#include <xtd/string>
24
26namespace xtd {
28 namespace drawing {
30 class bitmap;
31 namespace imaging::effects {
32 struct resize_effect;
33 struct scale_effect;
34 }
36
49 class drawing_export_ image : public xtd::object, public xtd::iequatable<image> {
50 struct data;
51
52 public:
54 image();
55 image(image&&) = default;
56 image(const image& image) = default;
57 image& operator =(const image& image) = default;
58 ~image();
60
62
65 static image empty;
67
69
77 [[nodiscard]] auto alpha() const -> const xtd::byte*;
78
85 [[nodiscard]] auto alpha() -> xtd::byte*;
86
107 [[nodiscard]] auto flags() const noexcept -> xtd::int32;
108
114 [[nodiscard]] auto frame_dimentions_list() const noexcept -> xtd::array<guid>;
115
118 [[nodiscard]] auto handle() const noexcept -> xtd::intptr;
119
122 [[nodiscard]] auto height() const noexcept -> xtd::int32;
123
126 [[nodiscard]] auto horizontal_resolution() const noexcept -> float;
127
131 [[nodiscard]] auto palette() const noexcept -> xtd::drawing::imaging::color_palette;
134 auto palette(const xtd::drawing::imaging::color_palette& palette) noexcept -> void;
135
139 [[nodiscard]] auto physical_dimension() const noexcept -> const xtd::drawing::size_f&;
140
143 [[nodiscard]] auto pixel_format() const noexcept -> xtd::drawing::imaging::pixel_format;
144
148 [[nodiscard]] auto property_id_list() const noexcept -> const xtd::array<xtd::int32>&;
149
153 [[nodiscard]] auto property_items() const noexcept -> const xtd::array<xtd::drawing::imaging::property_item>&;
154
157 [[nodiscard]] auto raw_format() const noexcept -> const xtd::drawing::imaging::image_format&;
158
166 [[nodiscard]] auto rgb() const -> const xtd::byte*;
167
175 [[nodiscard]] auto rgb() -> xtd::byte*;
176
179 [[nodiscard]] auto size() const noexcept -> const xtd::drawing::size&;
180
183 [[nodiscard]] auto tag() const noexcept -> const xtd::any_object&;
186 auto tag(const xtd::any_object& tag) noexcept -> void;
187
190 [[nodiscard]] auto vertical_resolution() const noexcept -> float;
191
194 [[nodiscard]] auto width() const noexcept -> xtd::int32;
196
198
202 [[nodiscard]] auto clone() const -> image;
203
206 [[nodiscard]] auto create_graphics() -> xtd::drawing::graphics;
207
211 [[nodiscard]] auto equals(const object& obj) const noexcept -> bool override;
215 [[nodiscard]] auto equals(const image& other) const noexcept -> bool override;
216
220 [[nodiscard]] auto get_bounds(xtd::drawing::graphics_unit page_unit) const noexcept -> xtd::drawing::rectangle_f;
221
225 [[nodiscard]] auto get_encoder_parameter_list(xtd::guid encoder) const noexcept -> xtd::drawing::imaging::encoder_parameters;
226
233 [[nodiscard]] auto get_frame_count(const xtd::drawing::imaging::frame_dimension& dimension) const -> xtd::usize;
234
237 [[nodiscard]] auto get_hash_code() const noexcept -> xtd::usize override;
238
245 [[nodiscard]] auto get_property_item(int32 propid) -> xtd::drawing::imaging::property_item;
246
253 [[nodiscard]] auto get_thmbnail_image(int32 thumb_width, int32 thunb_height) noexcept -> xtd::drawing::image;
254
260
265 auto save(const xtd::string& filename) const -> void;
269 auto save(const xtd::string& filename, const xtd::drawing::imaging::image_format& format) const -> void;
275 auto save(std::ostream& stream, const xtd::drawing::imaging::image_format& format) const -> void;
277
279
284 [[nodiscard]] static auto from_file(const xtd::string& filename) -> image;
285
290 [[nodiscard]] static auto from_hbitmap(xtd::intptr hbitmap) -> bitmap;
291
297 [[nodiscard]] static auto from_stream(std::istream& stream) -> image;
298
306 [[nodiscard]] static auto from_xbm_data(const unsigned char* bits, int32 width, int32 height) -> bitmap;
307
313 [[nodiscard]] static auto from_xpm_data(const char* const* bits) -> bitmap;
314
318 [[nodiscard]] static auto get_pixel_format_size(xtd::drawing::imaging::pixel_format pixfmt) noexcept -> xtd::int32;
319
323 [[nodiscard]] static auto is_alpha_pixel_format(xtd::drawing::imaging::pixel_format pixfmt) noexcept -> bool;
324
328 [[nodiscard]] static auto is_canonical_pixel_format(xtd::drawing::imaging::pixel_format pixfmt) noexcept -> bool;
329
333 [[nodiscard]] static auto is_extended_pixel_format(xtd::drawing::imaging::pixel_format pixfmt) noexcept -> bool;
335
336 protected:
338 friend xtd::drawing::imaging::effects::resize_effect;
339 friend xtd::drawing::imaging::effects::scale_effect;
340 explicit image(xtd::intptr hbitmap);
341 explicit image(const xtd::string& filename);
342 explicit image(const xtd::string& filename, bool use_icm);
343 explicit image(std::istream& stream);
344 explicit image(std::istream& stream, bool use_icm);
350 image(const image& image, const xtd::drawing::rectangle& rect);
351 [[nodiscard]] static auto from_hicon(xtd::intptr hicon) -> image;
352 [[nodiscard]] auto get_pixel(xtd::int32 x, xtd::int32 y) const -> xtd::drawing::color;
353 auto resize(const xtd::drawing::rectangle& rect, const xtd::drawing::color& fill_color) -> void;
354 auto scale(const xtd::drawing::size& size, xtd::drawing::drawing_2d::interpolation_mode interpolation_mode) -> void;
355 auto set_pixel(xtd::int32 x, xtd::int32 y, const xtd::drawing::color& color) -> void;
356 auto set_pixel_format(xtd::drawing::imaging::pixel_format value) -> void;
358
359 private:
360 auto update_properties() -> void;
361
362 xtd::sptr<data> data_;
363 };
364 }
365}
366
367#include "../literals/system_images.hpp"
Represent a polymorphic wrapper capable of holding any type.
Definition any_object.hpp:29
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes....
Definition bitmap.hpp:26
Represents an ARGB (alpha, red, green, blue) color.
Definition color.hpp:52
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition graphics.hpp:67
An abstract base class that provides functionality for the bitmap and metafile descended classes.
Definition image.hpp:49
auto width() const noexcept -> xtd::int32
Gets the width, in pixels, of this image.
auto handle() const noexcept -> xtd::intptr
Gets the handle of this image.
static auto is_canonical_pixel_format(xtd::drawing::imaging::pixel_format pixfmt) noexcept -> bool
Returns a value that indicates whether the pixel format is 32 bits per pixel.
auto get_bounds(xtd::drawing::graphics_unit page_unit) const noexcept -> xtd::drawing::rectangle_f
Gets the bounds of the image in the specified unit.
auto raw_format() const noexcept -> const xtd::drawing::imaging::image_format &
Gets the file format of this image.
auto horizontal_resolution() const noexcept -> float
Gets the horizontal resolution, in pixels per inch, of this image.
static auto from_hbitmap(xtd::intptr hbitmap) -> bitmap
Creates a xtd::drawing::bitmap from a handle to a GDI bitmap.
auto get_thmbnail_image(int32 thumb_width, int32 thunb_height) noexcept -> xtd::drawing::image
Returns a thumbnail for this xtd::drawing::image.
auto tag() const noexcept -> const xtd::any_object &
Gets an object that provides additional data about the image.
static auto from_xpm_data(const char *const *bits) -> bitmap
Creates an xtd::drawing::image from the specified data pointer.
auto clone() const -> image
Creates an exact copy of this xtd::drawing::image.
auto vertical_resolution() const noexcept -> float
Gets the vertical resolution, in pixels per inch, of this image.
auto size() const noexcept -> const xtd::drawing::size &
Gets the width and height, in pixels, of this image.
static auto get_pixel_format_size(xtd::drawing::imaging::pixel_format pixfmt) noexcept -> xtd::int32
Returns the color depth, in number of bits per pixel, of the specified pixel format.
auto get_encoder_parameter_list(xtd::guid encoder) const noexcept -> xtd::drawing::imaging::encoder_parameters
Returns information about the parameters supported by the specified image encoder.
static auto from_stream(std::istream &stream) -> image
Creates an xtd::drawing::image from the specified data stream.
auto palette() const noexcept -> xtd::drawing::imaging::color_palette
Gets the color palette used for this image.
static auto from_xbm_data(const unsigned char *bits, int32 width, int32 height) -> bitmap
Creates an xtd::drawing::image from the specified data pointer, width and hieght.
auto flags() const noexcept -> xtd::int32
Gets attribute flags for the pixel data of this xtd::drawing::image.
static auto is_extended_pixel_format(xtd::drawing::imaging::pixel_format pixfmt) noexcept -> bool
Returns a value that indicates whether the pixel format is 64 bits per pixel.
static image empty
Represent an empty xtd::drawing::image.
Definition image.hpp:65
auto rgb() const -> const xtd::byte *
Gets the image data pointer, which represents the RGB data of the image.
auto frame_dimentions_list() const noexcept -> xtd::array< guid >
Gets an array of GUIDs that represent the dimensions of frames within this image.
auto get_property_item(int32 propid) -> xtd::drawing::imaging::property_item
Gets the specified property item from this xtd::drawing::image.
auto equals(const object &obj) const noexcept -> bool override
Determines whether the specified object is equal to the current object.
auto pixel_format() const noexcept -> xtd::drawing::imaging::pixel_format
Gets the pixel format for this image.
auto rotate_flip(xtd::drawing::rotate_flip_type rotate_flip_type) -> void
Rotates, flips, or rotates and flips the xtd::drawing::image.
auto get_hash_code() const noexcept -> xtd::usize override
Serves as a hash function for a particular type.
auto property_items() const noexcept -> const xtd::array< xtd::drawing::imaging::property_item > &
Gets all the property items (pieces of metadata) stored in this image.
auto alpha() const -> const xtd::byte *
Gets the image alpha pointer, which represents the alpha data of the image.
static auto from_file(const xtd::string &filename) -> image
Creates an image from the specified file.
auto save(const xtd::string &filename) const -> void
Saves this xtd::drawing::image to the specified file or stream.
auto create_graphics() -> xtd::drawing::graphics
Creates the xtd::drawing::graphics for the image.
auto get_frame_count(const xtd::drawing::imaging::frame_dimension &dimension) const -> xtd::usize
Returns the number of frames of the specified dimension.
static auto is_alpha_pixel_format(xtd::drawing::imaging::pixel_format pixfmt) noexcept -> bool
Returns a value that indicates whether the pixel format for this xtd::drawing::image contains alpha i...
auto height() const noexcept -> xtd::int32
Gets the height, in pixels, of this image.
auto property_id_list() const noexcept -> const xtd::array< xtd::int32 > &
Gets IDs of the property items stored in this image.
auto physical_dimension() const noexcept -> const xtd::drawing::size_f &
Gets the width and height of this image.
Represents a globally unique identifier (GUID). A GUID is a 128-bit integer (16 bytes) that can be us...
Definition guid.hpp:23
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
Contains xtd::drawing::imaging::color_palette class.
Contains drawing_export_ keyword.
Contains xtd::drawing::imaging::encoder_parameters struct.
Contains xtd::drawing::imaging::frame_dimension class.
Contains xtd::drawing::graphics class.
Contains xtd::drawing::graphics_unit enum class.
auto format(const xtd::string &fmt, args_t &&... args) -> xtd::string
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition format.hpp:21
#define drawing_export_
Define shared library export.
Definition drawing_export.hpp:13
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
std::intmax_t intptr
Represent a pointer or a handle.
Definition intptr.hpp:23
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:25
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
graphics_unit
Specifies the unit of measure for the given data. This enumeration has a flags attribute that allows ...
Definition graphics_unit.hpp:17
rotate_flip_type
Specifies how much an image is rotated and the axis used to flip the image.
Definition rotate_flip_type.hpp:19
Contains xtd::drawing::imaging::image_flags class.
Contains xtd::drawing::imaging::image_format class.
Contains xtd::drawing::drawing_2d::interpolation_mode enum class.
The xtd::drawing::drawing_2d namespace provides advanced two-dimensional and vector graphics function...
Definition compositing_mode.hpp:12
The xtd::drawing::imaging::effects namespace provides functionality for adding effects to images.
Definition bitonal_effect.hpp:16
The xtd::drawing::imaging namespace provides advanced GDI+ imaging functionality. Basic graphics func...
Definition bitmap_data.hpp:15
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
constexpr auto data() const noexcept -> const_pointer
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:197
Contains xtd::drawing::imaging::pixel_format enum class.
Contains xtd::drawing::imaging::property_item class.
Contains xtd::drawing::rectangle struct.
Contains xtd::drawing::rotate_flip_type enum class.
Contains xtd::drawing::size struct.
Contains xtd::drawing::size_f struct.
The xtd::drawing::imaging::effects::resize_effect resizes the image with new rectangle and optionnaly...
Definition resize_effect.hpp:35
The xtd::drawing::imaging::effects::scale_effect scales the image with new size.
Definition scale_effect.hpp:35
Stores a set of four floating-point numbers that represent the location and size of a rectangle....
Definition rectangle_f.hpp:34
Stores a set of four integers that represent the location and size of a rectangle.
Definition rectangle.hpp:44
Stores an ordered pair of floating-point, which specify a height and width.
Definition size_f.hpp:32