예제 #1
1
        /// <summary>
        /// Draws the sprite. and Add the scene.
        /// 文字列(のsprite)を作成するメソッド
        /// </summary>
        /// <returns>
        /// The sprite.
        /// </returns>
        /// <param name='drawStr'>
        /// Draw string.
        /// </param>
        /// <param name='positionX'>
        /// Position x.
        /// </param>
        /// <param name='positionY'>
        /// Position y.
        /// </param>
        /// <param name='fontSize'>
        /// Font size.
        /// </param>
        /// <param name='fontColor'>
        /// Font color.
        /// </param>
        public static SpriteUV DrawSprite(String drawStr,float positionX, float positionY,
		                                   int fontSize,ImageColor fontColor)
        {
            //Director.Initialize(); //重要なんで最初にinitializeしようね。GameEngine2Dのために必要(たぶんほかにも)
            //Scene  //Sce.Pss.HighLevel.GameEngine2DのScene()
            //scene.Camera.SetViewFromViewport(); //CameraをDisplayで使う たぶん画面サイズ -> 3DCGソフトでいうところのカメラ。それの移してる範囲=画面サイズ
            positionX = Const.DISPLAY_WIDTH - Const.DISPLAY_WIDTH*(Const.GRID_NUM_X-positionX)/Const.GRID_NUM_X;
            positionY = Const.DISPLAY_HEIGHT - Const.DISPLAY_HEIGHT*(Const.GRID_NUM_Y-positionY)/Const.GRID_NUM_Y;
            //the Director's OpenGL context たぶん画面サイズの幅
            //var width = (int)Const.getVITA_DISPLAY_WIDTH();
            //var height = (int)Const.getVITA_DISPLAY_HEIGHT();

            //Font font = new Font(FontAlias.System, fontSize, FontStyle.Regular);
            Font font = new Font(Const.DEFAULT_FONT, fontSize, FontStyle.Regular); //日本語使う
            var width = font.GetTextWidth(drawStr);
            var height = font.GetTextWidth("oo");
            //Console.WriteLine(width + " : " + height);

            //Image classはimageデータを保つよ~。 PNG or JPGなど
            //今回はblankのnew Image でも、これ作らないと img.DrawTextが使えない
            Image img = new Image(ImageMode.Rgba,
                                  new ImageSize(width,height), //固定で。たぶん描画範囲
                                  new ImageColor(255,0,0,0));//blankなので変更しても意味なし
            //ここで文字を作ってる
            img.DrawText(drawStr,
                         fontColor,
                         font,
                         new ImagePosition(0, 0)); //画面の位置

            //textureを作る
            Texture2D texture = new Texture2D(width,
                                              height,
                                              false,
                                              PixelFormat.Rgba);

            //Texture2D を使うためにimageからpixelデータに変換(img.ToBuffer())
            //それをtexture.SetPixelsでtextureにPixcelデータを貼り付け
            texture.SetPixels(0, img.ToBuffer());
            //で一覧のimgの処理を実行
            img.Dispose();

            //新しいTexture作るときはTextureInfoも作らないとね
            TextureInfo ti = new TextureInfo();
            ti.Texture = texture;

            //スプライト(イメージパターン)を作る。まぁ、テクスチャだし
            SpriteUV sprite = new SpriteUV();
            sprite.TextureInfo = ti;

            //テクスチャーの貼り付けられた長方形(quad.S)を作成。サイズはImage img = new Imageのとこ。たぶん
            sprite.Quad.S = ti.TextureSizef;
            sprite.CenterSprite();
            //sprite.Position = scene.Camera.CalcBounds().Center;

            positionX = positionX + sprite.Quad.S.X/2;
            positionY = Const.DISPLAY_HEIGHT- positionY - sprite.Quad.S.Y;

            sprite.Position = new Vector2(positionX,positionY);

            return sprite;
        }
예제 #2
0
        public virtual bool Create_Legend(string path, string name)
        {
            //提取legendInfo
            string[] colors     = null;
            string[] titlesInfo = null;
            this.InitRenderInfos("titlesInfo", ref titlesInfo, "legendInfo");
            this.InitRenderInfos("colorsInfo", ref colors, "legendInfo");

            //计算图例区间
            ImageColor pBackground = new ImageColor("#192734");
            int        fontSize = 18, titleH = 46;
            int        nOffset_x = 10, nOffset_y = 10, nStepX = 10, nStepY = 10;
            int        nW_legend = 60, nH_legend = 20;
            int        nH   = colors.Length * (nH_legend + nStepY) - nStepY + nOffset_y * 2 + nStepX + titleH;
            int        nW   = nW_legend + nOffset_x * 2 + nW_legend + nStepY * 2;
            int        nNum = colors.Length - 1;

            string pathLengend = Directory.GetCurrentDirectory() + "/ModelData/Image/GIS/Legend.png";

            _Image_legend = new ImageObj();
            _Image_legend.Create(pathLengend, nW, nH);
            for (int i = 0; i < colors.Length; i++)
            {
                _Image_legend.DrawPolygon(nOffset_x, nOffset_y + titleH + i * (nH_legend + nStepY), _ImageColors[nNum - i].Color, 1, nW_legend, nH_legend, false);
                _Image_legend.DrawText(nOffset_x + nW_legend + nStepX, nOffset_y + titleH + i * (nH_legend + nStepY), _ImageColors[nNum - i].Color, titlesInfo[i], null, 11, true, false, Alignment.Near, Alignment.Near);
            }
            _Image_legend.DrawText(nW / 2, nOffset_y, pBackground.Color, "图例", null, fontSize, true, false, Alignment.Center, Alignment.Near);
            if (name + "" != "")
            {
                _Image_legend.Name = name;
            }
            return(_Image_legend.Save(path));
        }
예제 #3
0
        public override bool Render_Draw(ImageObj img = null)
        {
            //提取元数据、初始绘图对象
            if (base.Render_Draw(img) == false)
            {
                return(false);
            }
            IMetadataR pMetadata = (IMetadataR)_Metadata;

            if (pMetadata == null)
            {
                return(false);
            }

            //循环绘制
            ImageColor pColor = null;

            float[] datas   = null;
            bool    bResult = _GdalReadR.GetDatas(1, ref datas);

            for (int i = 0; i < pMetadata.Rows; i++)
            {
                for (int j = 0; j < pMetadata.Cols; j++)
                {
                    pColor = GetColor(datas[i * pMetadata.Cols + j]);
                    //Task.Run(() => _Image.Draw(i, j, pColor.Color));
                    _Image.Draw(j, i, pColor.Color);
                }
                ;
                //Task.Run(() => Draws(pMetadata, i, datas));
            }
            return(bResult);
        }
예제 #4
0
        /// <summary>
        /// カラーフレームを取得した時のイベント
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void colorFrameReader_FrameArrived(object sender, ColorFrameArrivedEventArgs e)
        {
            using (var colorFrame = e.FrameReference.AcquireFrame())
            {
                if (colorFrame == null)
                {
                    return;
                }
                //BGRAデータを登録
                colorBuffer = new byte[colorFrameDesc.Width * colorFrameDesc.Height * colorFrameDesc.BytesPerPixel];
                colorFrame.CopyConvertedFrameDataToArray(colorBuffer, ColorImageFormat.Bgra);

                bitmapSource = BitmapSource.Create(colorFrameDesc.Width, colorFrameDesc.Height, 96, 96,
                                                   PixelFormats.Bgra32, null, colorBuffer, colorFrameDesc.Width * (int)colorFrameDesc.BytesPerPixel);
                //ImageColor.Source = bitmapSource;
                ImageColor.SetCurrentValue(System.Windows.Controls.Image.SourceProperty, bitmapSource);

                if (RecordPoints.IsChecked == true && frameCount % 3 == 0)
                {
                    using (Stream stream =
                               new FileStream(pathSaveFolder + "image/" + StopWatch.ElapsedMilliseconds + ".jpg", FileMode.Create))
                    {
                        JpegBitmapEncoder encoder = new JpegBitmapEncoder();
                        encoder.Frames.Add(BitmapFrame.Create(bitmapSource));
                        encoder.Save(stream);
                        stream.Close();
                    }
                }
                frameCount++;
            }
        }
예제 #5
0
        public void TestConvertNoImageToGrayscale()
        {
            byte[] imageBytes = System.Array.Empty <byte>();

            byte[] convertedImage = ImageColor.ColorImageToGrayscale(imageBytes);

            Assert.AreEqual(convertedImage.Length, 0);
        }
예제 #6
0
        /// <summary>
        /// Draws the sprite. and Add the scene.
        /// 文字列(のsprite)を作成し、sceneに追加するメソッド
        /// </summary>
        /// <returns>
        /// The sprite.
        /// </returns>
        /// <param name='drawStr'>
        /// Draw string.
        /// </param>
        /// <param name='positionX'>
        /// Position x.
        /// </param>
        /// <param name='positionY'>
        /// Position y.
        /// </param>
        /// <param name='fontSize'>
        /// Font size.
        /// </param>
        /// <param name='fontColor'>
        /// Font color.
        /// </param>
        /// <param name='scene'>
        /// Scene.
        /// </param>
        public static SpriteUV DrawSprite(String drawStr,float positionX, float positionY,
		                                   int fontSize,ImageColor fontColor, Scene scene)
        {
            SpriteUV sprite = DrawSprite(drawStr,positionX, positionY, fontSize, fontColor);
            //sceneにspriteを追加
            scene.AddChild(sprite);

            return sprite;
        }
예제 #7
0
        public void TestConvertInvalidImageToGrayscale()
        {
            byte[] imageBytes =
            {
                50
            };

            ImageColor.ColorImageToGrayscale(imageBytes);
        }
예제 #8
0
        public void TestCombineAllWithNegative()
        {
            string resourcePath = "Freedom35.ImageProcessing.Tests.Resources.clock.bmp";

            // Load source image
            using Image sourceImage = TestImage.FromResource(resourcePath);
            Assert.IsNotNull(sourceImage);

            using Image negativeCopy = ImageColor.ToNegative(sourceImage);
            Assert.IsNotNull(negativeCopy);

            Image[] imagesToCombine = new Image[]
            {
                sourceImage,
                negativeCopy
            };

            Bitmap combinedImage = ImageCombine.All(imagesToCombine);

            // Get bytes for images
            byte[] combinedBytes = ImageBytes.FromImage(combinedImage);

            // Just check first row of bytes has been combined
            for (int i = 0; i < combinedImage.Width; i++)
            {
                Assert.AreEqual(byte.MaxValue, combinedBytes[i]);
            }

            int pixelDepth = 3;
            int stride     = 1056;
            int width      = 1053;
            int height     = combinedImage.Height;

            int limit = combinedBytes.Length - 4;

            // Compare combined bytes excluding stride padding
            for (int y = 0; y < height; y++)
            {
                int offset = y * stride;

                for (int x = 0; x < width; x += pixelDepth)
                {
                    int i = offset + x;

                    if (i < limit)
                    {
                        Assert.AreEqual(byte.MaxValue, combinedBytes[i]);
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
예제 #9
0
 //写点
 void SetPixel(int16_t x, int16_t y, ImageColor col)
 {
     if (col == Image_ColorRode)
     {
         tImage[y * IMAGE_WIDTH / 8 + x / 8] &= (byte)(~(0x80 >> (x % 8)));
     }
     else
     {
         tImage[y * IMAGE_WIDTH / 8 + x / 8] |= (byte)(0x80 >> (x % 8));
     }
 }
예제 #10
0
    internal void PreviewModel(AvatarModel heroModel, AvatarModel target, bool friendly)
    {
        Card c = target != null ? target.Card : null;

        Prepare(heroModel, c, global::WhereAmI.Board);

        //on board there is no color
        ImageColor.SetActive(false);
        PanelAttack.GetComponent <PanelValue>().Prepare(target != null ? target.ActualAttack:0);
        PanelHealth.GetComponent <PanelValue>().Prepare(target != null ? target.ActualHealth:0);
        PanelArmor.GetComponent <PanelValue>().Prepare(target != null ? target.Armor : 0);

        ImageBorder.SetActive(target != null);
        if (target != null)
        {
            ImageBorder.GetComponent <Image>().color    = target.MovesLeft > 0 ? Color.green : Color.black;
            ImageBorder.GetComponent <Image>().material = Image.defaultGraphicMaterial;

            if (!friendly)
            {
                ImageBorder.GetComponent <Image>().color    = Color.red;
                ImageBorder.GetComponent <Image>().material = SpriteManager.Font.material;
            }
        }
        bool hasTaunt  = false;
        bool hasSticky = false;

        if (target != null)
        {
            foreach (CastedCard cc in target.Effects)
            {
                if (cc.Params.ContainsKey(CastedCardParamType.Taunt))
                {
                    hasTaunt = true;
                }
            }

            foreach (KeyValuePair <Side, AvatarModel> kvp in target.AdjacentModels)
            {
                if (kvp.Value != null)
                {
                    foreach (CastedCard cc in kvp.Value.Effects)
                    {
                        if (cc.Params.ContainsKey(CastedCardParamType.Sticky))
                        {
                            hasSticky = true;
                        }
                    }
                }
            }
        }
        ImageTaunt.SetActive(hasTaunt);
        ImageSticky.SetActive(hasSticky);
    }
예제 #11
0
        protected bool Draws(IMetadataR pMetadata, int i, float[] datas)
        {
            ImageColor pColor = null;

            for (int j = 0; j < pMetadata.Cols; j++)
            {
                pColor = GetColor(datas[i * pMetadata.Cols + j]);
                _Image.Draw(j, i, pColor.Color);
            }
            ;
            return(true);
        }
예제 #12
0
        protected bool DrawGeometry(Geometry pGeometry, ImageColor _color)
        {
            //pGeometry.

            //ImageColor pColor = null;
            //for (int j = 0; j < pMetadata.Cols; j++)
            //{
            //    pColor = GetColor(datas[i * pMetadata.Cols + j]);
            //    _Image.Draw(j, i, pColor.Color);
            //};
            return(true);
        }
예제 #13
0
        public void TestConvertToBackAndWhite()
        {
            byte[] imageBytes =
            {
                50,
                100,
                150
            };

            byte[] convertedImage = ImageColor.GrayscaleImageToBlackAndWhite(imageBytes);

            Assert.IsTrue(convertedImage.All(b => b == 0 || b == 255));
        }
예제 #14
0
        public void TestConvertMonochromeToNegative()
        {
            byte[] imageBytes =
            {
                1,
                0
            };

            ImageColor.MonochromeToNegative(imageBytes);

            Assert.AreEqual(0, imageBytes[0]);
            Assert.AreEqual(1, imageBytes[1]);
        }
예제 #15
0
        public void TestConvertToGrayscale()
        {
            byte[] imageBytes =
            {
                50,
                100,
                150
            };

            byte[] convertedImage = ImageColor.ColorImageToGrayscale(imageBytes);

            Assert.IsNotNull(convertedImage);
            Assert.AreEqual(convertedImage.Length, imageBytes.Length / 3);
            Assert.AreEqual(convertedImage[0], imageBytes.Average(b => b));
        }
예제 #16
0
        public void TestConvertToNegative()
        {
            byte[] imageBytes =
            {
                0x01,
                0xf0,
                0x3c
            };

            ImageColor.ToNegative(imageBytes);

            Assert.AreEqual(0xfe, imageBytes[0]);
            Assert.AreEqual(0x0f, imageBytes[1]);
            Assert.AreEqual(0xc3, imageBytes[2]);
        }
예제 #17
0
        /// <summary>
        /// Convert toàn bộ các trang tài liệu dạng ảnh nền
        /// </summary>
        public void SlideAsBackground(NormalPage _page, pp.Slide _slide)
        {
            HelperClass helperClass = new HelperClass();
            ImageColor  imgColor    = new ImageColor();

            imgColor.Source = new Image();
            imgColor.ScaleX = 1;
            imgColor.ScaleY = 1;
            imgColor.Source.OpenFile(Path.Combine((System.Windows.Application.Current as IAppGlobal).DocumentTempFolder, "Slide_" + _slide.SlideIndex.ToString() + ".png"), false);
            _page.MainLayer            = new PageLayer();
            _page.MainLayer.Background = imgColor;
            _page.ID = ObjectElementsHelper.RandomString(13);
            //----Hiệu ứng trang
            helperClass.GetTransition(_slide, _page);
        }
예제 #18
0
        //取点
        ImageColor GetPiexl(int16_t x, int16_t y)
        {
            ImageColor ret = Image_ColorRode;

            if ((tImage[y * IMAGE_WIDTH / 8 + x / 8] & (0x80 >> (x % 8))) == 0)
            {
                ret = Image_ColorRode;
            }
            else
            {
                ret = Image_ColorSide;
            }

            return(ret);
        }
예제 #19
0
 public override ImageColor GetColor(double value)
 {
     if (_color != null)
     {
         return(_color);
     }
     if (_Colors != null && _Colors.Length > 0)
     {
         _color = new ImageColor(_Colors[0]);
     }
     else
     {
         _color = new ImageColor();
     }
     return(_color);
 }
예제 #20
0
            public override async Task <Picture[]> GetImages(Word word, ImageColor color)
            {
                try
                {
                    string parametersString = color != ImageColor.None ? "+filterui:color2-FGcls_" + ColorsStrings[color] : string.Empty;
                    var    response         = await _client.GetStringAsync(new Uri(string.Format("http://www.bing.com/images/search?filt=all&q={0}&qft=+filterui:imagesize-medium{1}", word, parametersString)));

                    return(_regex.Matches(response)
                           .Cast <Match>()
                           .Select(x => new Picture(word, x.Groups[1].ToString(), x.Groups[2].ToString()))
                           .ToArray());
                }
                catch
                {
                    return(new Picture[0]);
                }
            }
예제 #21
0
            public override async Task <Picture[]> GetImages(Word word, ImageColor color)
            {
                try
                {
                    string colorString = color != ImageColor.None ? "&icolor=" + ColorsStrings[color] : "";
                    var    response    = await _client.GetStringAsync(new Uri(string.Format("http://images.yandex.ru/yandsearch?text={0}&isize=small{1}", word, colorString)));

                    return(_regex.Matches(response)
                           .Cast <Match>()
                           .Select(x => new Picture(word, x.Groups[2].ToString(), x.Groups[1].ToString()))
                           .ToArray());
                }
                catch
                {
                    return(new Picture[0]);
                }
            }
예제 #22
0
        private static async Task <Picture[]> GetImages(Word word, ImageColor color)
        {
            var result = await ImageProvider.GetRandomProvider().GetImages(word, color);

            if (!result.Any())
            {
                if (!(await ImageProvider.HasConnection(word)))
                {
                    throw new Exception("Images for this word not found: " + word);
                }
                do
                {
                    result = await ImageProvider.GetRandomProvider().GetImages(word, color);
                } while (!result.Any());
                return(result);
            }
            return(result);
        }
예제 #23
0
        //public Image img = null;
        //public ImageColor rgb = null;
        //public ImageSize size = null;
        public TextLabel(string text)
        {
            ImageColor rgb = new ImageColor(255,255,255,255);
            ImageSize size = new ImageSize(200,100);
            Image img = new Image(ImageMode.Rgba, size,
                        rgb);
            img.DrawText (text,
                          new ImageColor(255,255,255,255),
                          new Font(FontAlias.System,120,FontStyle.Regular),
                          new ImagePosition(300,200));
            texture2d = new Texture2D(size.Width, size.Height, false, PixelFormat.Rgba);

            texture2d.SetPixels(0,img.ToBuffer());

            img.Dispose();

            Sce.PlayStation.HighLevel.GameEngine2D.Base.TextureInfo ti = new Sce.PlayStation.HighLevel.GameEngine2D.Base.TextureInfo(texture2d);

            this.TextureInfo = ti;
        }
예제 #24
0
        /// <summary>
        /// Nhập đối tượng tài liệu PowerPoint
        /// </summary>
        /// <param name="_page"></param>
        /// <param name="_slide"></param>
        public void ObjectsInSlides(NormalPage _page, pp.Slide _slide, int count)
        {
            HelperClass helperClass = new HelperClass();

            //----Hiệu ứng trang
            helperClass.GetTransition(_slide, _page);
            //---Chọn kiểu hiệu ứng trang và hướng chiếu

            //-- Thiết lập hình nền màu nền => quy ra ảnh nền object để lấy cả chủ đề, dải màu//loop: Tránh vòng lặp vô hạn
            int loop = 0;

            while (_slide.Shapes.Count > 0)
            {
                if (loop > 200)
                {
                    loop = 0;
                    goto BreakLoop;
                }
                else
                {
                    _slide.Shapes[1].Delete();
                    loop++;
                }
            }
BreakLoop:
            try
            {
                string PathBackground = Path.Combine((System.Windows.Application.Current as IAppGlobal).DocumentTempFolder, "Slide_" + DateTime.Now.Ticks.ToString() + ".png");
                _slide.Export(PathBackground, "png");
                if (File.Exists(PathBackground))
                {
                    ImageColor imgColor = new ImageColor();
                    imgColor.Source = new Image();
                    imgColor.Source.OpenFile(PathBackground, false);
                    _page.MainLayer.Background = imgColor;
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #25
0
            public override async Task <Picture[]> GetImages(Word word, ImageColor color)
            {
                try
                {
                    string colorString = color != ImageColor.None ? ",ic:specific,isc:" + ColorsStrings[color] : "";
                    var    uri         = new Uri(string.Format("https://www.google.ru/search?q={0}&safe=active&tbs=isz:m,sur:f{1}&tbm=isch",
                                                               word, colorString));
                    var response = await _client.GetStringAsync(uri);

                    var result = _regex.Matches(response)
                                 .Cast <Match>()
                                 .Where(x => int.Parse(x.Groups[2].ToString()) <= 900)
                                 .Select(x => new Picture(word, x.Groups[1].ToString(), x.Groups[3].ToString()))
                                 .ToArray();
                    return(result);
                }
                catch
                {
                    return(new Picture[0]);
                }
            }
예제 #26
0
        public bool InitValue()
        {
            var color = ImageColor.Parse(_colorLine);

            for (int y = 0; y < _sudoku._rows; y++)
            {
                for (int x = 0; x < _sudoku._cols; x++)
                {
                    if (_sudoku._values[y, x] == 0)
                    {
                        continue;
                    }
                    _img.DrawText(_x0 + x * size + size / 2 + 3, _y0 + y * size + size / 2 + 3, color, _sudoku._values[y, x].ToString(), null, 48, true, false, Alignment.Center, Alignment.Center);
                }
            }

            //标题
            //var font = _img.defaultFont(13.8f, "", System.DrawingCore.FontStyle.Regular);
            _img.DrawText(_y0, _y0 + size / 3 + _h + 6, color, string.Format("Lv {0}.     Spaces: {1}", _sudoku.Level.ToString(), _sudoku._spaces.ToString()), null, 13.6f, true, false, Alignment.Near, Alignment.Center);
            return(true);
        }
예제 #27
0
        public bool InitGrid(bool bHead = true)
        {
            _w  = size * 9;
            _h  = _w;
            _x0 = (_img.Image.Width - _w) / 2;
            _y0 = (_img.Image.Height - _h) / 2;
            float thickness = 1;

            //格网
            var color = ImageColor.Parse(_colorLine);

            for (int i = 0; i <= _sudoku._rows; i++)
            {
                thickness = i % 3 == 0 ? 4 : 0.4f;
                _img.DrawPolygon(_x0, _y0 + i * size, color, thickness, _w, 1);
            }
            for (int i = 0; i <= _sudoku._cols; i++)
            {
                thickness = i % 3 == 0 ? 4 : 0.4f;
                _img.DrawPolygon(_x0 + i * size, _y0, color, thickness, 1, _h);
            }

            //行列注解
            List <string> lstHead = new List <string>()
            {
                "A", "B", "C", "D", "E", "F", "G", "H", "I"
            };

            if (bHead)
            {
                for (int i = 0; i < _sudoku._rows; i++)
                {
                    _img.DrawText(_x0 - size / 2, _y0 + i * size + size / 2, color, (i + 1).ToString(), null, 12, true, false, Alignment.Center, Alignment.Center);
                    _img.DrawText(_x0 + size / 2 + _w, _y0 + i * size + size / 2, color, (i + 1).ToString(), null, 12, true, false, Alignment.Center, Alignment.Center);
                    _img.DrawText(_x0 + i * size + size / 2, _y0 - size / 3, color, lstHead[i], null, 11.6f, true, false, Alignment.Center, Alignment.Center);
                    _img.DrawText(_x0 + i * size + size / 2, _y0 + size / 3 + _h + 6, color, lstHead[i], null, 11.6f, true, false, Alignment.Center, Alignment.Center);
                }
            }
            return(true);
        }
예제 #28
0
    public void Prepare(AvatarModel heroModel, Card card, WhereAmI whereAmI)
    {
        HeroModel = heroModel;
        Card      = card;

        CardImage.SetActive(Card != null);
        ImageColor.SetActive(Card != null);
        ImageOval.SetActive(Card != null);
        PanelCrystal.SetActive(Card != null);
        PanelAttack.SetActive(Card != null);
        PanelHealth.SetActive(Card != null);
        ImageTaunt.SetActive(false);
        ImageSticky.SetActive(false);
        //minion has green background
        ImageColor.GetComponent <Image>().color = (card != null && card.CardPersistency.IsCharacter()) ? Color.blue : Color.red;
        //minion has oval
        //ImageOval.SetActive(card!=null && Card.CardPersistency.IsCharacter());

        CardImage.GetComponent <Image>().sprite = card != null?card.Animation:null;

        ImageBorder.SetActive(whereAmI == global::WhereAmI.Hand || whereAmI == global::WhereAmI.SpecialPower || whereAmI == global::WhereAmI.Board);
    }
예제 #29
0
        public static BitmapImage GetResourcesImage(string name, ColorScheme cs)
        {
            if (!name.EndsWith(".png"))
            {
                name += ".png";
            }

            ImageColor _theme = ImageColor.Color;

            if (cs.IsHighContrast)
            {
                if (cs.BackgroundColor == Colors.Black)
                {
                    _theme = ImageColor.White;
                }
                else
                {
                    _theme = ImageColor.Black;
                }
            }
            else
            {
                if (cs.BackgroundColor == Colors.Black)
                {
                    _theme = ImageColor.White;
                }
                else if (cs.BackgroundColor == Colors.White)
                {
                    _theme = ImageColor.Black;
                }
                else
                {
                    _theme = ImageColor.Color;
                }
            }

            return(new BitmapImage(new Uri("pack://application:,,,/Images/" + _theme.ToString("g") + "/" + name, UriKind.RelativeOrAbsolute)));
        }
예제 #30
0
        public virtual ImageObj Create_Scale(float length = 10000, string unit = "km")
        {
            string   pathScale = Directory.GetCurrentDirectory() + "/ModelData/Image/GIS/Scale.png";
            ImageObj imgScale  = new ImageObj(100, 100);

            //计算图例区间
            double W          = _Metadata.MaxX - _Metadata.MinX;
            double ratioScale = W * 111000 / _Image.Width;
            int    nPixels    = (int)(length / ratioScale);

            var font = imgScale.defaultFont(11, "");
            var sizeText = imgScale.Graphic.MeasureString(unit, font);
            int nOffset_x = 10, nOffset_y = 8;
            int nW = nPixels + nOffset_x * 3 + (int)sizeText.Width;
            int nH = nOffset_y * 3 + (int)sizeText.Height;

            imgScale.Create(pathScale, nPixels, nOffset_y);

            //绘制
            ImageColor pColor = new ImageColor("#192734");
            ImageObj   img    = new ImageObj(nW, nH);

            img.DrawImage(nOffset_x, nOffset_y + (int)sizeText.Height, imgScale, 1);

            int hUnit = nOffset_y + (int)(sizeText.Height - imgScale.Height / 2 - 1);

            img.DrawText(nOffset_x * 2 + nPixels, hUnit, pColor.Color, unit, font, 0, true, false, Alignment.Near, Alignment.Near);

            int hDis = (int)(sizeText.Height / 2 - 1);

            img.DrawText(nOffset_x, hDis, pColor.Color, "0", font, 0, true, false, Alignment.Center, Alignment.Near);
            img.DrawText(nOffset_x + nPixels / 2 / 2, hDis, pColor.Color, (length / 1000 / 2 / 2).ToString(), font, 0, true, false, Alignment.Center, Alignment.Near);
            img.DrawText(nOffset_x + nPixels / 2, hDis, pColor.Color, (length / 1000 / 2).ToString(), font, 0, true, false, Alignment.Center, Alignment.Near);
            img.DrawText(nOffset_x + nPixels, hDis, pColor.Color, (length / 1000).ToString(), font, 0, true, false, Alignment.Center, Alignment.Near);
            return(img);
        }
예제 #31
0
        public static FormatConvertedBitmap ConvertBitmapImage(BitmapImage IconImage, ImageColor imageColor = ImageColor.None)
        {
            FormatConvertedBitmap ConvertBitmapSource = new FormatConvertedBitmap();

            try
            {
                ConvertBitmapSource.BeginInit();
                ConvertBitmapSource.Source = IconImage;

                switch (imageColor)
                {
                case ImageColor.Gray:
                    ConvertBitmapSource.DestinationFormat = PixelFormats.Gray32Float;
                    break;

                case ImageColor.Black:
                    ConvertBitmapSource.Source = IconImage;
                    break;
                }

                ConvertBitmapSource.EndInit();
            }
            catch (Exception ex)
            {
                Common.LogError(ex, "PluginCommon", $"Error on ConvertBitmapImage()");
            }

            return(ConvertBitmapSource);
        }
예제 #32
0
        public async Task <AnalyzeImageModel> GetImageAnalysisCustomModel(string imageUrl)
        {
            var analyzeImageModel = new AnalyzeImageModel();
            // Creating a list that defines the features to be extracted from the image.

            List <VisualFeatureTypes?> features = new List <VisualFeatureTypes?>()
            {
                VisualFeatureTypes.Categories, VisualFeatureTypes.Description,
                VisualFeatureTypes.Faces, VisualFeatureTypes.ImageType,
                VisualFeatureTypes.Tags, VisualFeatureTypes.Adult,
                VisualFeatureTypes.Color, VisualFeatureTypes.Brands,
                VisualFeatureTypes.Objects
            };
            ImageAnalysis results = await _computerVisionClient.AnalyzeImageAsync(imageUrl, features);

            // </snippet_analyze_call>

            // <snippet_describe>
            // Sunmarizes the image content.
            foreach (var caption in results.Description.Captions)
            {
                var item = new Summary()
                {
                    Name       = caption.Text,
                    Confidence = caption.Confidence
                };
                analyzeImageModel.Summary.Add(item);
            }
            // </snippet_describe>

            // <snippet_categorize>
            // Display categories the image is divided into.
            foreach (var category in results.Categories)
            {
                var item = new Category()
                {
                    Name       = category.Name,
                    Confidence = category.Score
                };
                analyzeImageModel.Categories.Add(item);
            }
            // </snippet_categorize>

            // <snippet_tags>
            // Image tags and their confidence score
            foreach (var tag in results.Tags)
            {
                var item = new Tag()
                {
                    Name       = tag.Name,
                    Confidence = tag.Confidence
                };
                analyzeImageModel.Tags.Add(item);
            }
            // </snippet_tags>

            // <snippet_objects>
            // Objects
            foreach (var obj in results.Objects)
            {
                var item = new ImageObject()
                {
                    Name       = obj.ObjectProperty,
                    Confidence = obj.Confidence,
                    LocationX1 = obj.Rectangle.X,
                    LocationX2 = obj.Rectangle.X + obj.Rectangle.W,
                    LocationY1 = obj.Rectangle.Y,
                    LocationY2 = obj.Rectangle.Y + obj.Rectangle.H
                };
                analyzeImageModel.Objects.Add(item);
            }
            // </snippet_objects>

            // <snippet_faces>
            // Faces
            foreach (var face in results.Faces)
            {
                var item = new Face()
                {
                    Gender     = face.Gender.HasValue ? face.Gender.Value.ToString() : string.Empty,
                    Age        = face.Age,
                    LocationX1 = face.FaceRectangle.Left,
                    LocationX2 = face.FaceRectangle.Left,
                    LocationY1 = face.FaceRectangle.Top + face.FaceRectangle.Width,
                    LocationY2 = face.FaceRectangle.Top + face.FaceRectangle.Height
                };
                analyzeImageModel.Faces.Add(item);
            }
            // </snippet_faces>

            // <snippet_adult>
            // Adult or racy content, if any.
            Console.WriteLine("Adult:");
            if (results.Adult != null)
            {
                var adult = new Adult()
                {
                    IsAdultContent = results.Adult.IsAdultContent,
                    AdultScore     = results.Adult.AdultScore,
                    IsRacyContent  = results.Adult.IsRacyContent,
                    RacyScore      = results.Adult.RacyScore
                };
                analyzeImageModel.Adult = adult;
            }
            // </snippet_adult>

            // <snippet_brands>
            // Well-known (or custom, if set) brands.
            foreach (var brand in results.Brands)
            {
                var item = new Brand()
                {
                    Name       = brand.Name,
                    Confidence = brand.Confidence,
                    LocationX1 = brand.Rectangle.X,
                    LocationX2 = brand.Rectangle.X + brand.Rectangle.W,
                    LocationY1 = brand.Rectangle.Y,
                    LocationY2 = brand.Rectangle.Y + brand.Rectangle.H
                };
                analyzeImageModel.Brands.Add(item);
            }
            // </snippet_brands>

            // <snippet_celebs>
            // Celebrities in image, if any.
            foreach (var category in results.Categories)
            {
                if (category.Detail?.Celebrities != null)
                {
                    foreach (var celeb in category.Detail.Celebrities)
                    {
                        var item = new Celebrity()
                        {
                            Name       = celeb.Name,
                            Confidence = celeb.Confidence,
                            LocationX1 = celeb.FaceRectangle.Left,
                            LocationX2 = celeb.FaceRectangle.Top,
                            LocationY1 = celeb.FaceRectangle.Height,
                            LocationY2 = celeb.FaceRectangle.Width
                        };
                        analyzeImageModel.Celebrities.Add(item);
                    }
                }
            }
            // </snippet_celebs>


            // <snippet_landmarks>
            // Popular landmarks in image, if any.
            foreach (var category in results.Categories)
            {
                if (category.Detail?.Landmarks != null)
                {
                    foreach (var landmark in category.Detail.Landmarks)
                    {
                        var item = new Landmark()
                        {
                            Name       = landmark.Name,
                            Confidence = landmark.Confidence,
                        };
                        analyzeImageModel.Landmarks.Add(item);
                    }
                }
            }
            // </snippet_landmarks>

            // <snippet_color>
            // Identifies the color scheme.
            if (results.Color != null)
            {
                var color = new ImageColor()
                {
                    IsBWImg                 = results.Color.IsBWImg,
                    AccentColor             = results.Color.AccentColor,
                    DominantColorBackground = results.Color.DominantColorBackground,
                    DominantColorForeground = results.Color.DominantColorForeground,
                    DominantColors          = string.Join(",", results.Color.DominantColors)
                };
                analyzeImageModel.Color = color;
            }
            // </snippet_color>

            // <snippet_type>
            // Detects the image types.
            if (results.ImageType != null)
            {
                var imagetype = new Model.ImageType()
                {
                    ClipArtType     = results.ImageType.ClipArtType,
                    LineDrawingType = results.ImageType.LineDrawingType
                };
                analyzeImageModel.ImageType = imagetype;
            }
            // </snippet_type>
            return(analyzeImageModel);
        }
예제 #33
0
 public RasterRenderer(IGdalReadR gdalReadR) : base(null)
 {
     _IsRaster         = true;
     _GdalReadR        = gdalReadR;
     _ImageColorNodata = new ImageColor(_ColorNodata.R, _ColorNodata.G, _ColorNodata.B, _ColorNodata.A);
 }
예제 #34
0
        /// <summary>
        /// Draws the sprite. able to touch.
        /// Touchできる画像のspriteを作成するメソッド。
        /// Touch有効フラグを引数に持つ。
        /// </summary>
        /// <param name='drawStr'>
        /// Draw string.
        /// </param>
        /// <param name='positionX'>
        /// Position x.
        /// </param>
        /// <param name='positionY'>
        /// Position y.
        /// </param>
        /// <param name='fontSize'>
        /// Font size.
        /// </param>
        /// <param name='fontColor'>
        /// Font color.
        /// </param>
        /// <param name='touchOn'>
        /// Touch on.
        /// </param>
        public void DrawSprite(String drawStr,float positionX, float positionY,
		                       int fontSize,ImageColor fontColor, bool touchOn)
        {
            this.SetSpriteForTouch(WriteString.DrawSprite(drawStr,positionX, positionY, fontSize,fontColor),
                                   positionX,
                                   positionY,
                                   true);
            this.TouchOn = touchOn;
        }
예제 #35
0
        /****************************************
         * 描画も一緒に行う(文字)
         ****************************************/
        /// <summary>
        /// Draws the sprite. able to touch. but default TouchOn is false.
        /// Touchできる画像のspriteを作成し、sceneに追加するメソッド。
        /// デフォルトではタッチは無効。
        /// </summary>
        /// <param name='drawStr'>
        /// Draw string.
        /// </param>
        /// <param name='positionX'>
        /// Position x.
        /// </param>
        /// <param name='positionY'>
        /// Position y.
        /// </param>
        /// <param name='fontSize'>
        /// Font size.
        /// </param>
        /// <param name='fontColor'>
        /// Font color.
        /// </param>
        /// <param name='scene'>
        /// Scene.
        /// </param>
        public void DrawSprite(String drawStr,float positionX, float positionY,
		                       int fontSize,ImageColor fontColor, Scene scene)
        {
            this.SetSpriteForTouch(WriteString.DrawSprite(drawStr,positionX, positionY, fontSize,fontColor,scene),
                                   positionX,
                                   positionY,
                                   true);
        }