本文整理汇总了C#中System.Drawing.Image.RotateFlip方法的典型用法代码示例。如果您正苦于以下问题:C# Image.RotateFlip方法的具体用法?C# Image.RotateFlip怎么用?C# Image.RotateFlip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Image
的用法示例。
在下文中一共展示了Image.RotateFlip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureMaximumDimensions
public static Image EnsureMaximumDimensions(Image image, int maxWidth, int maxHeight)
{
// Prevent using images internal thumbnail
image.RotateFlip(RotateFlipType.Rotate180FlipNone);
image.RotateFlip(RotateFlipType.Rotate180FlipNone);
var aspectRatio = ((double)image.Width) / image.Height; //AR = L/A;
int imageWidth = image.Width;
int imageHeight = image.Height;
if (imageWidth > maxWidth)
{
imageWidth = maxWidth;
imageHeight = (int)(imageWidth / aspectRatio);
}
if (imageHeight > maxHeight)
{
imageHeight = maxHeight;
imageWidth = (int)(imageHeight * aspectRatio);
}
if (image.Width != imageWidth || image.Height != imageHeight)
return image.GetThumbnailImage(imageWidth, imageHeight, null, IntPtr.Zero);
return image;
}
示例2: RotateThumbImage
public static Image RotateThumbImage(Image img)
{
int ix = 20521;
foreach (PropertyItem pi in img.PropertyItems.Where(x => x.Id == ix))
{
string s = pi.Value.Length > 0 ? pi.Value[0].ToString() : "";
//if (s.Equals("1"))
//img.RotateFlip(RotateFlipType.RotateNoneFlipX);
if (s.Equals("2"))
img.RotateFlip(RotateFlipType.RotateNoneFlipX);
if (s.Equals("3"))
img.RotateFlip(RotateFlipType.Rotate180FlipNone);
if (s.Equals("4"))
img.RotateFlip(RotateFlipType.RotateNoneFlipY);
if (s.Equals("5"))
img.RotateFlip(RotateFlipType.Rotate90FlipX);
if (s.Equals("6"))
img.RotateFlip(RotateFlipType.Rotate90FlipNone);
if (s.Equals("7"))
img.RotateFlip(RotateFlipType.Rotate90FlipY);
if (s.Equals("8"))
img.RotateFlip(RotateFlipType.Rotate270FlipNone);
}
return img;
}
示例3: Orientate
/// <summary>
/// Make sure the image is orientated correctly
/// </summary>
/// <param name="image"></param>
public static void Orientate(Image image)
{
/*if (!conf.ProcessEXIFOrientation)
{
return;
}*/
try
{
// Get the index of the orientation property.
int orientationIndex = Array.IndexOf(image.PropertyIdList, EXIF_ORIENTATION_ID);
// If there is no such property, return Unknown.
if (orientationIndex < 0)
{
return;
}
PropertyItem item = image.GetPropertyItem(EXIF_ORIENTATION_ID);
ExifOrientations orientation = (ExifOrientations)item.Value[0];
// Orient the image.
switch (orientation)
{
case ExifOrientations.Unknown:
case ExifOrientations.TopLeft:
break;
case ExifOrientations.TopRight:
image.RotateFlip(RotateFlipType.RotateNoneFlipX);
break;
case ExifOrientations.BottomRight:
image.RotateFlip(RotateFlipType.Rotate180FlipNone);
break;
case ExifOrientations.BottomLeft:
image.RotateFlip(RotateFlipType.RotateNoneFlipY);
break;
case ExifOrientations.LeftTop:
image.RotateFlip(RotateFlipType.Rotate90FlipX);
break;
case ExifOrientations.RightTop:
image.RotateFlip(RotateFlipType.Rotate90FlipNone);
break;
case ExifOrientations.RightBottom:
image.RotateFlip(RotateFlipType.Rotate90FlipY);
break;
case ExifOrientations.LeftBottom:
image.RotateFlip(RotateFlipType.Rotate270FlipNone);
break;
}
// Set the orientation to be normal, as we rotated the image.
item.Value[0] = (byte)ExifOrientations.TopLeft;
image.SetPropertyItem(item);
}
catch (Exception orientEx)
{
LOG.Warn("Problem orientating the image: ", orientEx);
}
}
示例4: Robot
/// <summary>
/// Instantiates a Robot object
/// </summary>
/// <param name="img">Image</param>
/// <param name="imgOr">Cardinal direction</param>
public Robot(Image img, Direction imgOr = Direction.North)
{
RoboImg = img;
RoboImg.RotateFlip(RotateFlipType.Rotate180FlipNone);
FaceDirection = imgOr;
if (FaceDirection.Equals(Direction.East)) {
RoboImg.RotateFlip(RotateFlipType.Rotate270FlipNone);
}
if (FaceDirection.Equals(Direction.South)) {
RoboImg.RotateFlip(RotateFlipType.Rotate180FlipNone);
}
if (FaceDirection.Equals(Direction.West)) {
RoboImg.RotateFlip(RotateFlipType.Rotate90FlipNone);
}
}
示例5: ResizeImage
public Image ResizeImage( Image fullsizeImage, int newWidth )
{
// Prevent using images internal thumbnail
fullsizeImage.RotateFlip( System.Drawing.RotateFlipType.Rotate180FlipNone );
fullsizeImage.RotateFlip( System.Drawing.RotateFlipType.Rotate180FlipNone );
var newHeight = fullsizeImage.Height * newWidth / fullsizeImage.Width;
var newImage = fullsizeImage.GetThumbnailImage( newWidth, newHeight, null, IntPtr.Zero );
// Clear handle to original file so that we can overwrite it if necessary
fullsizeImage.Dispose();
// Save resized picture
return newImage;
}
示例6: ResizeImage
public static Image ResizeImage(Image image, int width, int height, bool onlyResizeIfWider)
{
// Prevent using images internal thumbnail
image.RotateFlip(RotateFlipType.Rotate180FlipNone);
image.RotateFlip(RotateFlipType.Rotate180FlipNone);
if (onlyResizeIfWider)
if (image.Width <= width)
width = image.Width;
var newHeight = image.Height * width / image.Width;
if (newHeight > height)
{
// Resize with height instead
width = image.Width * height / image.Height;
newHeight = height;
}
return image.GetThumbnailImage(width, newHeight, null, IntPtr.Zero);
}
示例7: ModifyImage
private static void ModifyImage(Image i)
{
i.RotateFlip(RotateFlipType.Rotate180FlipNone);
using (var g = Graphics.FromImage(i))
{
g.SmoothingMode = SmoothingMode.AntiAlias;
g.DrawString("To the cloud!",
new Font("Arial", 42, FontStyle.Bold),
SystemBrushes.ActiveCaptionText, new Point(0, 0));
}
}
示例8: Size
/*public static Image AppendBorder(Image original, int borderWidth)
{
var borderColor = Color.White;
var newSize = new Size(
original.Width + borderWidth * 2,
original.Height + borderWidth * 2);
var img = new Bitmap(newSize.Width, newSize.Height);
var g = Graphics.FromImage(img);
g.Clear(borderColor);
g.DrawImage(original, new Point(borderWidth, borderWidth));
g.Dispose();
return img;
}*/
//Image resizing
public static System.Drawing.Image ResizeImage(Image Image, int maxWidth, int maxHeight)
{
//return FixedSize(Image, maxWidth, maxHeight, true);
int width = Image.Width;
int height = Image.Height;
if (width > maxWidth || height > maxHeight)
{
//The flips are in here to prevent any embedded image thumbnails -- usually from cameras
//from displaying as the thumbnail image later, in other words, we want a clean
//resize, not a grainy one.
Image.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipX);
Image.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipX);
float ratio = 0;
if (width > height)
{
ratio = (float)width / (float)height;
width = maxWidth;
height = Convert.ToInt32(Math.Round((float)width / ratio));
}
else
{
ratio = (float)height / (float)width;
height = maxHeight;
width = Convert.ToInt32(Math.Round((float)height / ratio));
}
//Rectangle destRect = new Rectangle(0, 0, maxWidth, maxHeight);
//// Draw image to screen.
//e.Graphics.DrawImage(newImage, destRect);
//return the resized image
return Image.GetThumbnailImage(width, height, null, IntPtr.Zero);
}
//return the original resized image
return Image;
}
示例9: ResizeImage
public static Image ResizeImage(Image FullsizeImage, int NewWidth, int MaxHeight, bool OnlyResizeIfWider)
{
// Prevent using images internal thumbnail
FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
if (OnlyResizeIfWider)
{
if (FullsizeImage.Width <= NewWidth)
{
NewWidth = FullsizeImage.Width;
}
}
int NewHeight = FullsizeImage.Height * NewWidth / FullsizeImage.Width;
if (NewHeight > MaxHeight)
{
// Resize with height instead
NewWidth = FullsizeImage.Width * MaxHeight / FullsizeImage.Height;
NewHeight = MaxHeight;
}
return FullsizeImage.GetThumbnailImage(NewWidth, NewHeight, null, IntPtr.Zero);
}
示例10: MyPictureBox
public MyPictureBox(Image img,pbInfo _pbInfo)
{
InitializeComponent();
pictureBox.Image = img;
pbInfo = _pbInfo;
label.Text = pbInfo.Server;
pbInfo.pbInfoChanged += (a, b) =>
{
switch(b.PropertyName)
{
case "FilePath":
RefreshImage(pbInfo.FilePath);
break;
case "Rotation":
comboBoxRotate.Text = pbInfo.Rotate.ToString();
break;
case "Server":
label.Text = pbInfo.Server;
label.BackColor = System.Drawing.Color.Transparent;
label.ForeColor = System.Drawing.Color.Black;
break;
case "Error":
if (pbInfo.Error != null)
{
label.Text = pbInfo.Error.Message;
label.BackColor = System.Drawing.Color.Red;
label.ForeColor = System.Drawing.Color.White;
}
break;
}
};
comboBoxRotate.TextChanged += (a, b) => {
PointF pf = new PointF(2, img.Height - 20);
if (pbInfo.Rotate > 0)
{
img.RotateFlip(Stuff.getRotateFlipType(pbInfo.Rotate));
if (pbInfo.Rotate == 90 || pbInfo.Rotate == 270)
{
pictureBox.Size = new Size(240, 320);
pf = new PointF(2, img.Height - 20);
}
}
else
{
pictureBox.Size = new Size(320, 240);
}
};
}
示例11: RotateImage
public static void RotateImage(Image imageToRotate, ImageRotationStyle style)
{
if (imageToRotate != null)
{
RotateFlipType flipType;
switch (style)
{
case ImageRotationStyle.CCW:
{
flipType = RotateFlipType.Rotate90FlipXY;
break;
}
default:
{
flipType = RotateFlipType.Rotate270FlipXY;
break;
}
}
imageToRotate.RotateFlip(flipType);
}
}
示例12: Apply
public override Image Apply(Image img)
{
RotateFlipType flipType = RotateFlipType.RotateNoneFlipNone;
if (Horizontally && Vertically)
{
flipType = RotateFlipType.RotateNoneFlipXY;
}
else if (Horizontally)
{
flipType = RotateFlipType.RotateNoneFlipX;
}
else if (Vertically)
{
flipType = RotateFlipType.RotateNoneFlipY;
}
if (flipType != RotateFlipType.RotateNoneFlipNone)
{
img.RotateFlip(flipType);
}
return img;
}
示例13: ImageRotation
public static void ImageRotation(Image img)
{
if (Array.IndexOf(img.PropertyIdList, 274) > -1)
{
var orientation = (int)img.GetPropertyItem(274).Value[0];
switch (orientation)
{
case 1:
// No rotation required.
break;
case 2:
img.RotateFlip(RotateFlipType.RotateNoneFlipX);
break;
case 3:
img.RotateFlip(RotateFlipType.Rotate180FlipNone);
break;
case 4:
img.RotateFlip(RotateFlipType.Rotate180FlipX);
break;
case 5:
img.RotateFlip(RotateFlipType.Rotate90FlipX);
break;
case 6:
img.RotateFlip(RotateFlipType.Rotate90FlipNone);
break;
case 7:
img.RotateFlip(RotateFlipType.Rotate270FlipX);
break;
case 8:
img.RotateFlip(RotateFlipType.Rotate270FlipNone);
break;
}
// This EXIF data is now invalid and should be removed.
//img.RemovePropertyItem(274);
}
}
示例14: Settings
static Settings()
{
IslandImage = new Bitmap(typeof(GameTabPage), "Island.png");
IslandImage.RotateFlip(RotateFlipType.Rotate180FlipNone);
}
示例15: ApplyTransformation
public override Image ApplyTransformation(Image image) {
image.RotateFlip(this.Direction);
return image;
}