/// <summary>
        /// Initializes a new instance of the <see cref="ImageEnteredErrorStateException"/> class
        /// with the specified error state.
        /// </summary>
        /// <param name="status">The error state entered by the image.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="status"/> is <see langword="null"/>.</exception>
        public ImageEnteredErrorStateException(ImageState status)
            : base(string.Format("The image entered an error state: '{0}'", status))
        {
            if (status == null)
                throw new ArgumentNullException("status");

            _state.Status = status.Name;
#if !NET35
            SerializeObjectState += (ex, args) => args.AddSerializedState(_state);
#endif
        }
Exemplo n.º 2
0
 /// <summary>
 /// Forces the images to restart, making them retrace themselves from the game object.
 /// </summary>
 public void ForceStartImages()
 {
     imagePositions = new Vector3[positionsToSave];
     imagesInPlay = 0;
     state = ImageState.ON;
     index = 0;
     foreach (Transform t in images)
     {
         t.gameObject.SetActive(true);
         t.GetComponent<Afterimage>().offset = 0;
     }
 }
Exemplo n.º 3
0
        protected override RequestedAction PreRenderImage(ImageState s)
        {
            //Skip this when we are doing simulations
            if (s.destGraphics == null) return RequestedAction.None;

            string sf = s.settings["fi.scale"];
            if (string.IsNullOrEmpty(sf)) return RequestedAction.None;
            bool validAlg = false;
            FREE_IMAGE_FILTER filter = ParseResizeAlgorithm(sf, FREE_IMAGE_FILTER.FILTER_CATMULLROM, out validAlg);
            if (!validAlg) throw new ImageProcessingException("The specified resizing filter '" + sf + "' did not match bicubic, bilinear, box, bspline, catmullrom, or lanczos.");

            //Set copy attributes
            s.copyAttibutes.SetWrapMode(WrapMode.TileFlipXY);

            //The minimum dimensions of the temporary bitmap.
            SizeF targetSize = PolygonMath.getParallelogramSize(s.layout["image"]);
            targetSize = new SizeF((float)Math.Ceiling(targetSize.Width), (float)Math.Ceiling(targetSize.Height));

            //The size of the temporary bitmap.
            //We want it larger than the size we'll use on the final copy, so we never upscale it
            //- but we also want it as small as possible so processing is fast.
            SizeF tempSize = PolygonMath.ScaleOutside(targetSize, s.copyRect.Size);
            int tempWidth = (int)Math.Ceiling(tempSize.Width);
            int tempHeight = (int)Math.Ceiling(tempSize.Height);
            FIBITMAP src = FIBITMAP.Zero;
            FIBITMAP midway = FIBITMAP.Zero;
            try {
                //Crop if needed, Convert, scale, then convert back.
                if (s.preRenderBitmap != null || (s.copyRect.Width == s.originalSize.Width && s.copyRect.Height == s.originalSize.Height && s.copyRect.X == 0 && s.copyRect.Y == 0)){
                    src = FreeImage.CreateFromBitmap(s.preRenderBitmap != null ? s.preRenderBitmap : s.sourceBitmap);
                }else{

                    using (Bitmap c = s.sourceBitmap.Clone(s.copyRect, System.Drawing.Imaging.PixelFormat.Format32bppArgb)) {
                        src = FreeImage.CreateFromBitmap(c);
                    }
                }
                midway = FreeImage.Rescale(src, tempWidth, tempHeight, filter);
                FreeImage.UnloadEx(ref src);
                //Clear the old pre-rendered image if needed
                if (s.preRenderBitmap != null) s.preRenderBitmap.Dispose();
                //Reassign the pre-rendered image
                s.preRenderBitmap = FreeImage.GetBitmap(midway);
                FreeImage.UnloadEx(ref midway);
                s.preRenderBitmap.MakeTransparent();

            } finally {
                if (!src.IsNull) FreeImage.UnloadEx(ref src);
                if (!midway.IsNull) FreeImage.UnloadEx(ref midway);
            }

            return RequestedAction.Cancel;
        }
Exemplo n.º 4
0
 public static string GetString(ImageState state)
 {
     switch (state)
     {
         case ImageState.DownloadComplete:
             return "ダウンロード完了";
         case ImageState.DownloadFailed:
             return "ダウンロード失敗";
         case ImageState.NGFile:
             return "NG画像";
         case ImageState.DownloadPause:
             return "一時停止中";
         case ImageState.Secure:
             return "パス付き画像";
         default:
         case ImageState.Non:
             return "未ダウンロード";
     }
 }
Exemplo n.º 5
0
        public static IEnumerable<SimpleServerImage> ListAllImages(IComputeProvider provider, int? blockSize = null, string server = null, string imageName = null, ImageState imageStatus = null, DateTimeOffset? changesSince = null, ImageType imageType = null, string region = null, CloudIdentity identity = null)
        {
            if (blockSize <= 0)
                throw new ArgumentOutOfRangeException("blockSize");

            SimpleServerImage lastImage = null;

            do
            {
                string marker = lastImage != null ? lastImage.Id : null;
                IEnumerable<SimpleServerImage> images = provider.ListImages(server, imageName, imageStatus, changesSince, marker, blockSize, imageType, region, identity);
                lastImage = null;
                foreach (SimpleServerImage image in images)
                {
                    lastImage = image;
                    yield return image;
                }
            } while (lastImage != null);
        }
Exemplo n.º 6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="param">图片主键</param>
 /// <returns></returns>
 public ActionResult ShowImage(string param)
 {
     if (param.IndexOf("_") == -1) return Content("");
     FileUpload im = new FileUpload();
     byte[] imageByte = im.GetImage(param, () =>
     {
         ImageFileBll bll = new ImageFileBll();
         string name = param;
         name = name.Substring(0, param.IndexOf("_"));
         ImageFile file = bll.GetImage(name);
         if (file == null) return null;
         ImageState img = new ImageState();
         img.imageData = file.ImageData;
         img.imageName = file.ImageId;
         img.imageType = file.ImageType;
         return img;
     });
     if (imageByte == null) return Content("");//这里可以放默认图片
     return File(imageByte, "image/jpeg");
 }
Exemplo n.º 7
0
        /// <summary>
        /// Calculates a radius based on the provided value, using min(width/height) as the normalizing factor. Querystring values are interpreted as 1/1000ths of the normalizing factor.
        /// </summary>
        /// <param name="s"></param>
        /// <param name="key"></param>
        /// <param name="key2"></param>
        /// <returns></returns>
        protected int GetRadius(ImageState s, string key, string key2, double units)
        {
            string str = s.settings[key];

            if (string.IsNullOrEmpty(str) && key2 != null)
            {
                str = s.settings[key2];
            }
            if (string.IsNullOrEmpty(str))
            {
                return(-1);
            }
            double d;

            if (double.TryParse(str, ParseUtils.FloatingPointStyle, NumberFormatInfo.InvariantInfo, out d) && d > 0)
            {
                double factor = Util.PolygonMath.GetShortestPair(s.layout["image"]) / units;

                return((int)Math.Round(factor * d));
            }
            return(-1);
        }
Exemplo n.º 8
0
        private void Button_StateChanged(object sender, EventArgs e)
        {
            Button     ctrl  = (Button)sender;
            ImageState state = ImageState.NormalUp;

            if (!ctrl.Enabled &&
                ctrl.ImageList.Images.IndexOfKey(ImageState.DisabledUp.ToString()) >= 0)
            {
                state = ImageState.DisabledUp;
            }
            else if (ctrl.Focused &&
                     ctrl.ImageList.Images.IndexOfKey(ImageState.FocusedUp.ToString()) >= 0)
            {
                state = ImageState.FocusedUp;
            }
            else
            {
                state = ImageState.NormalUp;
            }

            SetButtonImageState(ctrl, state);
        }
Exemplo n.º 9
0
        protected override RequestedAction PostLayoutImage(ImageState s)
        {
            base.PostLayoutImage(s);

            if (!limits.HasImageSize)
            {
                return(RequestedAction.None);                     //Skip this unless we have image size limits
            }
            SizeF box = s.layout.GetBoundingBox().Size;

            double wFactor = box.Width / limits.ImageSize.Width;
            double hFactor = box.Height / limits.ImageSize.Height;

            double scaleFactor = wFactor > hFactor ? wFactor : hFactor;

            if (scaleFactor > 1)
            {
                //The bounding box exceeds the ImageSize. Scale down until it fits.
                s.layout.Scale(1 / scaleFactor, new PointF(0, 0));
            }

            return(RequestedAction.None);
        }
Exemplo n.º 10
0
        protected override RequestedAction LayoutImage(ImageState s)
        {
            if (s.sourceBitmap == null)
            {
                return(RequestedAction.None);
            }

            //percentpadding. Percentage is 0-100, multiplied by the average of the width and height.
            double percentpadding = s.settings.Get <double>("trim.percentpadding", 0) / 100;

            int?threshold = s.settings.Get <int>("trim.threshold");

            if (threshold != null)
            {
                if (threshold < 0)
                {
                    threshold = 0;
                }
                if (threshold > 255)
                {
                    threshold = 255;
                }

                Rectangle box = new BoundingBoxFinder().FindBoxSobel(s.sourceBitmap, new Rectangle(0, 0, s.sourceBitmap.Width, s.sourceBitmap.Height), (byte)threshold);
                //Add padding
                int paddingPixels = (int)Math.Ceiling(percentpadding * (box.Width + box.Height) / 2);
                box.X      = Math.Max(0, box.X - paddingPixels);
                box.Y      = Math.Max(0, box.Y - paddingPixels);
                box.Width  = Math.Min(s.sourceBitmap.Width, box.Width + paddingPixels * 2);
                box.Height = Math.Min(s.sourceBitmap.Height, box.Height + paddingPixels * 2);

                //Adjust s.originalSize so the layout occurs properly.
                s.originalSize      = box.Size;
                s.Data[RectDataKey] = box;
            }
            return(RequestedAction.None);
        }
Exemplo n.º 11
0
        protected Size GetDestinationSize(ImageState state, Bitmap bitmap)
        {
            var originalSize = new Size(bitmap.Width, bitmap.Height);

            var w = state.settings["width"];
            var h = state.settings["height"];

            if (w == null || !int.TryParse(w, out var width))
            {
                return(originalSize);
            }

            if (h == null || !int.TryParse(h, out var height))
            {
                return(originalSize);
            }

            if (!IsRequiredSize(width, height))
            {
                return(originalSize);
            }

            return(new Size(width, height));
        }
Exemplo n.º 12
0
        protected override RequestedAction PostRenderImage(ImageState s)
        {
            if (!"true".Equals(s.settings["f.show"], StringComparison.OrdinalIgnoreCase) ||
                !s.layout.ContainsRing("faces") ||
                s.destBitmap == null)
            {
                return(RequestedAction.None);
            }


            var newPoints = s.layout["faces"];

            using (Graphics g = Graphics.FromImage(s.destBitmap)) {
                for (var i = 0; i < newPoints.Length - 1; i += 2)
                {
                    float x1 = newPoints[i].X;
                    float y1 = newPoints[i].Y;
                    float x2 = newPoints[i + 1].X;
                    float y2 = newPoints[i + 1].Y;
                    float t;
                    if (x1 > x2)
                    {
                        t = x2; x2 = x1; x1 = t;
                    }
                    if (y1 > y2)
                    {
                        t = y1; y1 = y2; y2 = t;
                    }

                    g.DrawRectangle(Pens.Green, new Rectangle((int)x1, (int)y1, (int)(x2 - x1), (int)(y2 - y1)));
                }
            }


            return(RequestedAction.None);
        }
Exemplo n.º 13
0
        public void ShouldNeverCopyExcludedProperties()
        {
            CopyMetadataPlugin plugin = new CopyMetadataPlugin();

            using (ImageState state = CreateImageState(true))
            {
                RequestedAction requestedAction = CallProcessFinalBitmap(plugin, state);
                Assert.Equal(RequestedAction.None, requestedAction);

                // Make sure some of properties were stripped...

                // PropertyTagOrientation
                Assert.True(state.sourceBitmap.PropertyItems.Any(prop => prop.Id == 0x0112));
                Assert.False(state.destBitmap.PropertyItems.Any(prop => prop.Id == 0x0112));

                // PropertyTagXResolution
                Assert.True(state.sourceBitmap.PropertyItems.Any(prop => prop.Id == 0x011A));
                Assert.False(state.destBitmap.PropertyItems.Any(prop => prop.Id == 0x011A));

                // PropertyTagYResolution
                Assert.Single(state.sourceBitmap.PropertyItems, prop => prop.Id == 0x011B);
                Assert.False(state.destBitmap.PropertyItems.Any(prop => prop.Id == 0x011B));
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Initialization method
        /// </summary>
        public void Init()
        {
            Speed = Util.Rnd.Next(4000, 6200) / 1000000.0f;
            CurrentMove = MoveState.Intro;
            ImageSequence = ImageState.Normal;
            CurrentImage = 0;
            oldTicks = 0;
            CurrentImageSequence = 0;

            //X = 0.0f - Size.Width / 2.0f;
            //Y = -0.5f - Size.Height / 2.0f;
            X = (Util.Rnd.Next(-120, 120) / 100.0f) - (Size.Width / 2.0f); //0.0f - (Size.Width / 2.0f);
            Y = -1.2f - Size.Height;
            Z = 0.45f;
        }
Exemplo n.º 15
0
 protected virtual void OnImageStateChanged(ImageState imageState)
 {
     ImageStateChanged?.Invoke(this, new ImageStateChangedEventArgs(imageState));
 }
Exemplo n.º 16
0
        protected override RequestedAction ProcessFinalBitmap(ImageState s)
        {
            string metadata = s.settings[SettingsKey];
            Bitmap dest     = s.destBitmap;

            if (dest == null ||
                !"true".Equals(metadata, StringComparison.OrdinalIgnoreCase))
            {
                return(RequestedAction.None);
            }

            // We've been asked to copy the image metadata.  If the destination
            // image doesn't support property items at all, attempting to set
            // one will throw an ArgumentException with the message "Property not
            // supported.".  If an individual specific property is not supported,
            // SetPropertyItem() will ignore the attempt silently and *not* throw
            // an exception.
            try
            {
                // There are a handful of properties we *won't* copy, because they
                // may conflict with the resulting image.
                if (this.excludedProperties == null)
                {
                    List <int> list = new List <int>();

                    list.Add(0x0100);   // PropertyTagImageWidth
                    list.Add(0x0101);   // PropertyTagImageHeight
                    list.Add(0x0102);   // PropertyTagBitsPerSample
                    list.Add(0x0103);   // PropertyTagCompression
                    list.Add(0x0106);   // pixel composition (EXIF 2.2, not documented on MSDN)
                    list.Add(0x0108);   // PropertyTagCellWidth
                    list.Add(0x0109);   // PropertyTagCellHeight
                    list.Add(0x010A);   // PropertyTagFillOrder

                    list.Add(0x0111);   // PropertyTagStripOffsets
                    list.Add(0x0112);   // PropertyTagOrientation

                    list.Add(0x0115);   // PropertyTagSamplesPerPixel
                    list.Add(0x0116);   // PropertyTagRowsPerStrip
                    list.Add(0x0117);   // PropertyTagStripBytesCount
                    list.Add(0x0118);   // PropertyTagMinSampleValue
                    list.Add(0x0119);   // PropertyTagMaxSampleValue
                    list.Add(0x011A);   // PropertyTagXResolution
                    list.Add(0x011B);   // PropertyTagYResolution
                    list.Add(0x011C);   // PropertyTagPlanarConfig
                    list.Add(0x011D);   // PropertyTagPageName
                    list.Add(0x011E);   // PropertyTagXPosition
                    list.Add(0x011F);   // PropertyTagYPosition

                    list.Add(0x0120);   // PropertyTagFreeOffset
                    list.Add(0x0121);   // PropertyTagFreeByteCounts
                    list.Add(0x0122);   // PropertyTagGrayResponseUnit
                    list.Add(0x0123);   // PropertyTagGrayResponseCurve
                    list.Add(0x0124);   // PropertyTagT4Option
                    list.Add(0x0125);   // PropertyTagT6Option
                    list.Add(0x0128);   // PropertyTagResolutionUnit
                    list.Add(0x0129);   // PropertyTagPageNumber

                    list.Add(0x013D);   // PropertyTagPredictor
                    list.Add(0x013E);   // PropertyTagWhitePoint
                    list.Add(0x013F);   // PropertyTagPrimaryChromaticities
                    list.Add(0x0140);   // PropertyTagColorMap
                    list.Add(0x0141);   // PropertyTagHalftoneHints
                    list.Add(0x0142);   // PropertyTagTileWidth
                    list.Add(0x0143);   // PropertyTagTileLength
                    list.Add(0x0144);   // PropertyTagTileOffset
                    list.Add(0x0145);   // PropertyTagTileByteCounts

                    list.Add(0x015A);   // Indexed image (not on MSDN)
                    list.Add(0x015B);   // JPEG quantization andHuffman tables (not on MSDN)

                    list.Add(0x0200);   // PropertyTagJPEGProc
                    list.Add(0x0201);   // PropertyTagJPEGInterFormat
                    list.Add(0x0202);   // PropertyTagJPEGInterLength
                    list.Add(0x0203);   // PropertyTagJPEGRestartInterval
                    list.Add(0x0205);   // PropertyTagJPEGLosslessPredictors
                    list.Add(0x0206);   // PropertyTagJPEGPointTransforms
                    list.Add(0x0207);   // PropertyTagJPEGQTables
                    list.Add(0x0208);   // PropertyTagJPEGDCTables
                    list.Add(0x0209);   // PropertyTagJPEGACTables

                    list.Add(0x0211);   // PropertyTagYCbCrCoefficients
                    list.Add(0x0212);   // PropertyTagYCbCrSubsampling
                    list.Add(0x0213);   // PropertyTagYCbCrPositioning
                    list.Add(0x0214);   // PropertyTagREFBlackWhite

                    list.Add(0x5001);   // PropertyTagResolutionXUnit
                    list.Add(0x5002);   // PropertyTagResolutionYUnit
                    list.Add(0x5003);   // PropertyTagResolutionXLengthUnit
                    list.Add(0x5004);   // PropertyTagResolutionYLengthUnit

                    list.Add(0x5010);   // PropertyTagJPEGQuality
                    list.Add(0x5011);   // PropertyTagGridSize

                    this.excludedProperties = list;
                }

                // Copy all properties that aren't in the exclusion list.
                foreach (PropertyItem prop in s.sourceBitmap.PropertyItems)
                {
                    if (!this.excludedProperties.Contains(prop.Id))
                    {
                        dest.SetPropertyItem(prop);
                    }
                }
            }
            catch (ArgumentException /*ex*/)
            {
                // TODO: Should we be logging a message/issue that the
                // output image doesn't support property items (metadata),
                // but it's been asked for?

                // Right now, we silently ignore the exception and allow the
                // destination image to continue even without the property
                // items.
            }

            return(RequestedAction.None);
        }
Exemplo n.º 17
0
 protected override RequestedAction Render(ImageState s)
 {
     stop("prepdest");
     start("render");
     return(base.Render(s));
 }
Exemplo n.º 18
0
 protected override RequestedAction Layout(ImageState s)
 {
     stop("prepsource");
     start("layout");
     return(base.Layout(s));
 }
Exemplo n.º 19
0
 protected override RequestedAction OnProcess(ImageState s)
 {
     start("process");
     return(base.OnProcess(s));
 }
Exemplo n.º 20
0
        public async Task CanRecompressAndResizeDDSImages()
        {
            var profile = utils.AddProfile();
            var mod     = await utils.AddMod();

            var nativeFile = await utils.AddModFile(mod, @"native\whitestagbody.dds", 0);

            var recompressedFile = await utils.AddModFile(mod, @"recompressed\whitestagbody.dds", 0);

            var resizedFile = await utils.AddModFile(mod, @"resized\whitestagbody.dds", 0);

            var gameBSA = Game.SkyrimSpecialEdition.MetaData().GameLocation().Combine(@"Data\Skyrim - Textures1.bsa");
            var bsa     = await BSADispatch.OpenRead(gameBSA);

            var ddsExtension = new Extension(".dds");
            var firstFile    = bsa.Files.First(f => f.Path.Extension == ddsExtension);

            await using (var nf = await nativeFile.OpenWrite())
            {
                await firstFile.CopyDataTo(nf);
            }

            {
                var originalDDS = await ImageState.GetState(nativeFile);

                await ImageState.ConvertImage(nativeFile, recompressedFile.Parent, originalDDS.Width, originalDDS.Height, DXGI_FORMAT.BC7_UNORM, recompressedFile.Extension);

                await ImageState.ConvertImage(nativeFile, resizedFile.Parent, 128, 128, DXGI_FORMAT.BC7_UNORM, resizedFile.Extension);
            }

            await utils.Configure();

            await CompileAndInstall(profile, true);

            await utils.VerifyInstalledFile(mod, @"native\whitestagbody.dds");

            Assert.True(0.99f <= (await ImageState.GetState(recompressedFile)).PerceptualHash.Similarity(await ImageState.GetPHash(utils.InstalledPath(mod, @"recompressed\whitestagbody.dds"))));
            Assert.True(0.98f <= (await ImageState.GetState(resizedFile)).PerceptualHash.Similarity(await ImageState.GetPHash(utils.InstalledPath(mod, @"resized\whitestagbody.dds"))));
        }
Exemplo n.º 21
0
		private CompositeImage GetImage(ImageState state)
		{
			Image image=null;

			if(m_Icon!=null)
			{
				System.Drawing.Size iconSize=this.IconSize;
				System.Drawing.Icon icon=null;
				try
				{
					icon=new System.Drawing.Icon(m_Icon,iconSize);
				}
				catch{icon=null;}
				if(icon==null)
					return new CompositeImage(m_Icon,false);
				else
					return new CompositeImage(icon,true);
			}

			if(state==ImageState.Hover && (m_HoverImage!=null || m_HoverImageIndex>=0))
			{
				if(m_HoverImage!=null)
					return new CompositeImage(m_HoverImage,false);
				if(m_HoverImageIndex>=0)
				{
					image=GetImageFromImageList(m_HoverImageIndex);
					if(image!=null)
						return new CompositeImage(image,false);
					return null;
				}
			}

			if(state==ImageState.Pressed && (m_PressedImage!=null || m_PressedImageIndex>=0))
			{
				if(m_PressedImage!=null)
					return new CompositeImage(m_PressedImage,false);
				if(m_PressedImageIndex>=0)
				{
					image=GetImageFromImageList(m_PressedImageIndex);
					if(image!=null)
						return new CompositeImage(image,false);
					return null;
				}
			}

			if(m_Image!=null)
			{
				return new CompositeImage(m_Image,false);
			}
			if(m_ImageIndex>=0)
			{
				image=GetImageFromImageList(m_ImageIndex);
				if(image!=null)
					return new CompositeImage(image,false);
			}

			return null;
		}
        /// <summary>
        /// Fired when the control changes sizes.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ContentRoot_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            // Grab the new size.
            m_currentControlSize = e.NewSize;

            if(m_state == ImageState.Unloaded)
            {
                // If we are unloaded call this to ensure the image it loading.
                ReloadImage(false);
            }
            else if(m_state == ImageState.Normal)
            {
                // Only reload the image if the size is larger than the current image.
                bool didImageResize = false;
                if (m_lastImageSetSize.Height < m_currentControlSize.Height && m_lastImageSetSize.Width < m_currentControlSize.Width)
                {
                    // Resize the image.
                    didImageResize = ReloadImage(false);
                }

                // if we didn't resize the image just set the new zoom.
                if (!didImageResize)
                {
                    m_state = ImageState.NormalSizeUpdating;

                    await SetScrollerZoomFactors();

                    m_state = ImageState.Normal;
                }
            }
        }
        /// <summary>
        /// Fired when the scroller is done moving.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
        {
            // If we are done entering full screen set the var and return.
            if (m_state == ImageState.EnteringFullscreenComplete)
            {
                m_state = ImageState.Fullscreen;
                return; ;
            }
            else if (m_state != ImageState.Fullscreen)
            {
                return;
            }

            // If the two zoom factors are close enough, leave full screen.
            if (AreCloseEnoughToEqual(m_minZoomFactor, ui_scrollViewer.ZoomFactor))
            {
                // Set the state and hide the image, we do this make the transition smoother.
                m_state = ImageState.ExitingFullscreen;
                ui_scrollViewer.Visibility = Visibility.Collapsed;
                VisualStateManager.GoToState(this, "HideImage", true);

                // Try to leave full screen.
                m_base.FireOnFullscreenChanged(false);

                // Delay for a bit to let full screen settle.
                await Task.Delay(10);

                // Resize the image
                ReloadImage(false);
            }
        }
        /// <summary>
        /// Fired when the scroller is moving.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ScrollViewer_ViewChanging(object sender, ScrollViewerViewChangingEventArgs e)
        {
            if (m_state != ImageState.Normal)
            {
                return;
            }

            // If the zooms don't match go full screen
            if (!AreCloseEnoughToEqual(m_minZoomFactor, ui_scrollViewer.ZoomFactor))
            {
                // Set the state and hide the image, we do this make the transition smoother.
                m_state = ImageState.EnteringFullscreen;
                VisualStateManager.GoToState(this, "HideImage", true);
                ui_scrollViewer.Visibility = Visibility.Collapsed;

                // wait a second for the vis change to apply
                await Task.Delay(10);

                // Try to go full screen
                m_base.FireOnFullscreenChanged(true);

                // Delay for a bit to let full screen settle.
                await Task.Delay(10);

                // Resize the image.
                ReloadImage(true);
            }
        }
        /// <summary>
        /// Fired when the image is actually ready.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void BitmapImage_ImageOpened(object sender, RoutedEventArgs e)
        {
            if(m_base.IsDestoryed)
            {
                return;
            }

            // Update the zoom if needed
            await SetScrollerZoomFactors();

            // Hide the loading screen
            m_base.FireOnLoading(false);

            // This can throw if we are being destroyed.
            try
            {
                // Restore the state
                ui_scrollViewer.Visibility = Visibility.Visible;
                VisualStateManager.GoToState(this, "ShowImage", true);
            }
            catch(Exception)
            {
                return;
            }

            // wait a little bit before we set the new state so things can settle.
            await Task.Delay(50);

            // Update the state
            switch (m_state)
            {
                case ImageState.Unloaded:
                    m_state = ImageState.Normal;
                    break;
                case ImageState.EnteringFullscreen:
                    m_state = ImageState.EnteringFullscreenComplete;
                    break;
                case ImageState.ExitingFullscreen:
                    m_state = ImageState.Normal;
                    break;
            }
        }
Exemplo n.º 26
0
    // Update is called once per frame
    void Update()
    {
        CheckForUpdate();

        switch (state) {

            case ImageState.ON:
                {
                    imagePositions[index] = this.gameObject.transform.position;

                    foreach (Transform t in images)
                    {
                        if (t.gameObject.activeSelf == false)
                        {
                            t.gameObject.SetActive(true);
                        }

                        Afterimage image = t.GetComponent<Afterimage>();
                        t.position = this.gameObject.transform.position;

                        // If this value is null, it must have started generating images and not looped around yet.
                        if (imagePositions[positionsToSave - 1] == Vector3.zero)
                        {
                            int num = index - image.offset;
                            if (num < 0) num = 0;
                            t.position = imagePositions[num];
                        }
                        else
                        {
                            t.position = imagePositions[SubtractAndWrap(index, image.offset, positionsToSave)];
                        }

                        t.localScale = transform.localScale;
                        SpriteRenderer imageSprite = t.GetComponent<SpriteRenderer>();
                        imageSprite.sprite = sprite.sprite;
                        imageSprite.color = imageColor;

                        if (image.offset < image.maxOffset) image.offset++;
                    }

                    index++;
                    if (index >= positionsToSave) index = 0;
                }
                break;

            case ImageState.OFF:
                break;

            case ImageState.FADING:
            {
                imagePositions[index] = this.gameObject.transform.position;

                foreach (Transform t in images)
                {
                    Afterimage image = t.GetComponent<Afterimage>();

                    // If this value is null, it must have started generating images.
                    if (imagePositions[positionsToSave - 1] == Vector3.zero)
                    {
                        int num = index - image.offset;
                        if (num < 0) num = 0;
                        t.position = imagePositions[num];
                    }
                    else
                    {
                        t.position = imagePositions[SubtractAndWrap(index, image.offset, positionsToSave)];
                    }

                    t.localScale = transform.localScale;
                    t.GetComponent<SpriteRenderer>().sprite = sprite.sprite;

                    if (image.offset > 0) image.offset--;

                    if (image.imageInChain == imagesToDisplay && image.offset == 0)
                    {
                        disableImages();
                        state = ImageState.OFF;
                        break;
                    }
                }

                index++;
                if (index >= positionsToSave) index = 0;
            }
            break;
        }
    }
 /// <inheritdoc/>
 public IEnumerable<ServerImage> ListImagesDetails(string server = null, string imageName = null, ImageState imageStatus = null, DateTimeOffset? changesSince = null, string markerId = null, int? limit = null, ImageType imageType = null)
 {
     return ServersProvider.ListImagesWithDetails(server, imageName, imageStatus, changesSince, markerId, limit, imageType, this.DefaultRegion, this.Identity);
 }
Exemplo n.º 28
0
		private CompositeImage GetImage(ImageState state)
		{
			Image image=null;

            if (state == ImageState.Disabled)
            {
                if (m_DisabledImage == null && m_DisabledIcon == null && (m_Icon != null || m_Image != null || m_ImageIndex >= 0))
                    CreateDisabledImage();

                if(m_DisabledIcon!=null)
                    return new CompositeImage(new System.Drawing.Icon(m_DisabledIcon, IconSize), true);
                if(m_DisabledImage!=null)
                    return new CompositeImage(m_DisabledImage, false);
            }

			if(m_Icon!=null)
			{
				System.Drawing.Size iconSize=this.IconSize;
				return new CompositeImage(new System.Drawing.Icon(m_Icon,iconSize),true);
			}

			if(m_Image!=null)
			{
				return new CompositeImage(m_Image,false);
			}

			if(m_ImageIndex>=0)
			{
				image=GetImageFromImageList(m_ImageIndex);
				if(image!=null)
					return new CompositeImage(image,false);
			}

			return null;
		}
Exemplo n.º 29
0
 private void SetCheckBoxImageState(CheckBox ctrl, ImageState state)
 {
     if (ctrl.ImageList == null) return;
     int index = ctrl.ImageList.Images.IndexOfKey(state.ToString());
     if (index < 0)
     {
         if (console.SkinsEnabled)
         {
             switch (state)
             {
                 case (ImageState.NormalDown):
                     {
                         ctrl.BackgroundImage = null;
                         ctrl.ForeColor = console.SkinsButtonTxtColor;
                         ctrl.BackColor = console.ButtonSelectedColor;
                         return;
                     };
                 case (ImageState.MouseOverUp):
                     {
                         return;
                     };
                 case (ImageState.MouseOverDown):
                     {
                         return;
                     };
                 default:
                     {
                         ctrl.BackgroundImage = null;
                         ctrl.ForeColor = console.SkinsButtonTxtColor;
                         ctrl.BackColor = SystemColors.Control;
                         return;
                     }
             };
         }
         else
         {
             switch (state)
             {
                 case (ImageState.NormalDown):
                     {
                         ctrl.BackgroundImage = null;
                         ctrl.ForeColor = console.SkinsButtonTxtColor;
                         return;
                     };
                 case (ImageState.MouseOverUp):
                     {
                         return;
                     };
                 case (ImageState.MouseOverDown):
                     {
                         return;
                     };
                 default:
                     {
                         ctrl.BackgroundImage = null;
                         ctrl.ForeColor = console.SkinsButtonTxtColor;
                         ctrl.BackColor = SystemColors.Control;
                         return;
                     }
             };
         }
     }
     ctrl.BackgroundImage = ctrl.ImageList.Images[index];
 }
Exemplo n.º 30
0
 protected override RequestedAction EndProcess(ImageState s)
 {
     stop("process");
     return(base.EndProcess(s));
 }
Exemplo n.º 31
0
 /// <summary>
 /// Forces the afterimages to immediately stop and disappear.
 /// </summary>
 public void ForceStopImages()
 {
     disableImages();
     state = ImageState.OFF;
 }
Exemplo n.º 32
0
 protected override RequestedAction PrepareSourceBitmap(ImageState s)
 {
     start("prepsource");
     return(base.PrepareSourceBitmap(s));
 }
Exemplo n.º 33
0
 /// <summary>
 /// Sets the afterimages to stop. Afterimages will retract in towards the main body.
 /// </summary>
 public void StopImages()
 {
     if (state == ImageState.ON) state = ImageState.FADING;
 }
Exemplo n.º 34
0
 protected override RequestedAction EndLayout(ImageState s)
 {
     stop("layout");
     start("prepdest");
     return(base.EndLayout(s));
 }
Exemplo n.º 35
0
    public void UpdateTitleScreen()
    {
        switch (imageState)
        {
        case ImageState.Cooking: {
            anim = CookingText.GetComponent <Animator>();
            anim.SetBool("Play", true);
            if (CookingText.GetComponent <UserInterfaceAnimation>().state == AnimationState.IsFinished)
            {
                anim.SetBool("Play", false);
                anim       = null;
                imageState = ImageState.With;
            }
            break;
        }

        case ImageState.With: {
            anim = WithText.GetComponent <Animator>();
            anim.SetBool("Play", true);
            if (WithText.GetComponent <UserInterfaceAnimation>().state == AnimationState.IsFinished)
            {
                anim.SetBool("Play", false);
                anim       = null;
                imageState = ImageState.Tita;
            }
            break;
        }

        case ImageState.Tita: {
            anim = TitaText.GetComponent <Animator>();
            anim.SetBool("Play", true);
            if (TitaText.GetComponent <UserInterfaceAnimation>().state == AnimationState.IsFinished)
            {
                anim.SetBool("Play", false);
                anim       = null;
                imageState = ImageState.Image;
            }
            break;
        }

        case ImageState.Image: {
            anim = TitaImage.GetComponent <Animator>();
            anim.SetBool("Play", true);
            if (TitaImage.GetComponent <UserInterfaceAnimation>().state == AnimationState.IsFinished)
            {
                anim.SetBool("Play", false);
                anim       = null;
                imageState = ImageState.Ready;
            }
            break;
        }

        case ImageState.Ready: {
            ActionKeyImage.gameObject.SetActive(true);
            if (actionKeyPressed)
            {
                foreach (Image i in imageList)
                {
                    float alpha = i.color.a;

                    if (i.color.a > 0)
                    {
                        alpha -= Time.deltaTime;
                    }
                    else
                    {
                        _gameManager.miniGame = MiniGame.Exploration;
                    }
                    Color c = new Color(i.color.r, i.color.g, i.color.b, alpha);

                    i.color = c;
                }
            }
            break;
        }
        }
    }
Exemplo n.º 36
0
 protected override RequestedAction PostFlushChanges(ImageState s)
 {
     stop("render");
     return(RequestedAction.None);
 }
Exemplo n.º 37
0
 private void GetImageState( )
 {
     if (MyScreen != null && MyScreen.ElementCollection.Count > 1)
     {
         for (int j = 0; j < MyScreen.ElementCollection.Count-1; j++)
         {
             RectLayer screenlayer = (RectLayer)((RectLayer)MyScreen.ElementCollection[j]).ElementCollection[0];
             int elementNum = screenlayer.ElementCollection.Count;
             for (int i = 0; i < elementNum; i++)
             {
                 if (screenlayer.ElementCollection[i].GetType().BaseType == typeof(ILineElement))
                 {
                     _increaseOrDecreaseState =ImageState.Normal;
                     return;
                 }
                 else if (screenlayer.ElementCollection[i].GetType().BaseType == typeof(IRectElement))
                 {
                     if (SelectedEnvironMentIndex == 0)
                     {
                         _increaseOrDecreaseState = ImageState.Normal;
                         return;
                     }
                 }
             }
         }
     }
     _increaseOrDecreaseState = ImageState.Disable;
 }
Exemplo n.º 38
0
 public ImageStateChangedEventArgs(ImageState currentState)
 {
     CurrentState = currentState;
 }
Exemplo n.º 39
0
        /// <summary>
        /// Set picBoxStatus Image by ImageState
        /// </summary>
        /// <param name="state">State of Image View</param>
        protected void SetState(ImageState state)
        {
            switch (state)
            {
                case ImageState.NotLoad:
                    {
                        this.picBox.Image = this.ImageNotLoad;
                        Stop();
                    }
                    break;
                case ImageState.Loading:
                    {
                        this.picBox.Image = this.ImageLoading;
                        Start();

                    }
                    break;
                case ImageState.Loaded:
                    {
                        this.picBox.Image = this.ImageLoaded;
                        Stop();
                    }
                    break;
                default:
                    {
                        this.picBox.Image = this.ImageNotLoad;
                        Stop();
                    }
                    break;
            }
        }
Exemplo n.º 40
0
 private void OkOnMouseLeaveHandle(object sender, MouseEventArgs e)
 {
     ImageOk.Source = new BitmapImage(new Uri(@"/Clock;component/Imge/ok_normal.png",
                                              UriKind.RelativeOrAbsolute));
     okImageState = ImageState.Default;
 }
Exemplo n.º 41
0
 private void HttpImageErrorSeen()
 {
     _currentImageState = ImageState.ErrorShown;
     ShowErrorImage();
 }
Exemplo n.º 42
0
        /// <summary>
        /// Very unsecure way of doing moving on a screen that is of unknown size in ogl window....
        /// </summary>
        public void Move()
        {
            ticks = System.DateTime.Now.Ticks / TimeSpan.TicksPerSecond;

            if (this.oldTicks != 0)
            {
                #region Timed move - disabled
                /*
                //Console.WriteLine(DateTime.Now.ToString("hh:mm:ss.ffffff") + ": " + this.ticks + "-" + this.oldTicks + "=" + (this.ticks - this.oldTicks));

                if ((this.ticks - this.oldTicks) % 3 == 2)
                {
                    CurrentImage++;
                    if (CurrentImage > 7)
                    {
                        CurrentImage = 0;
                    }
                }

                if (
                    (CurrentMove == 0 && (this.ticks - this.oldTicks) > 6) ||
                    (CurrentMove == 1 && (this.ticks - this.oldTicks) > 6) ||
                    (CurrentMove == 2 && (this.ticks - this.oldTicks) > 13) ||
                    (CurrentMove == 3 && (this.ticks - this.oldTicks) > 13)
                   )
                {
                    if (CurrentMove == 3)
                    {
                        CurrentMove = 1;
                    }
                    CurrentMove++;
                    oldTicks = ticks;
                    //Console.WriteLine(DateTime.Now.ToString("hh:mm:ss.ffffff") + ": change move");
                }

                // Make move, this is so not good to have constant sizes on edges...
                switch (CurrentMove)
                {
                    case 0:
                        if (Y < 1.0f)
                        {
                            Y += Speed;
                        }
                        break;
                    case 3:
                    case 1:
                        if (X > -2.0f)
                        {
                            X -= Speed;
                        }
                        break;
                    case 2:
                        if (X < 2.0f)
                        {
                            X += Speed;
                        }
                        break;
                    default:
                        break;
                }
                */
                #endregion

                //Image selection
                if (CurrentImageSequence >= 10)
                {
                    CurrentImageSequence = 0;
                    switch (Util.Rnd.Next(0, 1000) / 100)
                    {
                        case 4: // Normal stop
                        case 3:
                        case 5:
                            ImageSequence = ImageState.NormalStop;
                            CurrentMove = MoveState.Stop;
                            break;
                        case 6: // Steroid
                        case 7:
                            ImageSequence = ImageState.Steroid;
                            CurrentMove = (MoveState)(Util.Rnd.Next(0, 999) / 500);
                            break;
                        case 8:// Steroid stop
                        case 9:
                            ImageSequence = ImageState.SteroidStop;
                            CurrentMove = MoveState.Stop;
                            break;
                        default: // Normal
                            ImageSequence = ImageState.Normal;
                            CurrentMove = (MoveState)(Util.Rnd.Next(0, 999) / 500);
                            break;
                    }
                }

                //Console.WriteLine((((this.ticks - this.oldTicks) / TimeSpan.TicksPerSecond) % 2) + ", " + ((this.ticks - this.oldTicks) / TimeSpan.TicksPerSecond));
                if (this.ticks != this.oldTicks && (
                    ( (((this.ticks - this.oldTicks) / TimeSpan.TicksPerSecond) % 2) == 0)
                   ))
                {
                    /*
                    CurrentImage++;

                    if (CurrentImage > 7)
                    {
                        CurrentImage = 0;
                    }*/

                    switch (ImageSequence)
                    {
                        case ImageState.Normal: //0,1,2,3,4,5
                        case ImageState.NormalStop:
                            CurrentImage++;
                            if (CurrentImage > 5)
                            {
                                CurrentImage = 0;
                            }
                            break;
                        case ImageState.Steroid: //0,1,2,3,6,7
                        case ImageState.SteroidStop:
                            CurrentImage++;
                            if (CurrentImage > 3 && CurrentImage < 6)
                            {
                                CurrentImage = 6;
                            }
                            else if (CurrentImage > 7)
                            {
                                CurrentImage = 0;
                            }
                            break;
                        default:
                            break;
                    }

                    oldTicks = ticks;
                    CurrentImageSequence++;
                }

                // Movements, fixed size :(
                switch (CurrentMove)
                {
                    case MoveState.Intro:
                        if (Y + Size.Height < 0.0f)
                        {
                            Y += 0.003f;
                        }
                        else
                        {
                            if ((Util.Rnd.Next(0, 1000) / 500.0) > 1.0)
                            {
                                CurrentMove = MoveState.MoveRight;
                            }
                            else
                            {
                                CurrentMove = MoveState.MoveLeft;
                            }

                        }
                        break;
                    case MoveState.MoveRight:
                        if (X - Size.Width > -2.0f)
                        {
                            X -= Speed;
                        }
                        else
                        {
                            CurrentMove = MoveState.MoveLeft;
                        }
                        break;
                    case MoveState.MoveLeft:
                        if (X + Size.Width < 1.5f)
                        {
                            X += Speed;
                        }
                        else
                        {
                            CurrentMove = MoveState.MoveRight;
                        }
                        break;
                    default: //MoveState.Stop
                        break;
                }
            }
            else if (oldTicks == 0)
            {
                oldTicks = ticks;
            }
        }
Exemplo n.º 43
0
        protected virtual void OnDownloaded(ImageHeaderEventArgs e)
        {
            //if (e.Locked)
            //{
            //    Common.UploaderLimiter.Release(e.Host);
            //    e.Locked = false;
            //}
            if (e.TriedDownload)
            {
                triedCount++;
            }

            if (e.Downloaded)
            {
                firstDownloadedTime = DateTime.Now;
                // ハッシュ値を計算
                MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                md5Hash = BitConverter.ToString(md5.ComputeHash(e.DownloadedData)).Replace("-", "").ToLower();
                downloadCompleted = true;
                downloadable = false;
                state = ImageState.DownloadComplete;
            }
            else
            {
                state = downloadable ? ImageState.DownloadPause : ImageState.DownloadFailed;
            }

            if (Downloaded != null)
            {
                Downloaded(this, e);
            }
        }
Exemplo n.º 44
0
 private void SetRadioButtonImageState(RadioButtonTS ctrl, ImageState state)
 {
     if (ctrl.ImageList == null) return;
     int index = ctrl.ImageList.Images.IndexOfKey(state.ToString());
     if (index < 0) return;
     ctrl.BackgroundImage = ctrl.ImageList.Images[index];
 }
Exemplo n.º 45
0
        internal CompositeImage GetImage(ImageState state, Color textColor)
        {
            Image image = null;
            if (state == ImageState.Disabled && (m_DisabledImage != null || m_DisabledImageIndex >= 0 || m_DisabledIcon != null || m_Image != null || m_ImageIndex >= 0 || m_Icon != null))
            {
                if (m_DisabledImage != null)
                    return new CompositeImage(m_DisabledImage, false, m_ImageSizeOverride);
                else if (m_DisabledIcon != null)
                    return new CompositeImage(m_DisabledIcon, false, m_ImageSizeOverride);
                if (m_DisabledImageIndex >= 0)
                {
                    DisposedCachedImageListImage();
                    image = GetImageFromImageList(m_DisabledImageIndex);
                    if (image != null)
                        return new CompositeImage(image, (image != m_ImageCachedIdx), m_ImageSizeOverride);
                    return null;
                }

                CreateDisabledImage();

                if (m_DisabledImage != null)
                    return new CompositeImage(m_DisabledImage, false, m_ImageSizeOverride);
                else if (m_DisabledIcon != null)
                    return new CompositeImage(m_DisabledIcon, false, m_ImageSizeOverride);
                else
                    return null;
            }

            if (m_Icon != null)
            {
                System.Drawing.Size iconSize = this.IconSize;
                System.Drawing.Icon icon = null;
                try
                {
                    icon = new System.Drawing.Icon(m_Icon, iconSize);
                }
                catch { icon = null; }
                if (icon == null)
                    return new CompositeImage(m_Icon, false, m_ImageSizeOverride);
                else
                    return new CompositeImage(icon, true, m_ImageSizeOverride);
            }

            if (state == ImageState.Hover && (m_HoverImage != null || m_HoverImageIndex >= 0))
            {
                if (m_HoverImage != null)
                    return new CompositeImage(m_HoverImage, false, m_ImageSizeOverride);
                if (m_HoverImageIndex >= 0)
                {
                    DisposedCachedImageListImage();
                    image = GetImageFromImageList(m_HoverImageIndex);
                    if (image != null)
                        return new CompositeImage(image, (image != m_ImageCachedIdx), m_ImageSizeOverride);
                    return null;
                }
            }

            if (state == ImageState.Pressed && (m_PressedImage != null || m_PressedImageIndex >= 0))
            {
                if (m_PressedImage != null)
                    return new CompositeImage(m_PressedImage, false, m_ImageSizeOverride);
                if (m_PressedImageIndex >= 0)
                {
                    DisposedCachedImageListImage();
                    image = GetImageFromImageList(m_PressedImageIndex);
                    if (image != null)
                        return new CompositeImage(image, (image != m_ImageCachedIdx), m_ImageSizeOverride);
                    return null;
                }
            }

            if (m_ImageSmall != null && (UseSmallImageResolved || m_ImageSizeOverride.Width == m_ImageSmall.Width && m_ImageSizeOverride.Height == m_ImageSmall.Height))
                return new CompositeImage(m_ImageSmall, false);
            if (m_Image != null)
            {
                if (_ImageAlt != null && textColor == Color.White)
                    return new CompositeImage(_ImageAlt, false, m_ImageSizeOverride);
                return new CompositeImage(m_Image, false, m_ImageSizeOverride);
            }
            if (m_ImageIndex >= 0)
            {
                if (m_DisabledImageIndex >= 0 || m_HoverImageIndex >= 0 || m_PressedImageIndex >= 0)
                    DisposedCachedImageListImage();
                image = GetImageFromImageList(m_ImageIndex);
                if (image != null)
                    return new CompositeImage(image, (image != m_ImageCachedIdx), m_ImageSizeOverride);
            }

            return null;
        }
Exemplo n.º 46
0
    /// <summary>
    /// Starts up the after images. Does nothing if images are currently on.
    /// </summary>
    public void StartImages()
    {
        if (state == ImageState.ON) return;

        imagePositions = new Vector3[positionsToSave];
        imagesInPlay = 0;
        index = 0;
        foreach (Transform t in images)
        {
            if (t.gameObject != null)
            {
                t.GetComponent<Afterimage>().offset = 0;
            }
        }
        state = ImageState.ON;
    }
Exemplo n.º 47
0
 private static void SetCheckBoxImageState(CheckBox ctrl, ImageState state)
 {
     if (ctrl.ImageList == null) return;
     int index = ctrl.ImageList.Images.IndexOfKey(state.ToString());
     if (index < 0) return;
     ctrl.BackgroundImage = ctrl.ImageList.Images[index];
 }
Exemplo n.º 48
0
        protected override RequestedAction PreRenderImage(ImageState s)
        {
            //Skip this when we are doing simulations
            if (s.destGraphics == null)
            {
                return(RequestedAction.None);
            }

            string sf = s.settings["fi.scale"];

            if (string.IsNullOrEmpty(sf))
            {
                return(RequestedAction.None);
            }
            bool validAlg            = false;
            FREE_IMAGE_FILTER filter = ParseResizeAlgorithm(sf, FREE_IMAGE_FILTER.FILTER_CATMULLROM, out validAlg);

            if (!validAlg)
            {
                throw new ImageProcessingException("The specified resizing filter '" + sf + "' did not match bicubic, bilinear, box, bspline, catmullrom, or lanczos.");
            }

            //Set copy attributes
            s.copyAttibutes.SetWrapMode(WrapMode.TileFlipXY);


            //The minimum dimensions of the temporary bitmap.
            SizeF targetSize = PolygonMath.getParallelogramSize(s.layout["image"]);

            targetSize = new SizeF((float)Math.Ceiling(targetSize.Width), (float)Math.Ceiling(targetSize.Height));

            s.ApplyCropping();
            s.EnsurePreRenderBitmap();

            //The size of the temporary bitmap.
            //We want it larger than the size we'll use on the final copy, so we never upscale it
            //- but we also want it as small as possible so processing is fast.
            SizeF    tempSize   = PolygonMath.ScaleOutside(targetSize, s.copyRect.Size);
            int      tempWidth  = (int)Math.Ceiling(tempSize.Width);
            int      tempHeight = (int)Math.Ceiling(tempSize.Height);
            FIBITMAP src        = FIBITMAP.Zero;
            FIBITMAP midway     = FIBITMAP.Zero;

            try {
                var oldbit = s.preRenderBitmap ?? s.sourceBitmap;
                //Crop if needed, Convert, scale, then convert back.
                src = FreeImage.CreateFromBitmap(oldbit);

                midway = FreeImage.Rescale(src, tempWidth, tempHeight, filter);
                FreeImage.UnloadEx(ref src);
                //Clear the old pre-rendered image if needed
                if (s.preRenderBitmap != null)
                {
                    s.preRenderBitmap.Dispose();
                }
                //Reassign the pre-rendered image
                s.preRenderBitmap = FreeImage.GetBitmap(midway);
                s.copyRect        = new RectangleF(0, 0, s.preRenderBitmap.Width, s.preRenderBitmap.Height);
                FreeImage.UnloadEx(ref midway);
                s.preRenderBitmap.MakeTransparent();
            } finally {
                if (!src.IsNull)
                {
                    FreeImage.UnloadEx(ref src);
                }
                if (!midway.IsNull)
                {
                    FreeImage.UnloadEx(ref midway);
                }
            }


            return(RequestedAction.Cancel);
        }
Exemplo n.º 49
0
 protected override RequestedAction RenderOverlays(ImageState s)
 {
     return(RenderLayersForLevel(s, Layer.LayerPlacement.Overlay));
 }
Exemplo n.º 50
0
        private void SetCheckBoxImageState(CheckBox ctrl, ImageState state)
        {
            if (ctrl.ImageList == null)
            {
                return;
            }
            int index = ctrl.ImageList.Images.IndexOfKey(state.ToString());

            if (index < 0)
            {
                if (console.SkinsEnabled)
                {
                    switch (state)
                    {
                    case (ImageState.NormalDown):
                    {
                        ctrl.BackgroundImage = null;
                        ctrl.ForeColor       = console.SkinsButtonTxtColor;
                        ctrl.BackColor       = console.ButtonSelectedColor;
                        return;
                    };

                    case (ImageState.MouseOverUp):
                    {
                        return;
                    };

                    case (ImageState.MouseOverDown):
                    {
                        return;
                    };

                    default:
                    {
                        ctrl.BackgroundImage = null;
                        ctrl.ForeColor       = console.SkinsButtonTxtColor;
                        ctrl.BackColor       = SystemColors.Control;
                        return;
                    }
                    }
                    ;
                }
                else
                {
                    switch (state)
                    {
                    case (ImageState.NormalDown):
                    {
                        ctrl.BackgroundImage = null;
                        ctrl.ForeColor       = console.SkinsButtonTxtColor;
                        return;
                    };

                    case (ImageState.MouseOverUp):
                    {
                        return;
                    };

                    case (ImageState.MouseOverDown):
                    {
                        return;
                    };

                    default:
                    {
                        ctrl.BackgroundImage = null;
                        ctrl.ForeColor       = console.SkinsButtonTxtColor;
                        ctrl.BackColor       = SystemColors.Control;
                        return;
                    }
                    }
                    ;
                }
            }
            ctrl.BackgroundImage = ctrl.ImageList.Images[index];
        }
Exemplo n.º 51
0
 /// <summary>
 /// Allows the game component to perform any initialization it needs to before starting
 /// to run.  This is where it can query for any required services and load content.
 /// </summary>
 public override void Initialize()
 {
     // TODO: Add your initialization code here
     imagestate = ImageState.Deferred;
     base.Initialize();
 }
Exemplo n.º 52
0
        protected override RequestedAction LayoutImage(ImageState s)
        {
            //Only activated if both width and height are specified, and mode=crop.
            if (s.settings.Mode != FitMode.Crop || s.settings.Width < 0 || s.settings.Height < 0)
            {
                return(RequestedAction.None);
            }

            //Calculate bounding box for all coordinates specified.
            double[] focus = NameValueCollectionExtensions.GetList <double>(s.settings, "c.focus", null, 2, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72);
            if (focus == null)
            {
                return(RequestedAction.None);
            }
            RectangleF box = PolygonMath.GetBoundingBox(focus);

            var bounds = new RectangleF(new PointF(0, 0), s.originalSize);

            //Clip box to original image bounds
            box = PolygonMath.ClipRectangle(box, bounds);

            var targetSize = new SizeF(s.settings.Width, s.settings.Height);

            SizeF copySize;

            //Now, we can either crop as closely as possible or as loosely as possible.
            if (NameValueCollectionExtensions.Get <bool>(s.settings, "c.zoom", false) && box.Width > 0 && box.Height > 0)
            {
                //Crop close
                copySize = PolygonMath.ScaleOutside(box.Size, targetSize);
            }
            else
            {
                //Crop minimally
                copySize = PolygonMath.ScaleInside(targetSize, bounds.Size);
                //Ensure it's outside the box
                if (!PolygonMath.FitsInside(box.Size, copySize))
                {
                    copySize = PolygonMath.ScaleOutside(box.Size, copySize);
                }
            }
            //Clip to bounds.
            box = PolygonMath.ClipRectangle(PolygonMath.ExpandTo(box, copySize), bounds);

            s.copyRect = box;

            ///What is the vertical and horizontal aspect ratio different in result pixels?
            var padding = PolygonMath.ScaleInside(box.Size, targetSize);

            padding = new SizeF(targetSize.Width - padding.Width, targetSize.Height - padding.Height);


            //So, if we haven't met the aspect ratio yet, what mode will we pass on?
            var finalmode = NameValueCollectionExtensions.Get <FitMode>(s.settings, "c.finalmode", FitMode.Pad);

            //Crop off 1 or 2 pixels instead of padding without worrying too much
            if (finalmode == FitMode.Pad && padding.Width + padding.Height < 3)
            {
                finalmode = FitMode.Crop;
            }

            s.settings.Mode = finalmode;

            return(RequestedAction.None);
        }
Exemplo n.º 53
0
    // Update is called once per frame
    void Update()
    {
        if (m_CharaIdCurrent != m_CharaIdRequest)
        {
            if (m_CharaIdRequest != 0)
            {
                m_CharaIdCurrent = m_CharaIdRequest;

                bool is_load = false;

                if (m_CharaIdCurrent > 0)
                {
                    // 通常ユニット
                    MasterDataParamChara master_chara = BattleParam.m_MasterDataCache.useCharaParam((uint)m_CharaIdCurrent);
                    if (master_chara != null)
                    {
                        float uv_off_x = master_chara.img_2_offsetX * 0.001f;
                        float uv_off_y = master_chara.img_2_offsetY * 0.001f;
                        float uv_size  = master_chara.img_2_tiling * 0.001f;
                        uv_size         *= 0.5f;
                        m_FaceCenterUv.x = uv_off_x + uv_size;
                        m_FaceCenterUv.y = uv_off_y + uv_size;
                        m_FaceUvSize     = uv_size * 0.5f * 1.2f;

                        m_CharaScaleAdjust = 1.0f;
                        if (m_ImageType == ImageType.CUTIN_DISP || m_ImageType == ImageType.CUTIN_DISP2)
                        {
                            // スキルカットインの時はキャラ表示サイズの大小の差を緩和(小さいものも大きめに表示)
                            m_CharaScaleAdjust = 1.0f + (640.0f - master_chara.size_width) * (0.5f / 640.0f);
                        }

                        m_EnemyDispMeshSize.x = master_chara.size_width * m_CharaScaleAdjust / m_MeterPerDot;
                        m_EnemyDispMeshSize.y = master_chara.size_height * m_CharaScaleAdjust / m_MeterPerDot;
                        if (m_ImageType != ImageType.FACE)
                        {
                            m_PivotType = master_chara.pivot;
                        }
                        else
                        {
                            m_PivotType = MasterDataDefineLabel.PivotType.NONE;
                        }
                        m_CharaWidth = master_chara.side_offset * 2.0f / m_MeterPerDot;
                        m_CharaTall  = master_chara.size_height / m_MeterPerDot; // 表示基準位置から上方向の高さ
                        if (m_PivotType == MasterDataDefineLabel.PivotType.CENTER)
                        {
                            if (m_CharaWidth >= 4.9f)
                            {
                                m_CharaTall *= 0.8f;
                            }
                            m_CharaTall *= 0.5f;
                        }

                        is_load = true;
                    }
                    else
                    {
                        m_MainSprite      = null;
                        m_TextureMask     = null;
                        m_TextureSize     = Vector2.zero;
                        m_Mesh            = null;
                        m_State           = ImageState.ERROR_IMAGE;
                        m_IsChangeTexture = true;
                    }
                }
                else
                {
                    // 主人公
                    m_FaceCenterUv.x = 0.5f;
                    m_FaceCenterUv.y = 0.5f;
                    m_FaceUvSize     = 0.1f;

                    m_EnemyDispMeshSize.x = 5.0f * 1.6f;
                    m_EnemyDispMeshSize.y = 5.0f * 1.6f;
                    m_PivotType           = MasterDataDefineLabel.PivotType.NONE;
                    m_CharaWidth          = m_EnemyDispMeshSize.x;

                    is_load = true;
                }

                if (is_load)
                {
                    // テクスチャロード
                    m_State = ImageState.LOADING;
                    if (BattleUnitTextureCache.HasInstance)
                    {
                        BattleUnitTextureCache.Instance.loadTexture(m_CharaIdCurrent, false);
                    }
                    else
                    {
                        AssetBundler.Create().
                        SetAsUnitTexture((uint)m_CharaIdCurrent,
                                         (o) =>
                        {
                            Texture2D texture = o.GetTexture2D(TextureWrapMode.Clamp);
                            m_MainSprite      = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), Vector2.one * 0.5f, 128, 0, SpriteMeshType.FullRect);
                            m_TextureMask     = null;
                            if (m_MainSprite != null)
                            {
                                m_State           = ImageState.READY_IMAGE;
                                m_IsChangeTexture = true;

                                calcSpriteAdjustment();
                            }
                            else
                            {
                                m_State           = ImageState.ERROR_IMAGE;
                                m_IsChangeTexture = true;
                            }
                        },
                                         (s) =>
                        {
                            m_State = ImageState.ERROR_IMAGE;
                        }
                                         ).Load();
                    }
                }
                else
                {
                    m_State           = ImageState.ERROR_IMAGE;
                    m_IsChangeTexture = true;
                }
            }
            else
            {
                clearCharaID();
            }
        }

        if (m_State == ImageState.LOADING &&
            BattleUnitTextureCache.HasInstance
            )
        {
            BattleUnitTextureCache.Status tex_status = BattleUnitTextureCache.Instance.getStatus(m_CharaIdCurrent);
            if (tex_status == BattleUnitTextureCache.Status.READY)
            {
                m_MainSprite      = BattleUnitTextureCache.Instance.getSprite(m_CharaIdCurrent);
                m_TextureMask     = BattleUnitTextureCache.Instance.getTexture(m_CharaIdCurrent, true);
                m_State           = ImageState.READY_IMAGE;
                m_IsChangeTexture = true;

                calcSpriteAdjustment();
            }
            else
            if (tex_status != BattleUnitTextureCache.Status.LOADING)
            {
                m_MainSprite      = null;
                m_TextureMask     = null;
                m_State           = ImageState.ERROR_IMAGE;
                m_IsChangeTexture = true;
            }
        }

        if (m_IsChangeTexture)
        {
            switch (m_CompnentType)
            {
            case CompnentType.SPRITE_RENDERER:
            {
                m_SpriteRenderer.sprite = m_MainSprite;

                if (m_MainSprite != null)
                {
                    if (m_TextureMask == null)
                    {
                        m_SpriteRenderer.material = m_OriginalMaterial;
                    }
                    else
                    {
                        m_SpriteRenderer.material = m_AlphaMaskMaterial;
                        m_SpriteRenderer.material.SetTexture("_AlphaTex", m_TextureMask);
                    }
                    transform.localPosition = m_SpriteOffsetPosition;
                    transform.localScale    = new Vector3(m_SpriteScale, m_SpriteScale, m_SpriteScale);

                    m_SpriteRenderer.enabled = true;
                }
                else
                {
                    m_SpriteRenderer.enabled = false;
                }
            }
            break;

            case CompnentType.MESH_RENDERER:
                break;

            case CompnentType.UI_IMAGE:
            {
                m_ImageComponent.sprite = m_MainSprite;
                if (m_MainSprite != null)
                {
                    m_ImageComponent.SetNativeSize();

                    if (m_TextureMask == null)
                    {
                        m_ImageComponent.material = m_OriginalMaterial;
                    }
                    else
                    {
                        m_ImageComponent.material = m_AlphaMaskMaterial;
                        m_ImageComponent.material.SetTexture("_AlphaTex", m_TextureMask);
                    }
                    transform.localPosition = m_SpriteOffsetPosition;
                    transform.localScale    = new Vector3(m_SpriteScale, m_SpriteScale, m_SpriteScale);

                    m_ImageComponent.enabled = true;
                }
                else
                {
                    m_ImageComponent.enabled = false;
                }
            }
            break;
            }
        }

        if (m_IsChangeColor || m_IsChangeTexture)
        {
            switch (m_CompnentType)
            {
            case CompnentType.SPRITE_RENDERER:
            {
                m_IsChangeColor        = false;
                m_SpriteRenderer.color = m_Color;
            }
            break;

            case CompnentType.MESH_RENDERER:
            {
                m_IsChangeColor = false;
                m_MeshRenderer.material.color = m_Color;
            }
            break;

            case CompnentType.UI_IMAGE:
            {
                m_IsChangeColor        = false;
                m_ImageComponent.color = m_Color;
            }
            break;
            }
        }

        m_IsChanged       = m_IsChangeTexture;
        m_IsChangeTexture = false;
    }
Exemplo n.º 54
0
 private void NewHttpImageRequested()
 {
     _currentImageState = ImageState.DefaultShown;
     ShowDefaultImage();
 }
Exemplo n.º 55
0
        protected override RequestedAction RenderImage(ImageState s)
        {
            //Skip this when we are doing simulations
            if (s.destGraphics == null)
            {
                return(RequestedAction.None);
            }

            //If there's pre-rendering involved this optimization is utterly pointless.
            if (s.preRenderBitmap != null)
            {
                return(RequestedAction.None);
            }

            //Find out what the speed setting is.
            int speed = 0;

            if (string.IsNullOrEmpty(s.settings["speed"]) || !int.TryParse(s.settings["speed"], NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out speed))
            {
                speed = 0;
            }

            if (speed < 1)
            {
                return(RequestedAction.None);
            }

            s.destGraphics.CompositingMode    = CompositingMode.SourceCopy;
            s.destGraphics.CompositingQuality = CompositingQuality.HighSpeed;
            if (speed == 1)
            {
                s.destGraphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
            }
            else
            {
                s.destGraphics.InterpolationMode = InterpolationMode.Bilinear;
            }

            s.destGraphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;
            s.destGraphics.SmoothingMode   = SmoothingMode.HighSpeed;

            s.copyAttibutes.SetWrapMode(WrapMode.TileFlipXY);

            if (speed < 3)
            {
                s.destGraphics.DrawImage(s.sourceBitmap, PolygonMath.getParallelogram(s.layout["image"]), s.copyRect, GraphicsUnit.Pixel, s.copyAttibutes);
            }
            else if (speed < 4)
            {
                Rectangle midsize = PolygonMath.ToRectangle(PolygonMath.GetBoundingBox(s.layout["image"]));

                using (Image thumb = s.sourceBitmap.GetThumbnailImage(midsize.Width, midsize.Height, delegate() { return(false); }, IntPtr.Zero)) {
                    double     xfactor  = (double)thumb.Width / (double)s.sourceBitmap.Width;
                    double     yfactor  = (double)thumb.Height / (double)s.sourceBitmap.Height;
                    RectangleF copyPart = new RectangleF((float)(s.copyRect.Left * xfactor),
                                                         (float)(s.copyRect.Top * yfactor),
                                                         (float)(s.copyRect.Width * xfactor),
                                                         (float)(s.copyRect.Height * yfactor));
                    if (Math.Floor(copyPart.Height) == thumb.Height || Math.Ceiling(copyPart.Height) == thumb.Height)
                    {
                        copyPart.Height = thumb.Height;
                    }
                    if (Math.Floor(copyPart.Width) == thumb.Width || Math.Ceiling(copyPart.Width) == thumb.Width)
                    {
                        copyPart.Width = thumb.Width;
                    }
                    s.destGraphics.DrawImage(thumb, PolygonMath.getParallelogram(s.layout["image"]), copyPart, GraphicsUnit.Pixel, s.copyAttibutes);
                }
            }
            else
            {
                RectangleF box = PolygonMath.GetBoundingBox(PolygonMath.getParallelogram(s.layout["image"]));
                s.destGraphics.CompositingMode = CompositingMode.SourceCopy;
                s.destGraphics.DrawImage(s.sourceBitmap, box.Left, box.Top, box.Width, box.Height);
            }

            return(RequestedAction.Cancel);
        }
Exemplo n.º 56
0
 private void NewImageAvailable(T image)
 {
     _currentImageState = ImageState.HttpImageShown;
     FireImageChanged(image);
 }
Exemplo n.º 57
0
 public void ResetState()
 {
     downloadCompleted = false;
     downloadable = true;
     state = ImageState.Non;
     triedCount = 0;
     firstDownloadedTime = DateTime.MinValue;
 }