示例#1
0
        static public void addSelectedVert(int x, int z, float selAmt)
        {
            int i = x * TerrainGlobals.getTerrain().getNumXVerts() + z;

            float factor = 1.0f;

            if (checkBaseWritePermission(x, z, out factor))
            {
                selAmt = Masking.combineValueWithBaseMask(factor, selAmt);
                extendCurrSelectionMask(x, z);
                mCurrSelectionMask.SetMaskWeight((int)i, selAmt);
            }
        }
示例#2
0
        private IMask AddMasks(List <IMask> inputs)
        {
            IMask mask = MaskFactory.GetNewMask();

            foreach (IMask input in inputs)
            {
                if (input is GraphBasedMask)
                {
                    ((GraphBasedMask)input).loadAndExecute();
                }

                float destVal;

                long  index;
                float value;
                input.ResetIterator();
                while (input.MoveNext(out index, out value))
                {
                    float baseValue = 1.0f;
                    if (Masking.checkBaseWritePermission(index, out baseValue) == false)
                    {
                        continue;
                    }

                    if (value == 0)
                    {
                        continue;
                    }
                    destVal = mask.GetMaskWeight(index);
                    //if (destVal == 0) continue;
                    destVal = value + destVal;
                    if (destVal > 1)
                    {
                        destVal = 1;
                    }

                    destVal = Masking.combineValueWithBaseMask(baseValue, destVal);
                    mask.SetMaskWeight(index, destVal);
                }
            }
            return(mask);
        }
示例#3
0
        public static IMask CreateMask(Image source1)
        {
            if (myCallback == null)
            {
                myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
            }

            IMask     mask   = MaskFactory.GetNewMask();
            Bitmap    source = (Bitmap)(source1.Clone());
            Rectangle r      = new Rectangle(0, 0, source.Width, source.Height);


            int formatSize = Image.GetPixelFormatSize(source.PixelFormat);

            unsafe
            {
                BitmapData sourceData = source.LockBits(r, ImageLockMode.ReadWrite, source.PixelFormat);
                if (sourceData.PixelFormat == PixelFormat.Format24bppRgb)
                {
                    PixelData24 *sourceBase = (PixelData24 *)sourceData.Scan0;
                    int          width      = source.Width;
                    int          height     = source.Height;
                    for (int x = 0; x < width; x++)
                    {
                        for (int y = 0; y < height; y++)
                        {
                            PixelData24 *pSourcePixel = sourceBase + y * width + x;
                            byte         blue         = pSourcePixel->blue;
                            //pOututPixel->alpha = (byte)(blue);
                            //pOututPixel->red = (byte)(blue);
                            //pOututPixel->blue = (byte)(blue);
                            //pOututPixel->green = (byte)(blue);
                            long  index = y * width + x;
                            float value = blue / (float)byte.MaxValue;
                            //mask.Add(index, value);
                            mask.SetMaskWeight(index, value);
                        }
                    }
                    source.UnlockBits(sourceData);
                }
                else if (sourceData.PixelFormat == PixelFormat.Format32bppRgb)
                {
                    PixelData32Rgb *sourceBase = (PixelData32Rgb *)sourceData.Scan0;
                    int             width      = source.Width;
                    int             height     = source.Height;
                    for (int x = 0; x < width; x++)
                    {
                        for (int y = 0; y < height; y++)
                        {
                            PixelData32Rgb *pSourcePixel = sourceBase + y * width + x;
                            byte            blue         = pSourcePixel->blue;
                            //pOututPixel->alpha = (byte)(blue);
                            //pOututPixel->red = (byte)(blue);
                            //pOututPixel->blue = (byte)(blue);
                            //pOututPixel->green = (byte)(blue);
                            long  index = y * width + x;
                            float value = blue / (float)byte.MaxValue;
                            //mask.Add(index, value);
                            mask.SetMaskWeight(index, value);
                        }
                    }
                    source.UnlockBits(sourceData);
                }
                else if (sourceData.PixelFormat == PixelFormat.Format32bppPArgb)
                {
                    PixelData32PArgb *sourceBase = (PixelData32PArgb *)sourceData.Scan0;
                    int width  = source.Width;
                    int height = source.Height;
                    for (int x = 0; x < width; x++)
                    {
                        for (int y = 0; y < height; y++)
                        {
                            PixelData32PArgb *pSourcePixel = sourceBase + y * width + x;
                            byte blue = pSourcePixel->blue;
                            //pOututPixel->alpha = (byte)(blue);
                            //pOututPixel->red = (byte)(blue);
                            //pOututPixel->blue = (byte)(blue);
                            //pOututPixel->green = (byte)(blue);
                            long  index = y * width + x;
                            float value = blue / (float)byte.MaxValue;
                            //mask.Add(index, value);
                            mask.SetMaskWeight(index, value);
                        }
                    }
                    source.UnlockBits(sourceData);
                }
            }
            return(mask);
        }