xtd 0.2.0
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 const xtd::byte* alpha() const;
78
86
107 int32 flags() const noexcept;
108
115
118 intptr handle() const noexcept;
119
122 int32 height() const noexcept;
123
126 float horizontal_resolution() const noexcept;
127
131 imaging::color_palette palette() const noexcept;
134 void palette(const imaging::color_palette& palette) noexcept;
135
139 const size_f& physical_dimension() const noexcept;
140
144
148 const xtd::array<int32>& property_id_list() const noexcept;
149
153 const xtd::array<imaging::property_item>& property_items() const noexcept;
154
157 const imaging::image_format& raw_format() const noexcept;
158
166 const xtd::byte* rgb() const;
167
175 xtd::byte* rgb();
176
179 const drawing::size& size() const noexcept;
180
183 const xtd::any_object& tag() const noexcept;
186 void tag(const xtd::any_object& tag) noexcept;
187
190 float vertical_resolution() const noexcept;
191
194 int32 width() const noexcept;
196
198
202 image clone() const;
203
207
211 bool equals(const object& obj) const noexcept override;
215 bool equals(const image& other) const noexcept override;
216
221
225 xtd::drawing::imaging::encoder_parameters get_encoder_parameter_list(xtd::guid encoder) const noexcept;
226
233 xtd::size get_frame_count(const xtd::drawing::imaging::frame_dimension& dimension) const;
234
237 xtd::size get_hash_code() const noexcept override;
238
245 xtd::drawing::imaging::property_item get_property_item(int32 propid);
246
253 xtd::drawing::image get_thmbnail_image(int32 thumb_width, int32 thunb_height) noexcept;
254
260
265 void save(const xtd::string& filename) const;
269 void save(const xtd::string& filename, const xtd::drawing::imaging::image_format& format) const;
275 void save(std::ostream& stream, const xtd::drawing::imaging::image_format& format) const;
277
279
284 static image from_file(const xtd::string& filename);
285
290 static bitmap from_hbitmap(intptr hbitmap);
291
297 static image from_stream(std::istream& stream);
298
306 static bitmap from_xbm_data(const unsigned char* bits, int32 width, int32 height);
307
313 static bitmap from_xpm_data(const char* const* bits);
314
319
323 static bool is_alpha_pixel_format(xtd::drawing::imaging::pixel_format pixfmt) noexcept;
324
329
333 static bool is_extended_pixel_format(xtd::drawing::imaging::pixel_format pixfmt) noexcept;
335
336 protected:
338 friend xtd::drawing::imaging::effects::resize_effect;
339 friend xtd::drawing::imaging::effects::scale_effect;
340 explicit image(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 rectangle& rect);
351 static image from_hicon(intptr hicon);
352 drawing::color get_pixel(int32 x, int32 y) const;
353 void resize(const xtd::drawing::rectangle& rect, const xtd::drawing::color& fill_color);
354 void scale(const xtd::drawing::size& size, xtd::drawing::drawing_2d::interpolation_mode interpolation_mode);
355 void set_pixel(int32 x, int32 y, const drawing::color& color);
356 void set_pixel_format(imaging::pixel_format value);
358
359 private:
360 void update_properties();
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:61
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:46
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
const xtd::byte * alpha() const
Gets the image alpha pointer, which represents the alpha data of the image.
const size_f & physical_dimension() const noexcept
Gets the width and height of this image.
xtd::drawing::image get_thmbnail_image(int32 thumb_width, int32 thunb_height) noexcept
Returns a thumbnail for this xtd::drawing::image.
xtd::array< guid > frame_dimentions_list() const noexcept
Gets an array of GUIDs that represent the dimensions of frames within this image.
const xtd::array< int32 > & property_id_list() const noexcept
Gets IDs of the property items stored in this image.
static bitmap from_xbm_data(const unsigned char *bits, int32 width, int32 height)
Creates an xtd::drawing::image from the specified data pointer, width and hieght.
imaging::pixel_format pixel_format() const noexcept
Gets the pixel format for this image.
const xtd::byte * rgb() const
Gets the image data pointer, which represents the RGB data of the image.
graphics create_graphics()
Creates the xtd::drawing::graphics for the image.
int32 flags() const noexcept
Gets attribute flags for the pixel data of this xtd::drawing::image.
static bool is_canonical_pixel_format(xtd::drawing::imaging::pixel_format pixfmt) noexcept
Returns a value that indicates whether the pixel format is 32 bits per pixel.
xtd::drawing::imaging::property_item get_property_item(int32 propid)
Gets the specified property item from this xtd::drawing::image.
bool equals(const object &obj) const noexcept override
Determines whether the specified object is equal to the current object.
float horizontal_resolution() const noexcept
Gets the horizontal resolution, in pixels per inch, of this image.
image clone() const
Creates an exact copy of this xtd::drawing::image.
xtd::size get_frame_count(const xtd::drawing::imaging::frame_dimension &dimension) const
Returns the number of frames of the specified dimension.
static bool is_extended_pixel_format(xtd::drawing::imaging::pixel_format pixfmt) noexcept
Returns a value that indicates whether the pixel format is 64 bits per pixel.
xtd::byte * alpha()
Gets the image alpha pointer, which represents the alpha data of the image.
static int32 get_pixel_format_size(xtd::drawing::imaging::pixel_format pixfmt) noexcept
Returns the color depth, in number of bits per pixel, of the specified pixel format.
void rotate_flip(xtd::drawing::rotate_flip_type rotate_flip_type)
Rotates, flips, or rotates and flips the xtd::drawing::image.
static image empty
Represent an empty xtd::drawing::image.
Definition image.hpp:65
const xtd::array< imaging::property_item > & property_items() const noexcept
Gets all the property items (pieces of metadata) stored in this image.
xtd::drawing::rectangle_f get_bounds(xtd::drawing::graphics_unit page_unit) const noexcept
Gets the bounds of the image in the specified unit.
int32 height() const noexcept
Gets the height, in pixels, of this image.
static bool is_alpha_pixel_format(xtd::drawing::imaging::pixel_format pixfmt) noexcept
Returns a value that indicates whether the pixel format for this xtd::drawing::image contains alpha i...
float vertical_resolution() const noexcept
Gets the vertical resolution, in pixels per inch, of this image.
static bitmap from_hbitmap(intptr hbitmap)
Creates a xtd::drawing::bitmap from a handle to a GDI bitmap.
const imaging::image_format & raw_format() const noexcept
Gets the file format of this image.
static bitmap from_xpm_data(const char *const *bits)
Creates an xtd::drawing::image from the specified data pointer.
static image from_stream(std::istream &stream)
Creates an xtd::drawing::image from the specified data stream.
xtd::drawing::imaging::encoder_parameters get_encoder_parameter_list(xtd::guid encoder) const noexcept
Returns information about the parameters supported by the specified image encoder.
void save(const xtd::string &filename) const
Saves this xtd::drawing::image to the specified file or stream.
static image from_file(const xtd::string &filename)
Creates an image from the specified file.
const xtd::any_object & tag() const noexcept
Gets an object that provides additional data about the image.
imaging::color_palette palette() const noexcept
Gets the color palette used for this image.
intptr handle() const noexcept
Gets the handle of this image.
xtd::size get_hash_code() const noexcept override
Serves as a hash function for a particular type.
int32 width() const noexcept
Gets the width, in pixels, of this image.
const drawing::size & size() const noexcept
Gets the width and height, in pixels, 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:24
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
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.
xtd::string format(const xtd::string &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition format.hpp:20
#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
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
intmax_t intptr
Represent a pointer or a handle.
Definition intptr.hpp:23
uint8_t byte
Represents a 8-bit unsigned integer.
Definition byte.hpp:23
@ other
The operating system is other.
Definition platform_id.hpp:58
@ y
The Y key.
Definition console_key.hpp:136
@ x
The X key.
Definition console_key.hpp:134
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 const_pointer data() const noexcept
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:201
Contains xtd::drawing::imaging::pixel_format enum class.
Contains xtd::drawing::imaging::property_item class.
Contains xtd::drawing::rectangle class.
Contains xtd::drawing::rotate_flip_type enum class.
Contains xtd::drawing::size_f class.
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:31
Contains xtd::drawing::size class.