Пример #1
0
        internal override byte[] RetrieveFullSizeImageData(object fullSizeCallbackParameter)
        {
            object fullSizeImage = null;

            try
            {
                fullSizeImage = mScript.RetrieveFullSizeImage(fullSizeCallbackParameter);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.Fail(String.Format("Script {0} threw an exception while retreiving full sized image: {1}", mScript.Name, e.Message));
            }

            return(BitmapHelpers.GetBitmapData(fullSizeImage));
        }
Пример #2
0
        private void DownloadImage()
        {
            if (!mImageDownloaded)
            {
                object fullSizeImage = null;
                try
                {
                    fullSizeImage = mScript.RetrieveFullSizeImage(mFullSizeImageCallbackParameter);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.Fail(String.Format("Script {0} threw an exception while retreiving full sized image: {1}", mScript.Name, e.Message));
                }

                mImageData = BitmapHelpers.GetBitmapData(fullSizeImage);
                if (mImageData == null)
                {
                    //just use the thumbnail image
                    mImageData = BitmapHelpers.GetBitmapData(mThumbnail);
                }

                if (mImageData != null)
                {
                    var decoder = BitmapDecoder.Create(new MemoryStream(mImageData), BitmapCreateOptions.DelayCreation, BitmapCacheOption.None);
                    var frame   = decoder.Frames[0];
                    mWidth  = frame.PixelWidth;
                    mHeight = frame.PixelHeight;

                    mExtension = decoder.CodecInfo.FileExtensions.Split(',')[0].Substring(1);

                    //Hack for consistency with previous versions - use .jpg by default for jpeg files, not .jpeg
                    if ("jpeg".Equals(mExtension, StringComparison.OrdinalIgnoreCase))
                    {
                        mExtension = "jpg";
                    }
                }

                mImageDownloaded = true;
            }
        }
Пример #3
0
			public void Add(object thumbnail, string name, string infoUri, int fullSizeImageWidth, int fullSizeImageHeight, object fullSizeImageCallback, CoverType coverType, string suggestedFilenameExtension)
			{
				if (!mSource.QueryContinueSearchInternal())
				{
					//Break out of this search
					mSource.AbortSearch();
					return;
				}

				if (mSource.FullSizeOnly || fullSizeImageCallback == null)
				{
					byte[] fullSizeData = null;
					if (fullSizeImageCallback != null) //If fullSizeImageCallback == null, then no full size image supplied, so the thumbnail is the full size image
					{
						//Try to get the full size image without getting the thumbnail
                        fullSizeData = mSource.RetrieveFullSizeImageData(fullSizeImageCallback);
					}
                    if (fullSizeData == null)
					{
						//Fall back on using the thumbnail as the full size
                        fullSizeData = BitmapHelpers.GetBitmapData(thumbnail);
					}
					if (fullSizeData != null)
					{
						mDispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate
						{
							mSource.Results.Add(new AlbumArt(mSource,
								name,
								infoUri,
                                fullSizeImageWidth,
                                fullSizeImageHeight,
								fullSizeData,
								coverType));
						}));
					}
				}
				else
				{
					byte[] thumbnailBitmapData = BitmapHelpers.GetBitmapData(thumbnail);

                    if (thumbnailBitmapData != null)
					{
						mDispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate
						{
							mSource.Results.Add(new AlbumArt(mSource,
                                thumbnailBitmapData,
								name,
								infoUri,
								fullSizeImageWidth,
								fullSizeImageHeight,
								fullSizeImageCallback,
								coverType,
								suggestedFilenameExtension));
						}));
					}
				}

				if (!mSource.QueryContinueSearchInternal())
				{
					//Break out of this search
					mSource.AbortSearch();
					return;
				}
			}