本文整理匯總了C#中System.Drawing.Bitmap.RemovePropertyItem方法的典型用法代碼示例。如果您正苦於以下問題:C# Bitmap.RemovePropertyItem方法的具體用法?C# Bitmap.RemovePropertyItem怎麽用?C# Bitmap.RemovePropertyItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Drawing.Bitmap
的用法示例。
在下文中一共展示了Bitmap.RemovePropertyItem方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: PostDecodeStream
protected override RequestedAction PostDecodeStream(ref Bitmap b, ResizeSettings settings)
{
if (!"true".Equals(settings["autorotate"], StringComparison.OrdinalIgnoreCase)) return RequestedAction.None;
int propertyId = 0x0112;
PropertyItem pi;
try {
pi = b.GetPropertyItem(propertyId);
} catch (ArgumentException) {
return RequestedAction.None;
}
if (pi == null) return RequestedAction.None;
int total = 0;
foreach (byte by in pi.Value) total += by; //Does not handle values larger than 255, but it doesn't need to, and is endian-agnostic.
if (total == 8) b.RotateFlip(RotateFlipType.Rotate270FlipNone);
if (total == 3) b.RotateFlip(RotateFlipType.Rotate180FlipNone);
if (total == 6) b.RotateFlip(RotateFlipType.Rotate90FlipNone);
if (total == 2) b.RotateFlip(RotateFlipType.RotateNoneFlipX);
if (total == 4) b.RotateFlip(RotateFlipType.Rotate180FlipX);
if (total == 5) b.RotateFlip(RotateFlipType.Rotate270FlipY);
if (total == 7) b.RotateFlip(RotateFlipType.Rotate90FlipY);
b.RemovePropertyItem(propertyId);
return RequestedAction.None;
}
示例2: CorrectRotation
private static Bitmap CorrectRotation(Bitmap bitmap)
{
if (Array.IndexOf (bitmap.PropertyIdList, 274) > -1)
{
var values = bitmap.GetPropertyItem (274).Value;
//var dateTakenPropertyItem = bitmap.GetPropertyItem (0x9003);
//var dateTakenString = Encoding.UTF8.GetString (dateTakenPropertyItem.Value);
//var regex = new Regex (":");
//dateTakenString = dateTakenString.Substring (0, dateTakenString.Length - 1);
//dateTakenString = regex.Replace (dateTakenString, "-", 2);
//var dateTaken = DateTime.Parse (dateTakenString);
if (values.Length < 1)
return bitmap;
var orientation = (int) values [0];
switch (orientation)
{
case 1:
// No rotation required.
break;
case 2:
bitmap.RotateFlip (RotateFlipType.RotateNoneFlipX);
break;
case 3:
bitmap.RotateFlip (RotateFlipType.Rotate180FlipNone);
break;
case 4:
bitmap.RotateFlip (RotateFlipType.Rotate180FlipX);
break;
case 5:
bitmap.RotateFlip (RotateFlipType.Rotate90FlipX);
break;
case 6:
bitmap.RotateFlip (RotateFlipType.Rotate90FlipNone);
break;
case 7:
bitmap.RotateFlip (RotateFlipType.Rotate270FlipX);
break;
case 8:
bitmap.RotateFlip (RotateFlipType.Rotate270FlipNone);
break;
}
// This EXIF data is now invalid and should be removed.
bitmap.RemovePropertyItem (274);
}
return bitmap;
}
示例3: skipExifData
private EndianStream skipExifData(EndianStream image)
{
Bitmap bitmap = new Bitmap(image.BaseStream);
Stream output = new MemoryStream();
// load into bitmap, remove all exlif data
foreach (PropertyItem item in bitmap.PropertyItems)
{
if (item.Type == 2)
bitmap.RemovePropertyItem(item.Id);
}
bitmap.Save(output, ImageFormat.Jpeg);
return new EndianStream(output, image.Endianness);
}