public Image Resize(int maxWidth, int maxHeight, ResamplingFilters technique)
        {
            double wFrac = (double)maxWidth / _input.Width;
            double hFrac = (double)maxHeight / _input.Height;
            double scale = 0;

            // Make the image as large as possible, while
            // fitting in the supplied box and
            // obeying the aspect ratio

            if (wFrac < hFrac)
            {
                scale = wFrac;
            }
            else
            {
                scale = hFrac;
            }

            if (scale >= 1.0)
            {
                throw new ResizeNotNeededException();
            }
            else
            {
                return(Resize(scale, technique));
            }
        }
예제 #2
0
 public TransformChangeCropResampling(string name, int layerIndex, TextureBitmap.CropMode previousCrop, ResamplingFilters previousSampling, TextureBitmap.CropMode newCrop, ResamplingFilters newSampling) : base(name)
 {
     this.LayerIndex       = layerIndex;
     this.PreviousCrop     = previousCrop;
     this.PreviousSampling = previousSampling;
     this.NewCrop          = newCrop;
     this.NewSampling      = newSampling;
 }
예제 #3
0
        public Image ResizeToScale(double scale, ResamplingFilters technique)
        {
            int    height       = (int)(scale * (double)_input.Height);
            int    width        = (int)(scale * (double)_input.Width);
            Filter resizeFilter = GetResizeFilter(technique);

            return(PerformResize(resizeFilter, width, height));
        }
예제 #4
0
 public SmartObjectLayer(SubPattern pattern, string name, TextureBitmap bitmap, int x, int y, int width, int height) : base(pattern, name)
 {
     Crop          = TextureBitmap.CropMode.Scale;
     Resampler     = ResamplingFilters.Box;
     Bitmap        = bitmap;
     _ObjectX      = x;
     _ObjectY      = y;
     _ObjectWidth  = width;
     _ObjectHeight = height;
 }
예제 #5
0
        public Image ResizeToScale(double scale, ResamplingFilters technique)
        {
            int height = (int)(scale * _input.Height);
            int width = (int)(scale * _input.Width);

            Filter resizeFilter;

            resizeFilter = GetResizeFilter(technique);

            return PerformResize(resizeFilter, width, height);
        }
예제 #6
0
        public Image ResizeToScale(int maxEdgeLength, ResamplingFilters technique)
        {
            double num = 0.0;

            num = ((_input.Width <= _input.Height) ? ((double)maxEdgeLength / (double)_input.Height) : ((double)maxEdgeLength / (double)_input.Width));
            if (num >= 1.0)
            {
                throw new ResizeNotNeededException();
            }
            return(ResizeToScale(num, technique));
        }
예제 #7
0
 public void UpdateColors()
 {
     if (_PreviousWidth != _ObjectWidth || _PreviousHeight != _ObjectHeight || _PreviousCrop != Crop || _PreviousResampler != Resampler)
     {
         Texture.CopyFrom(Bitmap);
         Texture.ResampleAndCrop(this.Resampler, this.Crop, _ObjectWidth, _ObjectHeight);
         UpdateTexture();
         _PreviousWidth     = _ObjectWidth;
         _PreviousHeight    = _ObjectHeight;
         _PreviousCrop      = Crop;
         _PreviousResampler = Resampler;
     }
 }
예제 #8
0
        public Image ResizeToScale(int maxWidth, int maxHeight, ResamplingFilters technique)
        {
            double num  = (double)maxWidth / (double)_input.Width;
            double num2 = (double)maxHeight / (double)_input.Height;
            double num3 = 0.0;

            num3 = ((!(num < num2)) ? num2 : num);
            if (num3 >= 1.0)
            {
                throw new ResizeNotNeededException();
            }
            return(ResizeToScale(num3, technique));
        }
예제 #9
0
        public Image ResizeToScale(int maxEdgeLength, ResamplingFilters technique)
        {
            double scale = 0;

            if (_input.Width > _input.Height)
                scale = (double)maxEdgeLength / _input.Width;
            else
                scale = (double)maxEdgeLength / _input.Height;

            if (scale >= 1.0)
                throw new ResizeNotNeededException();
            else
                return ResizeToScale(scale, technique);
        }
    public void Resample(ResamplingFilters filter, int newWidth, int newHeight)
    {
        if (Disposed)
        {
            return;
        }
        ResamplingService resamplingService = new ResamplingService();

        resamplingService.Filter = filter;
        var array  = ResamplingFilter.ConvertByteArrayToArray((byte *)this.Bytes.ToPointer(), this.Width, this.Height);
        var result = resamplingService.Resample(array, newWidth, newHeight);

        this.InternalResize(newWidth, newHeight);
        ResamplingFilter.ConvertArrayToByteArray(result, (byte *)this.Bytes.ToPointer());
    }
예제 #11
0
        public static ResamplingFilter Create(ResamplingFilters filter)
        {
            ResamplingFilter resamplingFilter = null;

              switch (filter) {
            case ResamplingFilters.Box:
              resamplingFilter = new BoxFilter();
              break;
            case ResamplingFilters.Triangle:
              resamplingFilter = new TriangleFilter();
              break;
            case ResamplingFilters.Hermite:
              resamplingFilter = new HermiteFilter();
              break;
            case ResamplingFilters.Bell:
              resamplingFilter = new BellFilter();
              break;
            case ResamplingFilters.CubicBSpline:
              resamplingFilter = new CubicBSplineFilter();
              break;
            case ResamplingFilters.Lanczos3:
              resamplingFilter = new Lanczos3Filter();
              break;
            case ResamplingFilters.Mitchell:
              resamplingFilter = new MitchellFilter();
              break;
            case ResamplingFilters.Cosine:
              resamplingFilter = new CosineFilter();
              break;
            case ResamplingFilters.CatmullRom:
              resamplingFilter = new CatmullRomFilter();
              break;
            case ResamplingFilters.Quadratic:
              resamplingFilter = new QuadraticFilter();
              break;
            case ResamplingFilters.QuadraticBSpline:
              resamplingFilter = new QuadraticBSplineFilter();
              break;
            case ResamplingFilters.CubicConvolution:
              resamplingFilter = new CubicConvolutionFilter();
              break;
            case ResamplingFilters.Lanczos8:
              resamplingFilter = new Lanczos8Filter();
              break;
              }

              return resamplingFilter;
        }
예제 #12
0
파일: ImageResizer.cs 프로젝트: JuRogn/OA
 public Image Resize(int maxEdgeLength, ResamplingFilters technique)
 {
     double scale = 0.0;
     if (this._input.Width > this._input.Height)
     {
         scale = ((double) maxEdgeLength) / ((double) this._input.Width);
     }
     else
     {
         scale = ((double) maxEdgeLength) / ((double) this._input.Height);
     }
     if (scale >= 1.0)
     {
         throw new ResizeNotNeededException();
     }
     return this.Resize(scale, technique);
 }
예제 #13
0
 private Filter GetResizeFilter(ResamplingFilters technique)
 {
     Filter resizeFilter;
     switch (technique)
     {
         case ResamplingFilters.NearestNeighbor:
             resizeFilter = new NNResize();
             break;
         case ResamplingFilters.LowpassAntiAlias:
             resizeFilter = new LowpassResize();
             break;
         default:
             throw new NotSupportedException();
     }
     resizeFilter.ProgressChanged += ResizeProgressChanged;
     return resizeFilter;
 }
예제 #14
0
파일: ImageResizer.cs 프로젝트: jjg0519/OA
        public Image Resize(int maxEdgeLength, ResamplingFilters technique)
        {
            double scale = 0.0;

            if (this._input.Width > this._input.Height)
            {
                scale = ((double)maxEdgeLength) / ((double)this._input.Width);
            }
            else
            {
                scale = ((double)maxEdgeLength) / ((double)this._input.Height);
            }
            if (scale >= 1.0)
            {
                throw new ResizeNotNeededException();
            }
            return(this.Resize(scale, technique));
        }
예제 #15
0
        public Image ResizeToScale(int maxWidth, int maxHeight, ResamplingFilters technique)
        {
            double wFrac = (double)maxWidth / _input.Width;
            double hFrac = (double)maxHeight / _input.Height;
            double scale = 0;

            // Make the image as large as possible, while 
            // fitting in the supplied box and
            // obeying the aspect ratio

            if (wFrac < hFrac) { scale = wFrac; }
            else { scale = hFrac; }

            if (scale >= 1.0)
                throw new ResizeNotNeededException();
            else
                return ResizeToScale(scale, technique);
        }
예제 #16
0
파일: ImageResizer.cs 프로젝트: JuRogn/OA
 public Image Resize(int maxWidth, int maxHeight, ResamplingFilters technique)
 {
     double num = ((double) maxWidth) / ((double) this._input.Width);
     double num2 = ((double) maxHeight) / ((double) this._input.Height);
     double scale = 0.0;
     if (num < num2)
     {
         scale = num;
     }
     else
     {
         scale = num2;
     }
     if (scale >= 1.0)
     {
         throw new ResizeNotNeededException();
     }
     return this.Resize(scale, technique);
 }
예제 #17
0
        public Image Resize(int maxEdgeLength, ResamplingFilters technique)
        {
            double scale;

            if (_input.Width > _input.Height)
            {
                scale = (double)maxEdgeLength / _input.Width;
            }
            else
            {
                scale = (double)maxEdgeLength / _input.Height;
            }

            if (scale >= 1.0)
            {
                throw new ResizeNotNeededException();
            }
            return(Resize(scale, technique));
        }
예제 #18
0
파일: ImageResizer.cs 프로젝트: jjg0519/OA
        public Image Resize(int maxWidth, int maxHeight, ResamplingFilters technique)
        {
            double num   = ((double)maxWidth) / ((double)this._input.Width);
            double num2  = ((double)maxHeight) / ((double)this._input.Height);
            double scale = 0.0;

            if (num < num2)
            {
                scale = num;
            }
            else
            {
                scale = num2;
            }
            if (scale >= 1.0)
            {
                throw new ResizeNotNeededException();
            }
            return(this.Resize(scale, technique));
        }
예제 #19
0
        private Filter GetResizeFilter(ResamplingFilters technique)
        {
            Filter resizeFilter;

            switch (technique)
            {
            case ResamplingFilters.NearestNeighbor:
                resizeFilter = new NNResize();
                break;

            case ResamplingFilters.LowpassAntiAlias:
                resizeFilter = new LowpassResize();
                break;

            default:
                throw new NotSupportedException();
            }
            resizeFilter.ProgressChanged += ResizeProgressChanged;
            return(resizeFilter);
        }
예제 #20
0
파일: ImageResizer.cs 프로젝트: JuRogn/OA
        public Image Resize(double scale, ResamplingFilters technique)
        {
            FluxJpeg.Core.Filtering.Filter filter;
            int newHeight = (int) (scale * this._input.Height);
            int newWidth = (int) (scale * this._input.Width);
            switch (technique)
            {
                case ResamplingFilters.NearestNeighbor:
                    filter = new NNResize();
                    break;

                case ResamplingFilters.LowpassAntiAlias:
                    filter = new LowpassResize();
                    break;

                default:
                    throw new NotSupportedException();
            }
            return new Image(this._input.ColorModel, filter.Apply(this._input.Raster, newWidth, newHeight));
        }
예제 #21
0
        public Image Resize(double scale, ResamplingFilters technique)
        {
            int height = (int)(scale * _input.Height);
            int width = (int)(scale * _input.Width);

            Filter resizeFilter;

            switch (technique)
            {
                case ResamplingFilters.NearestNeighbor:
                    resizeFilter = new NNResize();
                    break;
                case ResamplingFilters.LowpassAntiAlias:
                    resizeFilter = new LowpassResize();
                    break;
                default:
                    throw new NotSupportedException();
            }

            return new Image(_input.ColorModel, resizeFilter.Apply(_input.Raster, width, height));
        }
예제 #22
0
파일: ImageResizer.cs 프로젝트: jjg0519/OA
        public Image Resize(double scale, ResamplingFilters technique)
        {
            FluxJpeg.Core.Filtering.Filter filter;
            int newHeight = (int)(scale * this._input.Height);
            int newWidth  = (int)(scale * this._input.Width);

            switch (technique)
            {
            case ResamplingFilters.NearestNeighbor:
                filter = new NNResize();
                break;

            case ResamplingFilters.LowpassAntiAlias:
                filter = new LowpassResize();
                break;

            default:
                throw new NotSupportedException();
            }
            return(new Image(this._input.ColorModel, filter.Apply(this._input.Raster, newWidth, newHeight)));
        }
        public Image Resize(double scale, ResamplingFilters technique)
        {
            int height = (int)(scale * _input.Height);
            int width  = (int)(scale * _input.Width);

            Filter resizeFilter;

            switch (technique)
            {
            case ResamplingFilters.NearestNeighbor:
                resizeFilter = new NNResize();
                break;

            case ResamplingFilters.LowpassAntiAlias:
                resizeFilter = new LowpassResize();
                break;

            default:
                throw new NotSupportedException();
            }

            return(new Image(_input.ColorModel, resizeFilter.Apply(_input.Raster, width, height)));
        }
예제 #24
0
 public ResampleCommand(Bitmap srcBitmap, Size newSize, ResamplingFilters filterType)
 {
     _srcBitmap = srcBitmap;
     _newSize = newSize;
     res_filter = filterType;
 }
예제 #25
0
    public static ResamplingFilter Create(ResamplingFilters filter)
    {
        ResamplingFilter resamplingFilter = null;

        switch (filter)
        {
        case ResamplingFilters.Box:
            resamplingFilter = new BoxFilter();
            break;

        case ResamplingFilters.Triangle:
            resamplingFilter = new TriangleFilter();
            break;

        case ResamplingFilters.Hermite:
            resamplingFilter = new HermiteFilter();
            break;

        case ResamplingFilters.Bell:
            resamplingFilter = new BellFilter();
            break;

        case ResamplingFilters.CubicBSpline:
            resamplingFilter = new CubicBSplineFilter();
            break;

        case ResamplingFilters.Lanczos3:
            resamplingFilter = new Lanczos3Filter();
            break;

        case ResamplingFilters.Mitchell:
            resamplingFilter = new MitchellFilter();
            break;

        case ResamplingFilters.Cosine:
            resamplingFilter = new CosineFilter();
            break;

        case ResamplingFilters.CatmullRom:
            resamplingFilter = new CatmullRomFilter();
            break;

        case ResamplingFilters.Quadratic:
            resamplingFilter = new QuadraticFilter();
            break;

        case ResamplingFilters.QuadraticBSpline:
            resamplingFilter = new QuadraticBSplineFilter();
            break;

        case ResamplingFilters.CubicConvolution:
            resamplingFilter = new CubicConvolutionFilter();
            break;

        case ResamplingFilters.Lanczos8:
            resamplingFilter = new Lanczos8Filter();
            break;
        }

        return(resamplingFilter);
    }
    public void ResampleAndCrop(ResamplingFilters filter, CropMode mode, int newWidth, int newHeight)
    {
        if (Disposed)
        {
            return;
        }
        // fit
        int w = newWidth;
        int h = newHeight;

        if (mode == CropMode.Fit)
        {
            float factor1 = ((float)w / (float)h);
            float factor2 = ((float)Width / (float)Height);
            if (factor1 > factor2)
            {
                h = newHeight;
                w = (int)((((float)h) / ((float)Height)) * Width);
            }
            else
            {
                w = newWidth;
                h = (int)((((float)w) / ((float)Width)) * Height);
            }
        }
        else if (mode == CropMode.Cover)
        {
            float factor1 = ((float)w / (float)h);
            float factor2 = ((float)Width / (float)Height);
            if (factor1 > factor2)
            {
                w = newWidth;
                h = (int)((((float)w) / ((float)Width)) * Height);
            }
            else
            {
                h = newHeight;
                w = (int)((((float)h) / ((float)Height)) * Width);
            }
        }

        this.Resample(filter, w, h);

        Color *myPointer   = (Color *)Bytes.ToPointer();
        var    copy        = Marshal.AllocHGlobal(w * h * PixelSize);
        Color *copyPointer = (Color *)copy.ToPointer();

        Buffer.MemoryCopy(myPointer, copyPointer, w * h * PixelSize, w * h * PixelSize);

        this.InternalResize(newWidth, newHeight);
        myPointer = (Color *)Bytes.ToPointer();

        int ox = (newWidth - w) / 2;
        int oy = (newHeight - h) / 2;

        for (int y = 0; y < newHeight; y++)
        {
            for (int x = 0; x < newWidth; x++)
            {
                if (x >= ox && x < ox + w && y >= oy && y < oy + h)
                {
                    *(myPointer + x + y * newWidth) = *(copyPointer + (x - ox) + (y - oy) * w);
                }
                else
                {
                    *(myPointer + x + y * newWidth) = new Color(0, 0, 0, 0);
                }
            }
        }
    }
예제 #27
0
        public Image Resize(int width, int height, ResamplingFilters technique)
        {
            var resizeFilter = GetResizeFilter(technique);

            return(PerformResize(resizeFilter, width, height));
        }
예제 #28
0
 public Image Resize(int width, int height, ResamplingFilters technique)
 {
     var resizeFilter = GetResizeFilter(technique);
     return PerformResize(resizeFilter, width, height);
 }
예제 #29
0
    public void SwitchTool(Tool tool)
    {
        if (tool == Tool.CropNone)
        {
            if (Editor.CurrentPattern.CurrentSubPattern.SelectedLayer is SmartObjectLayer sml)
            {
                TextureBitmap.CropMode old = sml.GetCrop();
                if (old != TextureBitmap.CropMode.Scale)
                {
                    sml.ChangeCrop(TextureBitmap.CropMode.Scale);
                    sml.UpdateColors();
                    sml.UpdateTexture();
                    UpdateTransformSettings(sml);
                    Editor.CurrentPattern.CurrentSubPattern.UpdateImage();
                    Editor.CurrentPattern.CurrentSubPattern.History.AddEvent(new History.TransformChangeCropResampling("Changed crop", Editor.CurrentPattern.CurrentSubPattern.Layers.IndexOf(sml), old, sml.GetResampling(), TextureBitmap.CropMode.Scale, sml.GetResampling()));
                }
            }
            return;
        }
        if (tool == Tool.CropFit)
        {
            if (Editor.CurrentPattern.CurrentSubPattern.SelectedLayer is SmartObjectLayer sml)
            {
                TextureBitmap.CropMode old = sml.GetCrop();
                if (old != TextureBitmap.CropMode.Fit)
                {
                    sml.ChangeCrop(TextureBitmap.CropMode.Fit);
                    sml.UpdateColors();
                    sml.UpdateTexture();
                    UpdateTransformSettings(sml);
                    Editor.CurrentPattern.CurrentSubPattern.UpdateImage();
                    Editor.CurrentPattern.CurrentSubPattern.History.AddEvent(new History.TransformChangeCropResampling("Changed crop", Editor.CurrentPattern.CurrentSubPattern.Layers.IndexOf(sml), old, sml.GetResampling(), TextureBitmap.CropMode.Fit, sml.GetResampling()));
                }
            }
            return;
        }
        if (tool == Tool.CropCover)
        {
            if (Editor.CurrentPattern.CurrentSubPattern.SelectedLayer is SmartObjectLayer sml)
            {
                TextureBitmap.CropMode old = sml.GetCrop();
                if (old != TextureBitmap.CropMode.Cover)
                {
                    sml.ChangeCrop(TextureBitmap.CropMode.Cover);
                    sml.UpdateColors();
                    sml.UpdateTexture();
                    UpdateTransformSettings(sml);
                    Editor.CurrentPattern.CurrentSubPattern.UpdateImage();
                    Editor.CurrentPattern.CurrentSubPattern.History.AddEvent(new History.TransformChangeCropResampling("Changed crop", Editor.CurrentPattern.CurrentSubPattern.Layers.IndexOf(sml), old, sml.GetResampling(), TextureBitmap.CropMode.Cover, sml.GetResampling()));
                }
            }
            return;
        }
        if (tool == Tool.SamplingBox)
        {
            if (Editor.CurrentPattern.CurrentSubPattern.SelectedLayer is SmartObjectLayer sml)
            {
                ResamplingFilters old = sml.GetResampling();
                if (old != ResamplingFilters.Box)
                {
                    sml.ChangeResampling(ResamplingFilters.Box);
                    sml.UpdateColors();
                    sml.UpdateTexture();
                    UpdateTransformSettings(sml);
                    Editor.CurrentPattern.CurrentSubPattern.UpdateImage();
                    Editor.CurrentPattern.CurrentSubPattern.History.AddEvent(new History.TransformChangeCropResampling("Changed sampling", Editor.CurrentPattern.CurrentSubPattern.Layers.IndexOf(sml), sml.GetCrop(), old, sml.GetCrop(), ResamplingFilters.Box));
                }
            }
            return;
        }
        if (tool == Tool.SamplingLanczos8)
        {
            if (Editor.CurrentPattern.CurrentSubPattern.SelectedLayer is SmartObjectLayer sml)
            {
                ResamplingFilters old = sml.GetResampling();
                if (old != ResamplingFilters.Lanczos8)
                {
                    sml.ChangeResampling(ResamplingFilters.Lanczos8);
                    sml.UpdateColors();
                    sml.UpdateTexture();
                    UpdateTransformSettings(sml);
                    Editor.CurrentPattern.CurrentSubPattern.UpdateImage();
                    Editor.CurrentPattern.CurrentSubPattern.History.AddEvent(new History.TransformChangeCropResampling("Changed sampling", Editor.CurrentPattern.CurrentSubPattern.Layers.IndexOf(sml), sml.GetCrop(), old, sml.GetCrop(), ResamplingFilters.Lanczos8));
                }
            }
            return;
        }
        if (tool == Tool.SamplingMitchell)
        {
            if (Editor.CurrentPattern.CurrentSubPattern.SelectedLayer is SmartObjectLayer sml)
            {
                ResamplingFilters old = sml.GetResampling();
                if (old != ResamplingFilters.Mitchell)
                {
                    sml.ChangeResampling(ResamplingFilters.Mitchell);
                    sml.UpdateColors();
                    sml.UpdateTexture();
                    UpdateTransformSettings(sml);
                    Editor.CurrentPattern.CurrentSubPattern.UpdateImage();
                    Editor.CurrentPattern.CurrentSubPattern.History.AddEvent(new History.TransformChangeCropResampling("Changed sampling", Editor.CurrentPattern.CurrentSubPattern.Layers.IndexOf(sml), sml.GetCrop(), old, sml.GetCrop(), ResamplingFilters.Mitchell));
                }
            }
            return;
        }
        if (tool == Tool.SamplingCosine)
        {
            if (Editor.CurrentPattern.CurrentSubPattern.SelectedLayer is SmartObjectLayer sml)
            {
                ResamplingFilters old = sml.GetResampling();
                if (old != ResamplingFilters.Cosine)
                {
                    sml.ChangeResampling(ResamplingFilters.Cosine);
                    sml.UpdateColors();
                    sml.UpdateTexture();
                    UpdateTransformSettings(sml);
                    Editor.CurrentPattern.CurrentSubPattern.UpdateImage();
                    Editor.CurrentPattern.CurrentSubPattern.History.AddEvent(new History.TransformChangeCropResampling("Changed sampling", Editor.CurrentPattern.CurrentSubPattern.Layers.IndexOf(sml), sml.GetCrop(), old, sml.GetCrop(), ResamplingFilters.Cosine));
                }
            }
            return;
        }
        if (tool == Tool.SamplingCubicConvolution)
        {
            if (Editor.CurrentPattern.CurrentSubPattern.SelectedLayer is SmartObjectLayer sml)
            {
                ResamplingFilters old = sml.GetResampling();
                if (old != ResamplingFilters.CubicConvolution)
                {
                    sml.ChangeResampling(ResamplingFilters.CubicConvolution);
                    sml.UpdateColors();
                    sml.UpdateTexture();
                    UpdateTransformSettings(sml);
                    Editor.CurrentPattern.CurrentSubPattern.UpdateImage();
                    Editor.CurrentPattern.CurrentSubPattern.History.AddEvent(new History.TransformChangeCropResampling("Changed sampling", Editor.CurrentPattern.CurrentSubPattern.Layers.IndexOf(sml), sml.GetCrop(), old, sml.GetCrop(), ResamplingFilters.CubicConvolution));
                }
            }
            return;
        }

        if (CurrentTool != Tool.None)
        {
            ToolImages[CurrentTool].color = new UnityEngine.Color(212f / 255f, 135f / 255f, 155f / 255f, ActiveTools.Contains(CurrentTool) ? 1f : 0.5f);
            if ((CurrentTool == Tool.LineRect || CurrentTool == Tool.LineCircle || CurrentTool == Tool.FullRect || CurrentTool == Tool.FullCircle) &&
                (tool != Tool.LineRect && tool != Tool.LineCircle && tool != Tool.FullRect && tool != Tool.FullCircle))
            {
                ToolImages[Tool.Rect].color = new UnityEngine.Color(212f / 255f, 135f / 255f, 155f / 255f, ActiveTools.Contains(Tool.Rect) ? 1f : 0.5f);
            }
        }
        if (tool == Tool.Rect)
        {
            tool = Tool.LineRect;
            ToolImages[Tool.Rect].color       = new UnityEngine.Color(98f / 255f, 80f / 255f, 66f / 255f);
            ToolImages[Tool.LineRect].color   = new UnityEngine.Color(98f / 255f, 80f / 255f, 66f / 255f);
            ToolImages[Tool.LineCircle].color = new UnityEngine.Color(212f / 255f, 135f / 255f, 155f / 255f);
            ToolImages[Tool.FullRect].color   = new UnityEngine.Color(212f / 255f, 135f / 255f, 155f / 255f);
            ToolImages[Tool.FullCircle].color = new UnityEngine.Color(212f / 255f, 135f / 255f, 155f / 255f);
        }
        CurrentTool = tool;
        if (ToolImages.ContainsKey(CurrentTool))
        {
            ToolImages[CurrentTool].color = new UnityEngine.Color(98f / 255f, 80f / 255f, 66f / 255f);
        }

        if (CurrentTool == Tool.Brush || CurrentTool == Tool.Eraser)
        {
            if (CurrentTool == Tool.Brush)
            {
                Editor.ChangeTool(new BrushTool());
            }
            if (CurrentTool == Tool.Eraser)
            {
                Editor.ChangeTool(new EraseTool());
            }

            BrushContainer.SetParent(BrushOptions.transform);
            BrushContainer.anchoredPosition = new Vector2(0f, 0f);
            BrushContainer.localScale       = new Vector3(1f, 1f, 1f);

            BrushOptions.PopUp();
            BucketFillOptions.PopOut();
            RectOptions.PopOut();
            TransformOptions.PopOut();

            Editor.CurrentBrush.Size     = (int)BrushSize.value;
            Editor.CurrentBrush.Hardness = (int)BrushHardness.value;
            Editor.CurrentBrush.RecalculateBrush();
        }

        if (CurrentTool == Tool.ColorPicker)
        {
            Editor.ChangeTool(new ColorPickerTool());

            BrushOptions.PopOut();
            BucketFillOptions.PopOut();
            RectOptions.PopOut();
            TransformOptions.PopOut();

            Editor.CurrentBrush.Size = 1;
            Editor.CurrentBrush.RecalculateBrush();
        }

        if (CurrentTool == Tool.BucketFill)
        {
            Editor.ChangeTool(new BucketFillTool());

            BrushOptions.PopOut();
            BucketFillOptions.PopUp();
            RectOptions.PopOut();
            TransformOptions.PopOut();

            Editor.CurrentBrush.Size = 1;
            Editor.CurrentBrush.RecalculateBrush();
        }

        if (CurrentTool == Tool.LineRect || CurrentTool == Tool.LineCircle || CurrentTool == Tool.FullRect || CurrentTool == Tool.FullCircle)
        {
            Editor.ChangeTool(new RectTool());

            BrushContainer.SetParent(RectOptions.transform);
            BrushContainer.anchoredPosition = new Vector2(0f, 0f);
            BrushContainer.localScale       = new Vector3(1f, 1f, 1f);

            BrushOptions.PopOut();
            BucketFillOptions.PopOut();
            RectOptions.PopUp();
            TransformOptions.PopOut();

            if (CurrentTool == Tool.FullRect || CurrentTool == Tool.FullCircle)
            {
                Editor.CurrentBrush.Size = 1;
            }
            else
            {
                Editor.CurrentBrush.Size     = (int)BrushSize.value;
                Editor.CurrentBrush.Hardness = (int)BrushHardness.value;
            }

            Editor.CurrentBrush.RecalculateBrush();
        }

        if (CurrentTool == Tool.Line)
        {
            Editor.ChangeTool(new LineTool());

            BrushContainer.SetParent(BrushOptions.transform);
            BrushContainer.anchoredPosition = new Vector2(0f, 0f);
            BrushContainer.localScale       = new Vector3(1f, 1f, 1f);

            BrushOptions.PopUp();
            BucketFillOptions.PopOut();
            RectOptions.PopOut();
            TransformOptions.PopOut();

            Editor.CurrentBrush.Size     = (int)BrushSize.value;
            Editor.CurrentBrush.Hardness = (int)BrushHardness.value;
            Editor.CurrentBrush.RecalculateBrush();
        }

        if (CurrentTool == Tool.Transform)
        {
            Editor.ChangeTool(new TransformTool());

            BrushOptions.PopOut();
            BucketFillOptions.PopOut();
            RectOptions.PopOut();
            TransformOptions.PopUp();
        }

        if (CurrentTool == Tool.None)
        {
            Editor.ChangeTool(null);

            BrushOptions.PopOut();
            BucketFillOptions.PopOut();
            RectOptions.PopOut();
            TransformOptions.PopOut();
        }

        /*
         *
         * AddEvent(Line, new EventTrigger[] { Brush, Eraser, ColorPicker, BucketFill, Rect, Line, Shape, Quantize, Import, Select, Transform }, (evtData) => {
         *      CurrentTool = Tool.Line;
         *      BrushContainer.SetParent(BrushOptions.transform);
         *      BrushContainer.anchoredPosition = new Vector2(0f, 0f);
         * BrushContainer.localScale = new Vector3(1f, 1f, 1f);
         *
         * BrushOptions.PopUp();
         *      BucketFillOptions.PopOut();
         *      RectOptions.PopOut();
         *      RecalculateBrush();
         * }, "Line");
         *
         * AddEvent(Quantize, new EventTrigger[] { Brush, Eraser, ColorPicker, BucketFill, Rect, Line, Shape, Quantize, Import, Select, Transform }, (evtData) => {
         *      CurrentTool = Tool.Quantize;
         *      CurrentTools = QuantizeOptions;
         *      QuantizeOptions.gameObject.SetActive(true);
         *      Back.gameObject.SetActive(true);
         *
         *      ShowTools = true;
         *
         *      BrushOptions.PopOut();
         *      BucketFillOptions.PopOut();
         *      RectOptions.PopOut();
         *      ForceRebuildLayout();*/
    }
예제 #30
0
 public void ChangeResampling(ResamplingFilters filter)
 {
     Resampler = filter;
 }