public bool NextItem(MediaItem mediaItem, StartTime startTime) { string mimeType; string title; if (!mediaItem.GetPlayData(out mimeType, out title)) { return(false); } IResourceLocator locator = mediaItem.GetResourceLocator(); if (locator == null) { return(false); } if (!CanPlay(locator, mimeType)) { return(false); } RightAngledRotation rotation = RightAngledRotation.Zero; bool flipX = false; bool flipY = false; MediaItemAspect imageAspect = mediaItem[ImageAspect.ASPECT_ID]; if (imageAspect != null) { int orientationInfo = (int)imageAspect[ImageAspect.ATTR_ORIENTATION]; ImageRotation imageRotation; ImageAspect.OrientationToRotation(orientationInfo, out imageRotation); rotation = PlayerRotationTranslator.TranslateToRightAngledRotation(imageRotation); ImageAspect.OrientationToFlip(orientationInfo, out flipX, out flipY); } SetMediaItemData(locator, title, rotation, flipX, flipY); return(true); }
/// <summary> /// Constructs a <see cref="BinaryTextureImageSource"/> for thumbnails of the given size from MediaItems. /// </summary> public static ImageSource CreateMediaItemThumbnailAspectSource(object source, int width, int height) { MediaItem mediaItem = source as MediaItem; if (mediaItem == null) { return(null); } Guid id = mediaItem.MediaItemId; // Local media items don't have an item id string key = (id == Guid.Empty ? Guid.NewGuid() : id).ToString(); byte[] textureData = null; // Each resolution is cached separately. If we read cache only and our favourite resolution is not yet in cache, // we try to find any other existing. if (mediaItem.Aspects.ContainsKey(ThumbnailLargeAspect.ASPECT_ID)) { textureData = (byte[])mediaItem.Aspects[ThumbnailLargeAspect.ASPECT_ID].GetAttributeValue(ThumbnailLargeAspect.ATTR_THUMBNAIL); } ImageRotation miRotation; bool flipX; bool flipY; ImageAspect.GetOrientationMetadata(mediaItem, out miRotation, out flipX, out flipY); RightAngledRotation rotation = RotationTranslator.TranslateToRightAngledRotation(miRotation); return(new BinaryTextureImageSource(textureData, rotation, key)); }
public ImageControl() { _aspect = ImageAspect.AspectFill; _scaleX = 1.0; _scaleY = 1.0; _scale = 1.0; _rotation = 0.0; BuildImageControl(); }
internal static float GetRealAspect(ImageAspect imageAspect) { switch (imageAspect) { case ImageAspect.x16_9: return(16.0f / 9.0f); case ImageAspect.x16_10: return(16.0f / 10.0f); case ImageAspect.x19_10: return(19.0f / 10.0f); case ImageAspect.x5_4: return(5.0f / 4.0f); case ImageAspect.x4_3: return(4.0f / 3.0f); default: throw new ArgumentOutOfRangeException("imageAspect", imageAspect, null); } }
private static byte[] AutoRotateThumb(MediaItem mediaItem, byte[] textureData) { ImageRotation miRotation; bool flipX; bool flipY; if (ImageAspect.GetOrientationMetadata(mediaItem, out miRotation, out flipX, out flipY) && (miRotation != ImageRotation.Rot_0)) { try { using (MemoryStream rotatedStream = new MemoryStream()) using (MemoryStream inputStream = new MemoryStream(textureData)) using (Image bitmap = Image.FromStream(inputStream)) { if (miRotation == ImageRotation.Rot_180) { bitmap.RotateFlip(RotateFlipType.Rotate180FlipNone); } if (miRotation == ImageRotation.Rot_90) { bitmap.RotateFlip(RotateFlipType.Rotate90FlipNone); } if (miRotation == ImageRotation.Rot_270) { bitmap.RotateFlip(RotateFlipType.Rotate270FlipNone); } bitmap.Save(rotatedStream, ImageFormat.Jpeg); textureData = rotatedStream.ToArray(); } } catch (Exception) { } } return(textureData); }
public ImageControl() { _aspect = ImageAspect.AspectFill; BuildImageControl(); }