xtd 0.2.0
hello_world_png.cpp

The classic first application "Hello, World!" with GDI+ drawing objects.

#include <xtd/xtd>
using namespace xtd;
using namespace xtd::diagnostics;
using namespace xtd::drawing;
using namespace xtd::io;
auto main() -> int {
auto hello_world_bitmap = bitmap {300, 300};
auto graphics = graphics::from_image(hello_world_bitmap);
graphics.draw_string("Hello World!", {system_fonts::default_font(), 32, font_style::bold | font_style::italic}, solid_brush {color_converter::dark(color::spring_green, 2.0 / 3)}, rectangle::offset({{0, 0}, hello_world_bitmap.size()}, {2, 2}), string_format {}.alignment(string_alignment::center).line_alignment(string_alignment::center));
auto hello_world_path = path::combine(path::get_temp_path(), "hello_world.png");
hello_world_bitmap.save(hello_world_path);
process::start(hello_world_path);
}
bool start()
Starts (or reuses) the process resource that is specified by the xtd::diagnostics::process::start_inf...
Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes....
Definition bitmap.hpp:26
static xtd::drawing::solid_brush spring_green()
A system-defined brush object.
static const xtd::drawing::color spring_green
Gets a system-defined color that has an ARGB value of 0xFF00FF7F. This field is constant.
Definition color.hpp:443
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition graphics.hpp:67
void draw_string(const xtd::string &s, const xtd::drawing::font &font, const xtd::drawing::brush &brush, const xtd::drawing::rectangle_f &layout_rectangle)
Draws the specified text string at the specified rectangle with the specified xtd::drawing::brush and...
static graphics from_image(const xtd::drawing::image &image)
Creates a new xtd::drawing::graphics from the specified xtd::drawing::image.
Defines a xtd::drawing::brush of a single color. Brushes are used to fill graphics shapes,...
Definition solid_brush.hpp:29
Encapsulates text layout information (such as alignment, orientation and tab stops) display manipulat...
Definition string_format.hpp:30
xtd::drawing::string_alignment alignment() const noexcept
Gets horizontal alignment of the string.
static xtd::drawing::font default_font()
Gets the default font that applications can use for dialog boxes and forms.
static xtd::string get_temp_path() noexcept
Returns the path of the current user's temporary folder.
static xtd::string combine(const xtd::string &path1, const xtd::string &path2)
Combines two path strings.
@ italic
Italic text.
Definition font_style.hpp:23
@ bold
Bold text.
Definition font_style.hpp:21
@ center
Specifies that text is aligned in the center of the layout rectangle.
Definition string_alignment.hpp:27
The xtd::diagnostics namespace provides classes that allow you to interact with system processes,...
Definition assert_dialog_result.hpp:10
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
The xtd::io namespace contains types that allow reading and writing to files and data streams,...
Definition binary_reader.hpp:17
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
void inflate(const drawing::size &sz) noexcept
Enlarges this xtd::drawing::rectangle by the specified amount.
void offset(const point &pos) noexcept
Adjusts the location of this rectangle by the specified amount.