本文整理汇总了C#中System.Drawing.Image.RemovePropertyItem方法的典型用法代码示例。如果您正苦于以下问题:C# Image.RemovePropertyItem方法的具体用法?C# Image.RemovePropertyItem怎么用?C# Image.RemovePropertyItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Image
的用法示例。
在下文中一共展示了Image.RemovePropertyItem方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetPropertyItems
public static void SetPropertyItems(Image image, PropertyItem[] items)
{
PropertyItem[] pis = image.PropertyItems;
foreach (PropertyItem pi in pis)
{
image.RemovePropertyItem(pi.Id);
}
foreach (PropertyItem pi in items)
{
image.SetPropertyItem(pi);
}
}
示例2: ResizeImage
internal static Image ResizeImage(Image image, ref int width, ref int height)
{
if (image.Width <= width && image.Height <= height) {
foreach (var p in image.PropertyIdList.Clone() as int[]) {
image.RemovePropertyItem(p);
}
return image;
}
var nw = (float)image.Width;
var nh = (float)image.Height;
var factor = 1.0f;
if (nw > nh) {
factor = width / nw;
}
else {
factor = height / nh;
}
nw = nw * factor;
nh = nh * factor;
var result = new Bitmap((int)nw, (int)nh);
try {
try {
result.SetResolution(image.HorizontalResolution, image.VerticalResolution);
}
catch (Exception ex) {
LogManager.GetLogger(typeof(ThumbnailMaker)).Debug("Failed to set resolution", ex);
}
using (Graphics graphics = Graphics.FromImage(result)) {
if (result.Width > image.Width && result.Height > image.Height) {
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
}
else {
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bicubic;
}
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
graphics.DrawImage(image, 0, 0, result.Width, result.Height);
width = result.Width;
height = result.Height;
}
return result;
}
catch (Exception) {
result.Dispose();
throw;
}
}
示例3: ClearExif
/// <summary>
/// Clears any EXIF metadata from the image
/// </summary>
/// <param name="image">The current image.</param>
private void ClearExif(Image image)
{
if (image.PropertyItems.Any())
{
foreach (KeyValuePair<int, PropertyItem> item in this.ExifPropertyItems)
{
image.RemovePropertyItem(item.Key);
}
}
}
示例4: ClearExif
/// <summary>
/// Clears any EXIF metadata from the image
/// </summary>
/// <param name="image">The current image.</param>
private void ClearExif(Image image)
{
if (image.PropertyItems.Any())
{
foreach (KeyValuePair<int, PropertyItem> item in this.ExifPropertyItems)
{
// The Gif decoder specifically requires these properties so we must not delete them.
if (item.Key != (int)ExifPropertyTag.LoopCount && item.Key != (int)ExifPropertyTag.FrameDelay)
{
image.RemovePropertyItem(item.Key);
}
}
}
}
示例5: RotateImage
public Image RotateImage(Image bmp)
{
if (Array.IndexOf(bmp.PropertyIdList, 274) > -1)
{
var orientation = (int)bmp.GetPropertyItem(274).Value[0];
switch (orientation)
{
case 1:
// No rotation required.
break;
case 2:
bmp.RotateFlip(RotateFlipType.RotateNoneFlipX);
break;
case 3:
bmp.RotateFlip(RotateFlipType.Rotate180FlipNone);
break;
case 4:
bmp.RotateFlip(RotateFlipType.Rotate180FlipX);
break;
case 5:
bmp.RotateFlip(RotateFlipType.Rotate90FlipX);
break;
case 6:
bmp.RotateFlip(RotateFlipType.Rotate90FlipNone);
break;
case 7:
bmp.RotateFlip(RotateFlipType.Rotate270FlipX);
break;
case 8:
bmp.RotateFlip(RotateFlipType.Rotate270FlipNone);
break;
}
// This EXIF data is now invalid and should be removed.
bmp.RemovePropertyItem(274);
}
return bmp;
}
示例6: ClearExif
/// <summary>
/// Clears any EXIF metadata from the image
/// </summary>
/// <param name="image">The current image.</param>
private void ClearExif(Image image)
{
if (image.PropertyItems.Any())
{
foreach (KeyValuePair<int, PropertyItem> item in this.ExifPropertyItems)
{
// Ensure that we do not try to remove any stripped out properties
// e.g gif comments.
if (image.PropertyIdList.Contains(item.Key))
{
// The Gif decoder specifically requires these properties so we must not delete them.
if (item.Key != (int)ExifPropertyTag.LoopCount && item.Key != (int)ExifPropertyTag.FrameDelay)
{
image.RemovePropertyItem(item.Key);
}
}
}
}
}