/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
using System.Drawing;
using System.Runtime.InteropServices;
namespace GreenshotPlugin.UnmanagedHelpers.Structs
{
///
/// A floating point GDI Plus width/hight based rectangle.
///
[StructLayout(LayoutKind.Sequential)]
public struct RECTF {
///
/// The X corner location of the rectangle.
///
public float X;
///
/// The Y corner location of the rectangle.
///
public float Y;
///
/// The width of the rectangle.
///
public float Width;
///
/// The height of the rectangle.
///
public float Height;
///
/// Creates a new GDI Plus rectangle.
///
/// The X corner location of the rectangle.
/// The Y corner location of the rectangle.
/// The width of the rectangle.
/// The height of the rectangle.
public RECTF(float x, float y, float width, float height) {
X = x;
Y = y;
Width = width;
Height = height;
}
///
/// Creates a new GDI Plus rectangle from a System.Drawing.RectangleF.
///
/// The rectangle to base this GDI Plus rectangle on.
public RECTF(RectangleF rect) {
X = rect.X;
Y = rect.Y;
Width = rect.Width;
Height = rect.Height;
}
///
/// Creates a new GDI Plus rectangle from a System.Drawing.Rectangle.
///
/// The rectangle to base this GDI Plus rectangle on.
public RECTF(Rectangle rect) {
X = rect.X;
Y = rect.Y;
Width = rect.Width;
Height = rect.Height;
}
///
/// Returns a RectangleF for this GDI Plus rectangle.
///
/// A System.Drawing.RectangleF structure.
public RectangleF ToRectangle() {
return new RectangleF(X, Y, Width, Height);
}
///
/// Returns a RectangleF for a GDI Plus rectangle.
///
/// The GDI Plus rectangle to get the RectangleF for.
/// A System.Drawing.RectangleF structure.
public static RectangleF ToRectangle(RECTF rect) {
return rect.ToRectangle();
}
///
/// Returns a GDI Plus rectangle for a RectangleF structure.
///
/// The RectangleF to get the GDI Plus rectangle for.
/// A GDI Plus rectangle structure.
public static RECTF FromRectangle(RectangleF rect) {
return new RECTF(rect);
}
///
/// Returns a GDI Plus rectangle for a Rectangle structure.
///
/// The Rectangle to get the GDI Plus rectangle for.
/// A GDI Plus rectangle structure.
public static RECTF FromRectangle(Rectangle rect) {
return new RECTF(rect);
}
}
}