コード例 #1
0
ファイル: ImageThumbnailer.cs プロジェクト: mono/f-spot
		bool CreateThumbnail (SafeUri thumbnailUri, ThumbnailSize size, IImageFile imageFile)
		{
			var pixels = size == ThumbnailSize.Normal ? 128 : 256;
			Pixbuf pixbuf;
			try {
				pixbuf = imageFile.Load ();
			} catch (Exception e) {
				Log.DebugFormat ("Failed loading image for thumbnailing: {0}", imageFile.Uri);
				Log.DebugException (e);
				return false;
			}

			double scale_x = (double)pixbuf.Width / pixels;
			double scale_y = (double)pixbuf.Height / pixels;
			double scale = Math.Max (1.0, Math.Max (scale_x, scale_y));
			// Ensures that the minimum value is 1 so that pixbuf.ScaleSimple doesn't return null
			// Seems to only happen in rare(?) cases
			int target_x = Math.Max ((int)(pixbuf.Width / scale), 1);
			int target_y = Math.Max ((int)(pixbuf.Height / scale), 1);

			var thumb_pixbuf = pixbuf.ScaleSimple (target_x, target_y, InterpType.Bilinear);
			var mtime = fileSystem.File.GetMTime (imageFile.Uri).ToString ();
			thumb_pixbuf.Savev (thumbnailUri.LocalPath, "png",
				new string [] { ThumbnailService.ThumbUriOpt, ThumbnailService.ThumbMTimeOpt, null },
				new string [] { imageFile.Uri, mtime });

			pixbuf.Dispose ();
			thumb_pixbuf.Dispose ();

			return true;
		}
コード例 #2
0
ファイル: ImageThumbnailer.cs プロジェクト: mono/f-spot
		public bool TryCreateThumbnail (SafeUri thumbnailUri, ThumbnailSize size)
		{
			try {
				var imageFile = ImageFile.Create (fileUri);
				return CreateThumbnail (thumbnailUri, size, imageFile);
			}
			catch {
				return false;
			}
		}
コード例 #3
0
 public ThumbnailKey GetDeceasedThumbnailKey(ThumbnailSize size, int thumbIndex)
 {
     if (mSim is MiniSimDescription)
     {
         return GetThumbnailKey(size, thumbIndex);
     }
     else
     {
         return mSim.GetDeceasedThumbnailKey(size, thumbIndex);
     }
 }
コード例 #4
0
 public static string GetThumbnailImageUrl(string id, ThumbnailSize size = ThumbnailSize.Small)
 {
     switch (size)
     {
         case ThumbnailSize.Large:
             return string.Format("//i.ytimg.com/vi/{0}/hqdefault.jpg", id);
         case ThumbnailSize.Medium:
             return string.Format("//i.ytimg.com/vi/{0}/mqdefault.jpg", id);
         default:
             return string.Format("//i.ytimg.com/vi/{0}/default.jpg", id);
     }
 }
コード例 #5
0
ファイル: ThumbnailService.cs プロジェクト: mono/f-spot
		public Pixbuf GetThumbnail (SafeUri fileUri, ThumbnailSize size)
		{
			var thumbnailUri = GetThumbnailPath (fileUri, size);
			var thumbnail = LoadThumbnail (thumbnailUri);
			if (IsValid (fileUri, thumbnail))
				return thumbnail;
			IThumbnailer thumbnailer = thumbnailerFactory.GetThumbnailerForUri (fileUri);
			if (thumbnailer == null)
				return null;
			return !thumbnailer.TryCreateThumbnail (thumbnailUri, size)
				? null
				: LoadThumbnail (thumbnailUri);
		}
コード例 #6
0
ファイル: ImgurHelper.cs プロジェクト: Ranlaorn/Imgur.API
 /// <summary>
 /// Converts a <see cref="ThumbnailSize"/> to string.
 /// </summary>
 /// <param name="sz"></param>
 /// <returns></returns>
 public static string ThumbnailSizeToURIString(ThumbnailSize sz)
 {
     switch (sz)
     {
         case ThumbnailSize.BigSquare: return "b";
         case ThumbnailSize.Huge: return "h";
         case ThumbnailSize.Large: return "l";
         case ThumbnailSize.Medium: return "m";
         case ThumbnailSize.Small: return "t";
         case ThumbnailSize.SmallSquare: return "s";
         default:
             throw new Exception("Invalid ThumbnailSize!");
     }
 }
コード例 #7
0
 public void ThumbnailMaxHeight(ThumbnailSize size)
 {
     File file = null;
     try
     {
         file = PostImageFile("testimage.jpg");
         Image thumbnail = GetThumbnail(file, maxHeight: size);
         Assert.That(thumbnail, Is.Not.Null);
         Assert.That(thumbnail.Height, Is.LessThanOrEqualTo(int.Parse(size.Description())));
     }
     finally
     {
         Client.Delete(file);
     }
 }
コード例 #8
0
 public void ThumbnailHeightBounded(ThumbnailSize minHeight, ThumbnailSize maxHeight)
 {
     File file = null;
     try
     {
         file = PostImageFile("testimage.jpg");
         Image thumbnail = GetThumbnail(file, minHeight: minHeight, maxHeight: maxHeight);
         Assert.That(thumbnail, Is.Not.Null);
         Assert.That(thumbnail.Height, Is.GreaterThanOrEqualTo(int.Parse(minHeight.Description())));
         Assert.That(thumbnail.Height, Is.LessThanOrEqualTo(int.Parse(maxHeight.Description())));
     }
     finally
     {
         Client.Delete(file);
     }
 }
コード例 #9
0
        public static Pixbuf LoadThumbnail(SafeUri uri, ThumbnailSize size, PixbufLoader loader)
        {
            var thumb_uri = ThumbUri (uri, size);
            var pixbuf = LoadFromUri (thumb_uri);
            if (!IsValid (uri, pixbuf)) {
                Log.DebugFormat ("Invalid thumbnail, reloading: {0}", uri);
                if (pixbuf != null)
                    pixbuf.Dispose ();

                if (loader == null)
                    return null;

                pixbuf = CreateFrom (uri, thumb_uri, size, loader);
            }
            return pixbuf;
        }
コード例 #10
0
 /// <summary>
 /// Converts the ThumbnailSize enum to the string equivalent for the API
 /// </summary>
 /// <param name="size"></param>
 /// <returns></returns>
 private string ThumbnailSizeString(ThumbnailSize size)
 {
     switch (size)
     {
         case ThumbnailSize.Small:
             return "small";
         case ThumbnailSize.Medium:
             return "medium";
         case ThumbnailSize.Large:
             return "large";
         case ThumbnailSize.ExtraLarge:
             return "l";
         case ThumbnailSize.ExtraLarge2:
             return "xl";
     }
     return "s";
 }
コード例 #11
0
ファイル: MiniSims.cs プロジェクト: Robobeurre/NRaas
        public static ThumbnailKey GetThumbnailKey(IMiniSimDescription ths, ThumbnailSize size, int thumbIndex)
        {
            try
            {
                if (ths == null) return ThumbnailKey.kInvalidThumbnailKey;

                MiniSimDescription miniSim = ths as MiniSimDescription;
                if (miniSim != null)
                {
                    if (!ThumbnailManager.KeyExistsInDB(miniSim.mThumbKey))
                    {
                        SimDescription sim = MiniSims.UnpackSim(miniSim);

                        ThumbnailKey thumbnailKey = sim.GetThumbnailKey(ThumbnailSize.Large, 0x0);

                        try
                        {
                            sim.Dispose(false, true);
                        }
                        catch (Exception e)
                        {
                            Common.Exception(sim, e);
                        }

                        return thumbnailKey;
                    }

                    return miniSim.mThumbKey;
                }
                else if ((ths.CASGenealogy == null) || (ths.CASGenealogy.IsAlive()))
                {
                    return ths.GetThumbnailKey(size, thumbIndex);
                }
                else
                {
                    return ths.GetDeceasedThumbnailKey(size, thumbIndex);
                }
            }
            catch (Exception e)
            {
                Common.Exception(ths.FullName, e);
                return ThumbnailKey.kInvalidThumbnailKey;
            }
        }
コード例 #12
0
ファイル: Files.Sync.cs プロジェクト: jimmy6509/DropNet
 /// <summary>
 /// Gets the thumbnail of an image given its MetaData
 /// </summary>
 /// <param name="file"></param>
 /// <param name="size"></param>
 /// <returns></returns>
 public byte[] GetThumbnail(MetaData file, ThumbnailSize size)
 {
     return GetThumbnail(file.Path, size);
 }
コード例 #13
0
		/// <summary>
		/// Gets a thumbnail image for the virtual machine (Wrapper).
		/// </summary>
		/// <param name="vmId">Virtual machine id, represented by Guid (for example "4664215D-D195-4E35-BB6F-BFC1F17666EB").</param>
		/// <param name="size">Size of the thumbnail being requested</param>
		/// <returns>Array of bytes representing the virtual machine thumbnail image requested.</returns>
		public byte[] GetVirtualMachineThumbnailImage(string vmId, ThumbnailSize size)
		{
			return GetTumbnailFromSummaryInformation(vmId, size);
		}
コード例 #14
0
 public byte[] GetSnapshotThumbnail(int itemId, string snapshotId, ThumbnailSize size)
 {
     return(VirtualizationServerControllerProxmox.GetSnapshotThumbnail(itemId, snapshotId, size));
 }
コード例 #15
0
        // internal for unit testing with Moq
        internal SafeUri GetThumbnailPath(SafeUri fileUri, ThumbnailSize size)
        {
            var fileHash = CryptoUtil.Md5Encode(fileUri.AbsoluteUri);

            return(new SafeUri(Path.Combine(xdgDirectoryService.GetThumbnailsDir(size), fileHash + ".png")));
        }
コード例 #16
0
ファイル: RequestHelper.cs プロジェクト: jimmy6509/DropNet
        public RestRequest CreateThumbnailRequest(string path, ThumbnailSize size, string root)
        {
            var request = new RestRequest(Method.GET);
            request.Resource = "{version}/thumbnails/{root}{path}";

            request.AddParameter("version", _version, ParameterType.UrlSegment);
            request.AddParameter("path", path, ParameterType.UrlSegment);
            request.AddParameter("root", root, ParameterType.UrlSegment);
            request.AddParameter("size", ThumbnailSizeString(size));

            return request;
        }
コード例 #17
0
        public async Task <ImageSource> GetCover(string url, ThumbnailSize size)
        {
            var bytes = await this.GetBytes($"get/thumbnail?Size={Enum.GetName(typeof(ThumbnailSize), size)}&Url={url}");

            return(ImageSource.FromStream(() => new MemoryStream(bytes)));
        }
コード例 #18
0
        //public IEnumerable<Event> GetEvents(double latitude, double longitude, EventDateRange dateRange)
        //{
        //    var distance = "3km";

        //    //  TODO: ADD DATE RANGE.
        //    var events = this.Get($"events/search/?" +
        //                          $"location.latitude={latitude.InvariantString()}&" +
        //                          $"location.longitude={longitude.InvariantString()}&" +
        //                          $"location.within={distance}&" +
        //                          $"expand=venue,category", new EventbriteJsonReader());
        //    return events;
        //}

        public Task <ImageSource> GetCover(string url, ThumbnailSize size)
        {
            throw new System.NotImplementedException();
        }
コード例 #19
0
ファイル: Files.Async.cs プロジェクト: kristofzerbe/Fotosteam
 /// <summary>
 /// Gets the thumbnail of an image given its MetaData
 /// </summary>
 /// <param name="file">The metadat file</param>
 /// <param name="size">Thumbnail size</param>
 /// <param name="success">success callback</param>
 /// <param name="failure">Failure callback</param>
 public void GetThumbnailAsync(MetaData file, ThumbnailSize size, Action <byte[]> success, Action <DropboxException> failure)
 {
     GetThumbnailAsync(file.Path, size, success, failure);
 }
コード例 #20
0
 public Task <IRestResponse> GetThumbnailTask(MetaData file, ThumbnailSize size)
 {
     return(GetThumbnailTask(file.Path, size));
 }
コード例 #21
0
        public void Request(SafeUri uri, ThumbnailSize size, int order)
        {
            var pixels = size == ThumbnailSize.Normal ? 128 : 256;

            Request(uri, order, pixels, pixels);
        }
コード例 #22
0
 /// <summary>
 /// Retrieves a thumbnail for a sharing URL to a folder, album, or file. Can accept either the full or shortened sharing URL.
 /// </summary>
 /// <param name="size"></param>
 /// <param name="sharingUrlForItem"></param>
 /// <returns></returns>
 public async Task <byte[]> GetThumbnailAsync(ThumbnailSize size, Uri sharingUrlForItem)
 {
     // GET skydrive/get_item_preview?type=normal&url=http&3A%2F%2Fsdrv.ms%2F.....
     throw new NotImplementedException();
 }
コード例 #23
0
 public GetThumbnailQuery(ThumbnailSize thumbSize, string fileid)
 {
     ThumbnailSize = thumbSize;
     FileId        = fileid;
 }
コード例 #24
0
        public Pixbuf TryLoadThumbnail(SafeUri fileUri, ThumbnailSize size)
        {
            var thumbnailUri = GetThumbnailPath(fileUri, size);

            return(LoadThumbnail(thumbnailUri));
        }
コード例 #25
0
 /// <summary>
 /// Gets the thumbnail of an image given its MetaData
 /// </summary>
 /// <param name="file"></param>
 /// <param name="size"></param>
 /// <returns></returns>
 public async Task<byte[]> GetThumbnail(Metadata file, ThumbnailSize size)
 {
     return await GetThumbnail(file.Path, size);
 }
コード例 #26
0
 public static void MakeThumbnail(string originalImagePath, string thumbnailPath, ThumbnailSize size)
 {
     try
     {
         ImageHelper.MakeThumbnail(originalImagePath, thumbnailPath, size.Width, size.Height, size.Mode, size.AddWaterMarker, size.WaterMarkerPosition, size.WaterMarkerPath, size.Quality);
         Console.WriteLine("生成成功:{0}", thumbnailPath);
     }
     catch
     {
         Console.WriteLine("生成失败,非标准图片:{0}", thumbnailPath);
     }
 }
コード例 #27
0
        /// <summary>
        /// Gets the thumbnail of an image given its path
        /// </summary>
        /// <param name="path"></param>
        /// <param name="size"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<byte[]> GetThumbnail(string path, ThumbnailSize size, CancellationToken cancellationToken)
        {
            var request = MakeThumbnailRequest(path, size);

            var response = await _httpClient.SendAsync(request, cancellationToken);

            return await response.Content.ReadAsByteArrayAsync();
        }
コード例 #28
0
 /// <summary>
 /// Gets the thumbnail of an image given its MetaData
 /// </summary>
 /// <param name="file"></param>
 /// <param name="size"></param>
 /// <returns></returns>
 public byte[] GetThumbnail(MetaData file, ThumbnailSize size)
 {
     return(GetThumbnail(file.Path, size));
 }
コード例 #29
0
        /// <summary>
        /// <para>Begins an asynchronous send to the get thumbnail route.</para>
        /// </summary>
        /// <param name="path">The path to the image file you want to thumbnail.</param>
        /// <param name="format">The format for the thumbnail image, jpeg (default) or png. For
        /// images that are photos, jpeg should be preferred, while png is  better for
        /// screenshots and digital arts.</param>
        /// <param name="size">The size for the thumbnail image.</param>
        /// <param name="callback">The method to be called when the asynchronous send is
        /// completed.</param>
        /// <param name="callbackState">A user provided object that distinguished this send
        /// from other send requests.</param>
        /// <returns>An object that represents the asynchronous send request.</returns>
        public sys.IAsyncResult BeginGetThumbnail(string path,
                                                  ThumbnailFormat format = null,
                                                  ThumbnailSize size = null,
                                                  sys.AsyncCallback callback = null,
                                                  object callbackState = null)
        {
            var thumbnailArg = new ThumbnailArg(path,
                                                format,
                                                size);

            return this.BeginGetThumbnail(thumbnailArg, callback, callbackState);
        }
コード例 #30
0
        public static string GetThumbnailUri(string postfix, ThumbnailSize size)
        {
            var thumnailUri = $"{ThumbnailPrefix}{(int)size}{postfix}";

            return(thumnailUri);
        }
コード例 #31
0
 public byte[] GetVirtualMachineThumbnail(int itemId, ThumbnailSize size)
 {
     return(VirtualizationServerControllerProxmox.GetVirtualMachineThumbnail(itemId, size));
 }
コード例 #32
0
 public byte[] GetSnapshotThumbnail(int itemId, string snapshotId, ThumbnailSize size) {
     object[] results = this.Invoke("GetSnapshotThumbnail", new object[] {
                 itemId,
                 snapshotId,
                 size});
     return ((byte[])(results[0]));
 }
コード例 #33
0
 public ThumbnailKey GetThumbnailKey(ThumbnailSize size, int thumbIndex)
 {
     return(MiniSims.GetThumbnailKey(mSim, size, thumbIndex));
 }
コード例 #34
0
 /// <summary>
 /// Gets the thumbnails dir based on the user cache dir and the thumbnail size.
 ///
 /// http://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html
 /// </summary>
 /// <returns>The thumbnails dir.</returns>
 /// <param name="size">The thumbnail size to get the dir for.</param>
 public string GetThumbnailsDir(ThumbnailSize size)
 {
     return(Path.Combine(GetUserCacheDir(), "thumbnails", size == ThumbnailSize.Normal ? "normal" : "large"));
 }
コード例 #35
0
        /// <summary>
        /// Gets a file's thumbnail
        /// </summary>
        /// <param name="builder">Http request builder</param>
        /// <param name="provider">Http provider to execute the request</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <param name="optionSize"> A value from the enumeration that specifies the size of the image to retrieve. Small ,Medium, Large</param>
        /// <returns>When this method completes, return a stream containing the thumbnail, or null if no thumbnail are available</returns>
        public static async Task <Stream> GetThumbnailAsync(this IItemRequestBuilder builder, IOneDriveClient provider, CancellationToken cancellationToken, ThumbnailSize optionSize)
        {
            // Requests the different sizes of the thumbnail
            var thumbnailSet = await builder.GetThumbnailSetAsync(cancellationToken).ConfigureAwait(false);

            if (thumbnailSet == null)
            {
                return(null);
            }

            string requestUrl = null;

            if (optionSize == ThumbnailSize.Small)
            {
                requestUrl = thumbnailSet.Small;
            }
            else if (optionSize == ThumbnailSize.Medium)
            {
                requestUrl = thumbnailSet.Medium;
            }
            else if (optionSize == ThumbnailSize.Large)
            {
                requestUrl = thumbnailSet.Large;
            }

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUrl);
            await provider.AuthenticationProvider.AuthenticateRequestAsync(request).ConfigureAwait(false);

            var response = await provider.HttpProvider.SendAsync(request).ConfigureAwait(false);

            if (response.IsSuccessStatusCode)
            {
                return(await response.Content.ReadAsStreamAsync());
            }

            return(null);
        }
コード例 #36
0
 /// <summary>
 /// Gets the thumbnail of an image given its path
 /// </summary>
 /// <param name="path"></param>
 /// <param name="size"></param>
 /// <returns></returns>
 public Task <byte[]> GetThumbnail(string path, ThumbnailSize size)
 {
     return(GetThumbnail(path, size, CancellationToken.None));
 }
コード例 #37
0
        public static void MakeThumbnail(string originalImagePath, string thumbnailPath, ThumbnailSize size)
        {
            try
            {
                ImageUtil.MakeThumbnail(originalImagePath, thumbnailPath,
                                        size.Width,
                                        size.Height,
                                        size.Mode,
                                        size.AddWaterMarker,
                                        size.WaterMarkerPosition,
                                        size.WaterMarkerPath,
                                        size.Quality);

                Console.WriteLine("生成成功:{0}", thumbnailPath);
            }
            catch (Exception e)
            {
                Console.WriteLine("生成失败,非标准图片:{0}", thumbnailPath);
                //_Logger.Error(string.Format("{0} 生成失败,非标准图片", thumbnailPath), e);
            }
        }
コード例 #38
0
        /// <summary>
        /// Gets a url for the thumbnail of an image
        /// </summary>
        /// <param name="path"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public Uri GetThumbnailUrl(string path, ThumbnailSize size)
        {
            var request = MakeThumbnailRequest(path, size);

            return(request.RequestUri);
        }
コード例 #39
0
        public async Task <Stream> GetThumbnail(BoxFileMetaData file, ThumbnailSize size)
        {
            int px = convertThumbnailSize2Pixels(size);

            return(await getThumbnail(file.Id, maxHeight : px, maxWidth : px));
        }
コード例 #40
0
 public static Pixbuf LoadThumbnail(SafeUri uri, ThumbnailSize size)
 {
     return(LoadThumbnail(uri, size, DefaultLoader));
 }
コード例 #41
0
 /// <remarks/>
 public void GetVirtualMachineThumbnailAsync(int itemId, ThumbnailSize size) {
     this.GetVirtualMachineThumbnailAsync(itemId, size, null);
 }
コード例 #42
0
 /// <remarks/>
 public void GetSnapshotThumbnailAsync(int itemId, string snapshotId, ThumbnailSize size) {
     this.GetSnapshotThumbnailAsync(itemId, snapshotId, size, null);
 }
コード例 #43
0
 /// <remarks/>
 public System.IAsyncResult BeginGetSnapshotThumbnail(int itemId, string snapshotId, ThumbnailSize size, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("GetSnapshotThumbnail", new object[] {
                 itemId,
                 snapshotId,
                 size}, callback, asyncState);
 }
コード例 #44
0
ファイル: FilesHelper.cs プロジェクト: coupalm/PnP
        /// <summary>
        /// This method returns the thumbnails of a specific file by ID
        /// </summary>
        /// <param name="driveId">The ID of the target drive</param>
        /// <param name="fileId">The ID of the target file</param>
        /// <returns>The file thumbnails for the specific file</returns>
        public static Stream GetFileThumbnailImage(String driveId, String fileId, ThumbnailSize size)
        {
            String jsonResponse = MicrosoftGraphHelper.MakeGetRequestForString(
                String.Format("{0}drives/{1}/items/{2}/thumbnails/0/{3}",
                    MicrosoftGraphHelper.MicrosoftGraphV1BaseUri,
                    driveId,
                    fileId,
                    size.ToString().ToLower()));

            var thumbnail = JsonConvert.DeserializeObject<Thumbnail>(jsonResponse);

            var thumbnailImageStream = MicrosoftGraphHelper.MakeGetRequestForStream(
                thumbnail.Url,
                "image/jpeg");

            return (thumbnailImageStream);
        }
コード例 #45
0
 /// <remarks/>
 public void GetSnapshotThumbnailAsync(int itemId, string snapshotId, ThumbnailSize size, object userState) {
     if ((this.GetSnapshotThumbnailOperationCompleted == null)) {
         this.GetSnapshotThumbnailOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetSnapshotThumbnailOperationCompleted);
     }
     this.InvokeAsync("GetSnapshotThumbnail", new object[] {
                 itemId,
                 snapshotId,
                 size}, this.GetSnapshotThumbnailOperationCompleted, userState);
 }
コード例 #46
0
 /// <summary>
 /// Gets the thumbnail of an image given its MetaData
 /// </summary>
 /// <param name="file"></param>
 /// <param name="size"></param>
 /// <returns></returns>
 public async Task <byte[]> GetThumbnail(MetaData file, ThumbnailSize size)
 {
     return(await GetThumbnail(file.Path, size));
 }
コード例 #47
0
		public byte[] GetSnapshotThumbnailImage(string snapshotId, ThumbnailSize size)
		{
			//            ManagementBaseObject objSummary = GetSnapshotSummaryInformation(snapshotId, (SummaryInformationRequest)size);

			using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient())
			{

				VirtualMachineInfo vminfo = client.GetVirtualMachineByName(snapshotId);
				HostInfo host = client.GetHostById(vminfo.HostId);

				return GetTumbnailFromSummaryInformation(vminfo.Name, size);
			}
		}
コード例 #48
0
 public async Task <IDownloadResponse <FileMetadata> > GetThumbnailAsync(string path, ThumbnailFormat format = null, ThumbnailSize size = null, ThumbnailMode mode = null) =>
 await _dropBoxClient.Files.GetThumbnailAsync(path, format, size, mode);
コード例 #49
0
		/// <summary>
		/// Gets a thumbnail image for the virtual machine (Implementation).
		/// </summary>
		/// <param name="vmId">Virtual machine id, represented by Guid (for example "4664215D-D195-4E35-BB6F-BFC1F17666EB").</param>
		/// <param name="size">Size of the thumbnail being requested</param>
		/// <returns>Array of bytes representing the virtual machine thumbnail image requested.</returns>
		private byte[] GetTumbnailFromSummaryInformation(string vmName, ThumbnailSize size)
		{
			int width = 80;
			int height = 60;

			if (size == ThumbnailSize.Medium160x120)
			{
				width = 160;
				height = 120;
			}
			else if (size == ThumbnailSize.Large320x240)
			{
				width = 320;
				height = 240;
			}

			lock (HostinfoByVMName)
			{
				if (!HostinfoByVMName.ContainsKey(vmName))
				{
					using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient())
					{
						VirtualMachineInfo vminfo = client.GetVirtualMachineByName(vmName);
						if (vminfo != null)
						{
							HostInfo host = client.GetHostById(vminfo.HostId);

							HostinfoByVMName.Add(vmName, host);
						}
					}
				}
			}

			HostInfo hostInfo = null;

			HostinfoByVMName.TryGetValue(vmName, out hostInfo);

			byte[] imgData = null;

			if (hostInfo != null)
			{
				using (WSPVirtualMachineManagementServiceClient client = GetVMMSClient())
				{
					try
					{
						imgData = client.GetVirtualSystemThumbnailImage(width, height, vmName, hostInfo.ComputerName);
					}
					catch (Exception ex)
					{
						imgData = null;
						//
						Log.WriteError(ex);
					}
				}
			}

			// Create new bitmap
			if (imgData == null)
			{
				using (Bitmap bmp = new Bitmap(width, height))
				{
					Graphics g = Graphics.FromImage(bmp);
					SolidBrush brush = new SolidBrush(Color.LightGray);
					g.FillRectangle(brush, 0, 0, width, height);

					using (MemoryStream stream = new MemoryStream())
					{
						bmp.Save(stream, ImageFormat.Png);
						imgData = stream.ToArray();
					}
				}
			}

			return imgData;
		}
コード例 #50
0
ファイル: Empty1.cs プロジェクト: niec-and-linc/OpenDGS
 // Token: 0x06000D4B RID: 3403 RVA: 0x00015063 File Offset: 0x00014063
 public ThumbnailKey(ResourceKey objectDescKey, int index, uint bodyType, uint ageGender, bool liveUpdate, ThumbnailSize size)
 {
     this             = new ThumbnailKey(objectDescKey, index, bodyType, ageGender, size);
     this.mLiveUpdate = liveUpdate;
 }
コード例 #51
0
ファイル: Files.Sync.cs プロジェクト: jimmy6509/DropNet
        /// <summary>
        /// Gets the thumbnail of an image given its path
        /// </summary>
        /// <param name="path">The path to the picture</param>
        /// <param name="size">The size to return the thumbnail</param>
        /// <returns></returns>
        public byte[] GetThumbnail(string path, ThumbnailSize size)
        {
            if (!path.StartsWith("/"))
            {
                path = "/" + path;
            }
            var request = _requestHelper.CreateThumbnailRequest(path, size, Root);

            var response = Execute(ApiType.Content, request);

            return response.RawBytes;
        }
コード例 #52
0
ファイル: Empty1.cs プロジェクト: niec-and-linc/OpenDGS
 // Token: 0x06000D4E RID: 3406 RVA: 0x000151B8 File Offset: 0x000141B8
 public ThumbnailKey(SimOutfit outfit, int index, ThumbnailSize size, ThumbnailCamera camera, uint ageGenderSpecies)
 {
     this            = new ThumbnailKey(outfit, index, size, camera);
     this.mAgeGender = ageGenderSpecies;
 }
コード例 #53
0
 /// <summary>
 /// Gets the thumbnail of an image given its path
 /// </summary>
 /// <param name="path"></param>
 /// <param name="size"></param>
 /// <returns></returns>
 public Task<byte[]> GetThumbnail(string path, ThumbnailSize size)
 {
     return GetThumbnail(path, size, CancellationToken.None);
 }
コード例 #54
0
ファイル: Empty1.cs プロジェクト: niec-and-linc/OpenDGS
 // Token: 0x06000D50 RID: 3408 RVA: 0x0001524D File Offset: 0x0001424D
 public ThumbnailKey(SimOutfit outfit, int index, bool liveUpdate, ThumbnailSize size, ThumbnailCamera camera)
 {
     this             = new ThumbnailKey(outfit, index, size, camera);
     this.mLiveUpdate = liveUpdate;
 }
コード例 #55
0
        /// <summary>
        /// Gets a url for the thumbnail of an image
        /// </summary>
        /// <param name="path"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public Uri GetThumbnailUrl(string path, ThumbnailSize size)
        {
            var request = MakeThumbnailRequest(path, size);

            return request.RequestUri;
        }
コード例 #56
0
ファイル: Empty1.cs プロジェクト: niec-and-linc/OpenDGS
 // Token: 0x06000D48 RID: 3400 RVA: 0x00014F68 File Offset: 0x00013F68
 public ThumbnailKey(ResourceKey objectDescKey, uint bodyType, uint ageGender, ThumbnailSize size)
 {
     this.mDescKey                = objectDescKey;
     this.mTemplateObjectId       = default(ObjectGuid);
     this.mIndex                  = -1;
     this.mSize                   = size;
     this.mCamera                 = ThumbnailCamera.Default;
     this.mBodyType               = bodyType;
     this.mAgeGender              = ageGender;
     this.mLiveUpdate             = false;
     this.mTechnique              = ThumbnailTechnique.Default;
     this.mMaterialState          = 0u;
     this.mGeometryState          = 3787619543u;
     this.mDoNotCache             = false;
     this.mAdditionalSizesToCache = ThumbnailSizeMask.None;
 }
コード例 #57
0
        /// <summary>
        /// <para>Get a thumbnail for an image.</para>
        /// <para>This method currently supports files with the following file extensions: jpg,
        /// jpeg, png, tiff, tif, gif and bmp. Photos that are larger than 20MB in size won't
        /// be converted to a thumbnail.</para>
        /// </summary>
        /// <param name="path">The path to the image file you want to thumbnail.</param>
        /// <param name="format">The format for the thumbnail image, jpeg (default) or png. For
        /// images that are photos, jpeg should be preferred, while png is  better for
        /// screenshots and digital arts.</param>
        /// <param name="size">The size for the thumbnail image.</param>
        /// <returns>The task that represents the asynchronous send operation. The TResult
        /// parameter contains the response from the server.</returns>
        /// <exception cref="Dropbox.Api.ApiException{ThumbnailError}">Thrown if there is an
        /// error processing the request; This will contain a <see
        /// cref="ThumbnailError"/>.</exception>
        public t.Task<enc.IDownloadResponse<FileMetadata>> GetThumbnailAsync(string path,
                                                                             ThumbnailFormat format = null,
                                                                             ThumbnailSize size = null)
        {
            var thumbnailArg = new ThumbnailArg(path,
                                                format,
                                                size);

            return this.GetThumbnailAsync(thumbnailArg);
        }
コード例 #58
0
 public Task <Cover> GetCover(string url, ThumbnailSize size)
 {
     throw new NotImplementedException();
 }
コード例 #59
0
 public byte[] GetSnapshotThumbnailImage(string snapshotId, ThumbnailSize size)
 {
     try
     {
         Log.WriteStart("'{0}' GetSnapshotThumbnailImage", ProviderSettings.ProviderName);
         byte[] result = VirtualizationProvider.GetSnapshotThumbnailImage(snapshotId, size);
         Log.WriteEnd("'{0}' GetSnapshotThumbnailImage", ProviderSettings.ProviderName);
         return result;
     }
     catch (Exception ex)
     {
         Log.WriteError(String.Format("'{0}' GetSnapshotThumbnailImage", ProviderSettings.ProviderName), ex);
         throw;
     }
 }
コード例 #60
0
        public static string GetThumbnailVirtualPathForStoryOrCreateNew(string storyUrl, string shrinkedStoryId, ThumbnailSize size, bool createMediumThumbnail = false, bool fullPath = false, bool doNotCheckForExistingMiniature = false, bool async = false)
        {
            if (createMediumThumbnail && (!ThumbnailExists(shrinkedStoryId, ThumbnailSize.Medium) || doNotCheckForExistingMiniature))
            {
                if (!async)
                {
                    return(ThumbnailStoragePath + BlankThumbnailImageName);
                }
                var uri       = IoC.Resolve <IThumbnail>().For(storyUrl, ThumbnailSize.Medium);
                var thumbnail = CreateThumbnailFromUri(uri);
                SaveThumbnail(thumbnail, shrinkedStoryId, ThumbnailSize.Medium);
            }

            if (!ThumbnailExists(shrinkedStoryId, ThumbnailSize.Small) || doNotCheckForExistingMiniature)
            {
                if (!async)
                {
                    return(ThumbnailStoragePath + BlankThumbnailImageName);
                }
                var uri       = IoC.Resolve <IThumbnail>().For(storyUrl, ThumbnailSize.Small);
                var thumbnail = CreateThumbnailFromUri(uri);
                SaveThumbnail(thumbnail, shrinkedStoryId, ThumbnailSize.Small);
            }

            return(GetThumbnailVirtualPathForStory(shrinkedStoryId, size, fullPath));
        }