Exemplo n.º 1
0
        /// <summary>
        /// 타일 리스트 세팅
        /// </summary>
        public void SetTileList(string sResourcePath)
        {
            //  sResourcePath = @"C:\Users\wjkim\Source\Repos\Serenade\Serenade\Resource\Residential.png";
            SplitImage splitImage = new SplitImage();
            Bitmap     resource   = new Bitmap(sResourcePath);

            System.Drawing.Color[,] color = splitImage.GetBitmapPixel(resource);
            List <Bitmap> resourceSplit = splitImage.GetDivisionBitmap(color, 16, 16);

            WrapPanel wpTileGroup = new WrapPanel();

            wpTileGroup.Orientation = Orientation.Horizontal;
            wpTileGroup.Width       = color.GetLength(0);
            wpTileGroup.Height      = color.GetLength(1);

            wpTileGroup.Margin = new Thickness(5);

            for (int i = 0; i < resourceSplit.Count; i++)
            {
                //// 임시 전체 색상 적용
                //Color testColor = Color.FromRgb(0, 100, byte.Parse(20.ToString()));

                //UcTile ucTile = new UcTile();

                //ucTile.LbName = testColor.ToString();
                //ucTile.ColorTileImage = testColor;
                //ucTile.IsTileType = false;
                //wpTileList.Children.Add(ucTile);
                UcTile ucTile = new UcTile();
                ucTile.BitmapTileImage = resourceSplit[i];
                wpTileGroup.Children.Add(ucTile);
            }
            wpTileList.Children.Add(wpTileGroup);
        }
Exemplo n.º 2
0
        public ActionResult SplitImageUrl(string id, string imgUrl)
        {
            var svPath = Server.MapPath("~/Images");
            var vExten = SplitImage.SplitImageURL4X4(svPath, id, imgUrl);

            return(Json(new { success = true, exten = vExten }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        internal static IImage[] SplitChannels(IImage img, params int[] channelIndicies)
        {
            if (channelIndicies == null || channelIndicies.Length == 0)
            {
                channelIndicies = Enumerable.Range(0, img.ColorInfo.NumberOfChannels).ToArray();
            }

            Type      depthType   = img.ColorInfo.ChannelType;
            ColorInfo channelType = ColorInfo.GetInfo(typeof(Gray), depthType);

            SplitImage splitter = null;

            if (splitters.TryGetValue(depthType, out splitter) == false)
            {
                throw new Exception(string.Format("Splitting function can not split image of color depth type {0}", depthType));
            }

            ParallelProcessor <IImage, IImage[]> proc = new ParallelProcessor <IImage, IImage[]>(img.Size,
                                                                                                 () => //called once
            {
                IImage[] channels = new IImage[channelIndicies.Length];
                for (int i = 0; i < channels.Length; i++)
                {
                    channels[i] = Image.Create(channelType, img.Width, img.Height);
                }

                return(channels);
            },

                                                                                                 (IImage src, IImage[] dest, Rectangle area) => //called for every thread
            {
                IImage srcPatch    = src.GetSubRect(area);
                IImage[] destPatch = new IImage[dest.Length];

                for (int i = 0; i < dest.Length; i++)
                {
                    destPatch[i] = dest[i].GetSubRect(area);
                }

                splitter(srcPatch, destPatch, channelIndicies);
            }
                                                                                                 /*,new ParallelOptions { ForceSequential = true}*/);

            return(proc.Process(img));
        }