xtd 0.2.0
Loading...
Searching...
No Matches
image.h
Go to the documentation of this file.
1
4#pragma once
5#include "../drawing_export.h"
13#include "graphics.h"
14#include "graphics_unit.h"
15#include "rectangle.h"
16#include "rotate_flip_type.h"
17#include "size.h"
18#include "size_f.h"
19#include <xtd/any>
20#include <xtd/iequatable>
21#include <xtd/object>
22#include <xtd/ustring>
23#include <cstdint>
24#include <map>
25#include <memory>
26#include <iostream>
27
29namespace xtd {
31 namespace drawing {
33 class bitmap;
34 class image_converter;
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
91 int32 flags() const noexcept;
92
98 std::vector<guid> frame_dimentions_list() const noexcept;
99
102 intptr handle() const noexcept;
103
106 int32 height() const noexcept;
107
110 float horizontal_resolution() const noexcept;
111
115 imaging::color_palette palette() const noexcept;
118 void palette(const imaging::color_palette& palette) noexcept;
119
123 const size_f& physical_dimension() const noexcept;
124
127 imaging::pixel_format pixel_format() const noexcept;
128
132 const std::vector<int32>& property_id_list() const noexcept;
133
137 const std::vector<imaging::property_item>& property_items() const noexcept;
138
141 const imaging::image_format& raw_format() const noexcept;
142
145 const drawing::size& size() const noexcept;
146
149 const std::any& tag() const noexcept;
152 void tag(const std::any& tag) noexcept;
153
156 float vertical_resolution() const noexcept;
157
160 int32 width() const noexcept;
162
164
168 image clone() const;
169
172 graphics create_graphics();
173
174 bool equals(const image& image) const noexcept override;
175
182 const xtd::byte* get_alpha() const;
183
190 xtd::byte* get_alpha();
191
195 xtd::drawing::rectangle_f get_bounds(xtd::drawing::graphics_unit page_unit) const noexcept;
196
200 xtd::drawing::imaging::encoder_parameters get_encoder_parameter_list(xtd::guid encoder) const noexcept;
201
208 size_t get_frame_count(const xtd::drawing::imaging::frame_dimension& dimension) const;
209
216 xtd::drawing::imaging::property_item get_property_item(int32 propid);
217
225 const xtd::byte* get_rgb() const;
226
234 xtd::byte* get_rgb();
235
242 xtd::drawing::image get_thmbnail_image(int32 thumb_width, int32 thunb_height) noexcept;
243
248 void rotate_flip(xtd::drawing::rotate_flip_type rotate_flip_type);
249
254 void save(const xtd::ustring& filename) const;
258 void save(const xtd::ustring& filename, const xtd::drawing::imaging::image_format& format) const;
264 void save(std::ostream& stream, const xtd::drawing::imaging::image_format& format) const;
266
268
273 static image from_file(const xtd::ustring& filename) {return image(filename);}
274
279 static bitmap from_hbitmap(intptr hbitmap);
280
286 static image from_stream(std::istream& stream);
287
292 static image from_data(const char* const* bits);
293
298
303
308
314
315 protected:
317 explicit image(intptr hbitmap);
318 explicit image(const xtd::ustring& filename);
319 explicit image(const xtd::ustring& filename, bool use_icm);
320 explicit image(std::istream& stream);
321 explicit image(std::istream& stream, bool use_icm);
322 explicit image(const char* const* bits);
323 image(int32 width, int32 height);
324 image(int32 width, int32 height, float horizontal_resolution, float vertical_resolution);
326 image(int32 width, int32 height, int32 stride, xtd::drawing::imaging::pixel_format format, intptr scan0);
327 image(const image& image, int32 width, int32 height);
328 image(const image& image, const rectangle& rect);
329 static image from_hicon(intptr hicon);
330 void set_pixel_format(imaging::pixel_format value);
331 drawing::color get_pixel(int32 x, int32 y) const;
332 void set_pixel(int32 x, int32 y, const drawing::color& color);
334
335 private:
336 friend class image_converter;
337 void blur(int32 radius);
338 void crop(int32 x, int32 y, int32 width, int32 height);
339 void rescale(int32 width, int32 height);
340 void resize(int32 width, int32 height);
341 void update_properties();
342
343 std::shared_ptr<data> data_;
344 };
345 }
346}
Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes....
Definition bitmap.h:26
Represents an ARGB (alpha, red, green, blue) color.
Definition color.h:49
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition graphics.h:70
Converts images to and from xtd::drawing::image class. This class cannot be inherited.
Definition image_converter.h:29
An abstract base class that provides functionality for the bitmap and metafile descended classes.
Definition image.h:49
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.
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.
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.
static image empty
Represent an empty xtd::drawing::image.
Definition image.h:65
static image from_data(const char *const *bits)
Creates an xtd::drawing::image from the specified data pointer.
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...
static bitmap from_hbitmap(intptr hbitmap)
Creates a xtd::drawing::bitmap from a handle to a GDI bitmap.
static image from_stream(std::istream &stream)
Creates an xtd::drawing::image from the specified data stream.
Stores a set of four floating-point numbers that represent the location and size of a rectangle....
Definition rectangle_f.h:34
Stores a set of four integers that represent the location and size of a rectangle.
Definition rectangle.h:44
Stores an ordered pair of floating-point, which specify a height and width.
Definition size_f.h:31
Stores an ordered pair of integers, which specify a height and width.
Definition size.h:31
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.h:18
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:32
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
Contains xtd::drawing::imaging::color_palette class.
Contains xtd::drawing::imaging::encoder_parameters class.
Contains xtd::drawing::imaging::frame_dimension class.
Contains xtd::drawing::graphics class.
Contains xtd::drawing::graphics_unit enum class.
#define drawing_export_
Define shared library export.
Definition drawing_export.h:13
int_least32_t int32
Represents a 32-bit signed integer.
Definition types.h:131
intmax_t intptr
Represent a pointer or a handle.
Definition types.h:153
graphics_unit
Specifies the unit of measure for the given data. This enumeration has a flags attribute that allows ...
Definition graphics_unit.h:17
pixel_format
Specifies the format of the color data for each pixel in the image.
Definition pixel_format.h:23
rotate_flip_type
Specifies how much an image is rotated and the axis used to flip the image.
Definition rotate_flip_type.h:19
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 xtd_about_box.h:10
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.
Represents a globally unique identifier (GUID). A GUID is a 128-bit integer (16 bytes) that can be us...
Definition guid.h:23
Contains xtd::drawing::size class.