コード例 #1
0
ファイル: ImageMode.cs プロジェクト: PlumpMath/vlcwinrt
 public ImageSettings(int width, int height, ImageMode mode, string background)
 {
     this.Width      = width;
     this.Height     = height;
     this.Mode       = mode;
     this.Background = background;
 }
コード例 #2
0
ファイル: ImageMode.cs プロジェクト: kusl/vlcwinrt
 public ImageSettings(int width, int height, ImageMode mode, string background)
 {
     this.Width = width;
     this.Height = height;
     this.Mode = mode;
     this.Background = background;
 }
コード例 #3
0
 public void grayScaleMode(GrayScaleMode scaleMode)
 {
     modifiedImage  = ImageProcessing.grayScale(image, scaleMode);
     imageMode      = ImageMode.Grayscale;
     this.scaleMode = scaleMode;
     changeBitmap(getCurrentImage());
 }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: hszeng/GeneralSolution
 private void radioButtonSequential_CheckedChanged(object sender, EventArgs e)
 {
     if (radioButtonSequential.Checked)
     {
         imageMode = ImageMode.Sequential;
     }
 }
コード例 #5
0
        private BitmapImage GetImage(ImageMode mode)
        {
            BitmapImage tmp = null;

            if (ImageMode.Image == mode)
            {
                tmp = Interlocked.Exchange(ref _ThumbnailImage, null);
            }
            else
            {
                tmp = Interlocked.Exchange(ref _LargeImage, null);
            }
            if (tmp != null)
            {
                return(tmp);
            }

            if (CacheFile == null)
            {
                var task = FetchThumbnailAsync().ConfigureAwait(false);
            }
            else
            {
                var task = LoadCachedThumbnailImageAsync(mode).ConfigureAwait(false);
            }

            return(null);
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: hszeng/GeneralSolution
 private void radioButtonPipeline_CheckedChanged(object sender, EventArgs e)
 {
     if (radioButtonPipeline.Checked)
     {
         imageMode = ImageMode.Pipelined;
     }
 }
コード例 #7
0
ファイル: MainForm.cs プロジェクト: hszeng/GeneralSolution
 private void radioButtonLoadBalanced_CheckedChanged(object sender, EventArgs e)
 {
     if (radioButtonLoadBalanced.Checked)
     {
         imageMode = ImageMode.LoadBalanced;
     }
 }
コード例 #8
0
        public ImageForm(string imagePath, Main owner)
        {
            InitializeComponent();

            this.owner = owner;
            Owner      = owner;

            imageMode = ImageMode.Default;
            scaleMode = GrayScaleMode.Null;

            filter = new ColorFilter();

            this.imagePath = imagePath;
            using (var bmpTemp = new Bitmap(imagePath))
            {
                image         = new Bitmap(bmpTemp);
                originalImage = new Bitmap(bmpTemp);
            }

            Text             = imagePath;
            pictureBox.Image = image;

            MaximumSize = new Size(owner.Width - 100, owner.Height - 150);
            setSizeAuto();
        }
コード例 #9
0
        public override void Decode(string tg, CfgData data)
        {
            switch (tg)
            {
            case "expVis": data.Decode(out _nodeEnteredVisuals); break;

            case "subVis": data.Decode(out _nodeActiveDefaultVisuals); break;

            case "disVis": data.Decode(out _nodeInactiveVisuals); break;

            case "bg_cfg": source.visualStyleConfigs[BoxButtons.classTag] = data; break;

            case "bg_cfgs": data.Decode_Dictionary(out source.visualStyleConfigs); break;

            case "URL": imageUrl = data.ToString(); break;

            case "imgScl": _imageScaling = data.ToFloat(); break;

            case "imgMd": _mode = (ImageMode)data.ToInt(); break;

            case "hidTxt": _hideLabel = data.ToBool(); break;

            case "m": MeshObjectGetOrCreate().DecodeFull(data); break;
            }
        }
コード例 #10
0
        public void SetImageMode(ImageMode mode)
        {
            var imageMode = "";

            switch (mode)
            {
            case ImageMode.Center:
                imageMode = "center";
                break;

            case ImageMode.Corner:
                imageMode = "corner";
                break;

            case ImageMode.Corners:
                imageMode = "corners";
                break;

            default:
                throw new Exception("Invalid ImageMode");
            }
            _jsRuntime.InvokeVoid(
                _p5InvokeFunction,
                "imageMode",
                imageMode
                );
        }
コード例 #11
0
ファイル: NodeIcon.cs プロジェクト: w0pr/blizztv
 public NodeIcon(string key, Bitmap image)
 {
     this._normalImage = image;
     this._normalKey = key;
     this._imageMode = ImageMode.Normal;
     this._grayscaledImage = image.GrayScale();
     this._grayscaledKey = string.Format("{0}-grayscaled", key);
 }
コード例 #12
0
        public Image(ImageMode mode, ImageSize size, ImageColor color)
        {
            int errorCode = Image.NewFromModeSizeColor(mode, ref size, ref color, out this.handle);

            if (errorCode < 0)
            {
                Error.ThrowNativeException(errorCode);
            }
        }
コード例 #13
0
        public Image(ImageMode mode, ImageSize size, byte[] buffer)
        {
            int errorCode = Image.NewFromModeSizeBuffer(mode, ref size, buffer, out this.handle);

            if (errorCode < 0)
            {
                Error.ThrowNativeException(errorCode);
            }
        }
コード例 #14
0
        /// <summary>
        /// Initialize image task type, image color filter (as image view mode), image set and
        /// other variables with defaults
        /// </summary>
        /// <param name="mod">One of provided image modifications</param>
        /// <param name="imageSet">Pointer to image set from engine</param>
        public ImageTask(ImageModification mod, ImageSet imageSet)
        {
            taskType = mod;

            ongoing  = false;
            previous = null;
            next     = null;

            iSet  = imageSet;
            iMode = iSet.imageMode;
        }
コード例 #15
0
 private void OnColorModeChanged(ImageMode imageMode)
 {
     Astra.ImageMode[] modes = AstraManager.Instance.AvailableColorModes;
     foreach (var mode in modes)
     {
         if (mode.Width == imageMode.width && mode.Height == imageMode.height)
         {
             AstraManager.Instance.ColorMode = mode;
             break;
         }
     }
 }
コード例 #16
0
        private async Task LoadCachedThumbnailImageAsync(ImageMode mode)
        {
            var file = CacheFile;

            if (file == null)
            {
                DebugUtil.Log("CacheFile is null");
                return;
            }

            try
            {
                using (var stream = await file.GetThumbnailAsync(ThumbnailMode.ListView, 90)) // 90 pix seems to be the best balance between speed and quality
                {
                    var bmp = new BitmapImage();
                    bmp.CreateOptions = BitmapCreateOptions.None;
                    await bmp.SetSourceAsync(stream);

                    if (ImageMode.Image == mode)
                    {
                        ThumbnailImage = bmp;
                    }
                    else
                    {
                        LargeImage = bmp;
                    }
                    IsBroken = false;
                    NotifyChanged(nameof(ThumbnailExists));
                    NotifyChanged(nameof(IsBroken));
                }
                return;
            }
            catch { }

            if (0 < RemainingRetryCount)
            {
                var delay = 1000 * (3 - RemainingRetryCount--);
                DebugUtil.Log(() => "Failed to load thumbnail from file. Retry " + delay + " msec later.");

                await Task.Delay(delay);

                NotifyChanged(nameof(ThumbnailImage));
                NotifyChanged(nameof(LargeImage));
            }
            else
            {
                DebugUtil.Log("Failed to load thumbnail from file. Retry count exhausted.");
                IsBroken = true;
                NotifyChanged(nameof(ThumbnailExists));
                NotifyChanged(nameof(IsBroken));
            }
        }
コード例 #17
0
ファイル: Image.cs プロジェクト: weimingtom/Sakura
 public Image(ImageMode mode, ImageSize size, ImageColor color)
 {
     //Debug.Assert(mode == ImageMode.Rgba); //FIXME:???
     //PixelFormat.
     __img = new System.Drawing.Bitmap(size.Width,
                                       size.Height,
                                       PixelFormat.Format32bppArgb);
     System.Drawing.Color _backColor = System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B);
     using (System.Drawing.Graphics drawing = System.Drawing.Graphics.FromImage(__img))
     {
         drawing.Clear(_backColor);
         drawing.Save();
     }
 }
コード例 #18
0
        /// <summary>
        /// http://forums.asp.net/t/2007059.aspx?multiple+users+access+dynamic+generated+image+in+mvc+action
        /// </summary>
        /// <param name="guid"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="imageMode"></param>
        /// <returns></returns>
        public ActionResult GetImage(
            /*deserves view model*/
            Guid? guid,
            uint width = 100,
            uint height = 200, 
            ImageMode imageMode = ImageMode.Fill)
        {
            if(guid == null)
            {
                guid = Guid.NewGuid();
            }

            var fileUrl =  ImageRepository.GetFilePath(new ImageDescriptor(guid.Value));
            return new FilePathResult(fileUrl, "html/text");//change mime type to image
        }        
コード例 #19
0
        private async Task LoadCachedThumbnailImageAsync(ImageMode mode)
        {
            var file = CacheFile;

            if (file == null)
            {
                DebugUtil.Log("CacheFile is null");
                return;
            }

            try
            {
                using (var stream = await file.GetThumbnailAsync(ThumbnailMode.ListView))
                {
                    var bmp = new BitmapImage();
                    bmp.CreateOptions = BitmapCreateOptions.None;
                    await bmp.SetSourceAsync(stream);

                    if (ImageMode.Image == mode)
                    {
                        ThumbnailImage = bmp;
                    }
                    else
                    {
                        LargeImage = bmp;
                    }
                }
                return;
            }
            catch { }

            if (0 < RemainingRetryCount)
            {
                var delay = 1000 * (3 - RemainingRetryCount--);
                DebugUtil.Log("Failed to load thumbnail from file. Retry " + delay + " msec later.");

                await Task.Delay(delay);

                NotifyChanged("ThumbnailImage");
                NotifyChanged("LargeImage");
            }
            else
            {
                DebugUtil.Log("Failed to load thumbnail from file. Retry count exhausted.");
            }
        }
コード例 #20
0
 /// <summary>
 /// Create restore point and initialize values from current image set
 /// </summary>
 /// <param name="mode">Image view mode</param>
 /// <param name="taskType">Task type</param>
 /// <param name="image">Main image</param>
 /// <param name="thumb">Thumbnail image</param>
 /// <param name="saturation">Saturation level</param>
 /// <param name="brightness">Brightness level</param>
 /// <param name="clarity">Clarity level</param>
 public RestorePoint(
     ImageMode mode,
     ImageModification taskType,
     Bitmap image,
     Bitmap thumb,
     int saturation,
     int brightness,
     int clarity
     )
 {
     this.mode       = mode;
     this.taskType   = taskType;
     this.image      = image;
     this.thumb      = thumb;
     this.saturation = saturation;
     this.brightness = brightness;
     this.clarity    = clarity;
 }
コード例 #21
0
        internal Style(Font font, Pen pen, SolidBrush brush, SolidBrush textBrush, StringFormat format,
                       RectangleMode rectMode, ImageMode imageMode, LineCap strokeMode, DBColorMode colorMode, bool fill)
        {
            Font      = new Font(font.FontFamily, font.Size);
            Pen       = new Pen(pen.Color, pen.Width);
            Brush     = new SolidBrush(brush.Color);
            TextBrush = new SolidBrush(textBrush.Color);

            Format = new StringFormat();
            Format.LineAlignment = format.LineAlignment;
            Format.Alignment     = format.Alignment;

            RectMode   = rectMode;
            ImageMode  = imageMode;
            StrokeMode = strokeMode;
            ColorMode  = colorMode;
            Fill       = fill;
        }
コード例 #22
0
        /// <summary>
        /// Initialize image set variables to its defaults
        /// </summary>
        public ImageSet()
        {
            filename = null;
            origin   = null;

            image     = null;
            imageMode = ImageMode.Full;
            rectangle = new Rectangle(0, 0, 0, 0);

            thumb          = null;
            thumbRed       = null;
            thumbGreen     = null;
            thumbBlue      = null;
            thumbRectangle = new Rectangle(0, 0, 0, 0);

            saturation = 0;
            brightness = 0;
            clarity    = 0;
        }
コード例 #23
0
 private static extern int NewFromModeSizeColor(ImageMode mode, ref ImageSize size, ref ImageColor color, out int handle);
コード例 #24
0
 private void radioButtonSequential_CheckedChanged(object sender, EventArgs e)
 {
     if (radioButtonSequential.Checked)
         imageMode = ImageMode.Sequential;
 }
コード例 #25
0
 private void radioButtonPipeline_CheckedChanged(object sender, EventArgs e)
 {
     if (radioButtonPipeline.Checked)
         imageMode = ImageMode.Pipelined;
 }
コード例 #26
0
ファイル: Utility.cs プロジェクト: no10pc/Light
        public static void MakeThumbnailImage(string originalImagePath, string thumbnailPath, int width, int height, ImageMode mode)
        {
            Image image = Image.FromFile(originalImagePath);
            int num = width;
            int num2 = height;
            int x = 0;
            int y = 0;
            int num5 = image.Width;
            int num6 = image.Height;
            switch (mode)
            {
                case ImageMode.W:
                    num2 = (image.Height * width) / image.Width;
                    break;

                case ImageMode.H:
                    num = (image.Width * height) / image.Height;
                    break;

                case ImageMode.Cut:
                    if ((((double)image.Width) / ((double)image.Height)) > (((double)num) / ((double)num2)))
                    {
                        num6 = image.Height;
                        num5 = (image.Height * num) / num2;
                        y = 0;
                        x = (image.Width - num5) / 2;
                    }
                    else
                    {
                        num5 = image.Width;
                        num6 = (image.Width * height) / num;
                        x = 0;
                        y = (image.Height - num6) / 2;
                    }
                    break;
            }
            Image image2 = new Bitmap(num, num2);
            Graphics graphics = Graphics.FromImage(image2);
            graphics.InterpolationMode = InterpolationMode.High;
            graphics.SmoothingMode = SmoothingMode.HighQuality;
            graphics.Clear(Color.Transparent);
            graphics.DrawImage(image, new Rectangle(0, 0, num, num2), new Rectangle(x, y, num5, num6), GraphicsUnit.Pixel);
            try
            {
                try
                {
                    CreateFolder(GetRemoveFile(thumbnailPath));
                    image2.Save(thumbnailPath, ImageFormat.Jpeg);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
                image.Dispose();
                image2.Dispose();
                graphics.Dispose();
            }
        }
コード例 #27
0
    private void InitializeStreams()
    {
        try
        {
            AstraUnityContext.Instance.WaitForUpdate(AstraBackgroundUpdater.WaitIndefinitely);

            _streamSet = Astra.StreamSet.Open();

            _readerDepth         = _streamSet.CreateReader();
            _readerColor         = _streamSet.CreateReader();
            _readerBody          = _streamSet.CreateReader();
            _readerMaskedColor   = _streamSet.CreateReader();
            _readerColorizedBody = _streamSet.CreateReader();
            _readerPoint         = _streamSet.CreateReader();

            _depthStream = _readerDepth.GetStream <DepthStream>();

            var       depthModes        = _depthStream.AvailableModes;
            ImageMode selectedDepthMode = depthModes[0];

    #if ASTRA_UNITY_ANDROID_NATIVE
            int targetDepthWidth  = 160;
            int targetDepthHeight = 120;
            int targetDepthFps    = 30;
    #else
            int targetDepthWidth  = 320;
            int targetDepthHeight = 240;
            int targetDepthFps    = 30;
    #endif

            foreach (var m in depthModes)
            {
                if (m.Width == targetDepthWidth &&
                    m.Height == targetDepthHeight &&
                    m.FramesPerSecond == targetDepthFps)
                {
                    selectedDepthMode = m;
                    break;
                }
            }

            _depthStream.SetMode(selectedDepthMode);

            _colorStream = _readerColor.GetStream <ColorStream>();

            var       colorModes        = _colorStream.AvailableModes;
            ImageMode selectedColorMode = colorModes[0];

    #if ASTRA_UNITY_ANDROID_NATIVE
            int targetColorWidth  = 320;
            int targetColorHeight = 240;
            int targetColorFps    = 30;
    #else
            int targetColorWidth  = 640;
            int targetColorHeight = 480;
            int targetColorFps    = 30;
    #endif

            foreach (var m in colorModes)
            {
                if (m.Width == targetColorWidth &&
                    m.Height == targetColorHeight &&
                    m.FramesPerSecond == targetColorFps)
                {
                    selectedColorMode = m;
                    break;
                }
            }

            _colorStream.SetMode(selectedColorMode);

            _bodyStream = _readerBody.GetStream <BodyStream>();

            _maskedColorStream = _readerMaskedColor.GetStream <MaskedColorStream>();

            _colorizedBodyStream = _readerColorizedBody.GetStream <ColorizedBodyStream>();

            _pointStream = _readerPoint.GetStream <PointStream>();

            _areStreamsInitialized = true;
        }
        catch (AstraException e)
        {
            Debug.Log("AstraController: Couldn't initialize streams: " + e.ToString());
            UninitializeStreams();
        }
    }
コード例 #28
0
 private void radioButtonLoadBalanced_CheckedChanged(object sender, EventArgs e)
 {
     if (radioButtonLoadBalanced.Checked)
         imageMode = ImageMode.LoadBalanced;
 }
コード例 #29
0
ファイル: Manager.cs プロジェクト: rwoodley/FaceToys
 public enum ImageMode { Undefined = 0, Plain = 1, Grayscale, ColorMap, Histogram } // careful! this has to match some code in Trainer.cpp. and sync with db: ImageModes table
 public System.Drawing.Image GetImage(String path, int rows, int cols, ImageMode mode)
 {
     if (!File.Exists(path)) return new System.Drawing.Bitmap(100, 100);
     if (mode == ImageMode.Plain)
         return Image.FromFile(path);
     else 
         return GrayscaleImage(path, rows, cols, mode);
 }
コード例 #30
0
ファイル: Manager.cs プロジェクト: rwoodley/FaceToys
 public static String GrayscaleImagePath(String path, int rows, int cols, ImageMode mode)
 {
     String grayscaleImagePath = GetTempImagePath();
     CAPI.DumpGrayscalePicture(path, grayscaleImagePath, rows, cols, (int)mode);
     return grayscaleImagePath;
 }
コード例 #31
0
    public void InitializeStreams()
    {
        try
        {
            AstraUnityContext.Instance.WaitForUpdate(AstraBackgroundUpdater.WaitIndefinitely);

            _streamSet = Astra.StreamSet.Open();

            _readerDepth         = _streamSet.CreateReader();
            _readerColor         = _streamSet.CreateReader();
            _readerNV21Color     = _streamSet.CreateReader();
            _readerBody          = _streamSet.CreateReader();
            _readerMaskedColor   = _streamSet.CreateReader();
            _readerColorizedBody = _streamSet.CreateReader();

            _depthStream = _readerDepth.GetStream <DepthStream>();

            var       depthModes        = _depthStream.AvailableModes;
            ImageMode selectedDepthMode = depthModes[0];

            int targetDepthWidth, targetDepthHeight, targetDepthFps;
#if ASTRA_UNITY_ANDROID_NATIVE
            //Deeyea and Dabai doesn't support qqvga and qvga resolution.
            //use 640*400.
            if (_depthStream.usbInfo.Pid == 0x60b ||
                _depthStream.usbInfo.Pid == 0x60e ||
                _depthStream.usbInfo.Pid == 0x608 ||
                _depthStream.usbInfo.Pid == 0x617)
            {
                targetDepthWidth  = 640;
                targetDepthHeight = 400;
                targetDepthFps    = 30;
            }
            else
            {
                targetDepthWidth  = 160;
                targetDepthHeight = 120;
                targetDepthFps    = 30;
            }
#else
            if (_depthStream.usbInfo.Pid == 0x60b ||
                _depthStream.usbInfo.Pid == 0x60e ||
                _depthStream.usbInfo.Pid == 0x608 ||
                _depthStream.usbInfo.Pid == 0x617)
            {
                targetDepthWidth  = 640;
                targetDepthHeight = 400;
                targetDepthFps    = 30;
            }
            else
            {
                targetDepthWidth  = 320;
                targetDepthHeight = 240;
                targetDepthFps    = 30;
            }
    #endif

            foreach (var m in depthModes)
            {
                if (m.Width == targetDepthWidth &&
                    m.Height == targetDepthHeight &&
                    m.FramesPerSecond == targetDepthFps)
                {
                    selectedDepthMode = m;
                    break;
                }
            }

            _depthStream.SetMode(selectedDepthMode);

            _colorStream = _readerColor.GetStream <ColorStream>();

            var       colorModes        = _colorStream.AvailableModes;
            ImageMode selectedColorMode = colorModes[0];

            if (_depthStream.usbInfo.Pid == 0x60b ||
                _depthStream.usbInfo.Pid == 0x617)
            {
                //for deeyea, set mirror to false to match depth.
                _colorStream.IsMirroring = false;
            }
#if ASTRA_UNITY_ANDROID_NATIVE
            int targetColorWidth, targetColorHeight, targetColorFps;
            if (_depthStream.usbInfo.Pid == 0x608 ||
                _depthStream.usbInfo.Pid == 0x60f ||
                _depthStream.usbInfo.Pid == 0x617)
            {
                targetColorWidth  = 640;
                targetColorHeight = 480;
                targetColorFps    = 30;
            }
            else
            {
                targetColorWidth  = 320;
                targetColorHeight = 240;
                targetColorFps    = 30;
            }
#else
            int targetColorWidth  = 640;
            int targetColorHeight = 480;
            int targetColorFps    = 30;
#endif

            foreach (var m in colorModes)
            {
                if (m.Width == targetColorWidth &&
                    m.Height == targetColorHeight &&
                    m.FramesPerSecond == targetColorFps)
                {
                    selectedColorMode = m;
                    break;
                }
            }

            _colorStream.SetMode(selectedColorMode);

#if ASTRA_UNITY_ANDROID_NATIVE
            _nv21ColorStream = _readerNV21Color.GetStream <ColorStream>(Astra.Core.StreamSubType.COLOR_NV21_SUBTYPE);
            if (_nv21ColorStream.IsAvailable)
            {
                //COLOR_NV21_SUBTYPE is only available when using astra pro and astra pro plus.
                colorModes        = _nv21ColorStream.AvailableModes;
                selectedColorMode = colorModes[0];

                foreach (var m in colorModes)
                {
                    if (m.Width == targetColorWidth &&
                        m.Height == targetColorHeight &&
                        m.FramesPerSecond == targetColorFps)
                    {
                        selectedColorMode = m;
                        break;
                    }
                }

                _nv21ColorStream.SetMode(selectedColorMode);
                if (_depthStream.usbInfo.Pid == 0x60b ||
                    _depthStream.usbInfo.Pid == 0x617)
                {
                    //for deeyea, set mirror to false to match depth.
                    _nv21ColorStream.IsMirroring = false;
                }
            }
            else
            {
                _readerNV21Color.Dispose();
                _readerNV21Color = null;
                _nv21ColorStream = null;
            }
#endif

            _bodyStream = _readerBody.GetStream <BodyStream>();

            _maskedColorStream = _readerMaskedColor.GetStream <MaskedColorStream>();

            _colorizedBodyStream = _readerColorizedBody.GetStream <ColorizedBodyStream>();

            _areStreamsInitialized = true;
        }
        catch (AstraException e)
        {
            Debug.Log("AstraController: Couldn't initialize streams: " + e.ToString());
            UninitializeStreams();
        }
    }
コード例 #32
0
 public void SetImageMode(ImageMode mode) => _jsRuntime.InvokeVoid(
     _p5InvokeFunction,
     "imageMode",
     ImageModeToString(mode)
     );
コード例 #33
0
 public static string ImageModeToString(ImageMode mode) => mode switch
 {
コード例 #34
0
ファイル: Manager.cs プロジェクト: rwoodley/FaceToys
 public db.TrainingRunInfo CreateTrainingRun
     (String name, int numDimensions, double threshold, String trainingSet, String detectionSetting, int rows, int cols, ImageMode mode, Model model)
 {
     _dimensions = numDimensions;
     int numFaces = _dbm.CreateTrainingRun
         (name, _trainingDropZone, numDimensions, threshold, trainingSet, detectionSetting, rows, cols, mode, model);
     return LoadTrainingRun(name);
 }
コード例 #35
0
 private static extern int NewFromModeSizeBuffer(ImageMode mode, ref ImageSize size, byte[] buffer, out int handle);
コード例 #36
0
ファイル: Manager.cs プロジェクト: rwoodley/FaceToys
 public System.Drawing.Image GrayscaleImage(String path, int rows, int cols, ImageMode mode)
 {
     return Image.FromFile(GrayscaleImagePath(path,rows,cols,mode));
 }
コード例 #37
0
 public void SetImageMode(ImageMode mode)
 {
     ((IStyle)Style).SetImageMode(mode);
 }
コード例 #38
0
ファイル: AstraManager.cs プロジェクト: GabrielCruzT/Teste
    private void InitializeStreams()
    {
        try
        {
            AstraUnityContext.Instance.WaitForUpdate(AstraBackgroundUpdater.WaitIndefinitely);

            _streamSet = Astra.StreamSet.Open();

            _readerDepth         = _streamSet.CreateReader();
            _readerColor         = _streamSet.CreateReader();
            _readerBody          = _streamSet.CreateReader();
            _readerMaskedColor   = _streamSet.CreateReader();
            _readerColorizedBody = _streamSet.CreateReader();

            _depthStream = _readerDepth.GetStream <DepthStream>();

            _depthModes = _depthStream.AvailableModes;
            ImageMode selectedDepthMode = _depthModes[0];

#if ASTRA_UNITY_ANDROID_NATIVE
            int targetDepthWidth  = 160;
            int targetDepthHeight = 120;
            int targetDepthFps    = 30;
#else
            int targetDepthWidth  = 320;
            int targetDepthHeight = 240;
            int targetDepthFps    = 30;
#endif

            foreach (var m in _depthModes)
            {
                Debug.Log("Depth mode: " + m.Width + "x" + m.Height + "@" + m.FramesPerSecond);
                if (m.Width == targetDepthWidth &&
                    m.Height == targetDepthHeight)
                {
                    selectedDepthMode = m;
                    break;
                }
            }

            _depthStream.SetMode(selectedDepthMode);

            _colorStream = _readerColor.GetStream <ColorStream>();
            try
            {
                _colorModes = _colorStream.AvailableModes;
                ImageMode selectedColorMode = _colorModes[0];

#if ASTRA_UNITY_ANDROID_NATIVE
                int targetColorWidth  = 320;
                int targetColorHeight = 240;
                int targetColorFps    = 30;
#else
                int targetColorWidth  = 640;
                int targetColorHeight = 480;
                int targetColorFps    = 30;
#endif

                foreach (var m in _colorModes)
                {
                    Debug.Log("Color mode: " + m.Width + "x" + m.Height + "@" + m.FramesPerSecond);
                    if (m.Width == targetColorWidth &&
                        m.Height == targetColorHeight)
                    {
                        selectedColorMode = m;
                        break;
                    }
                }

                _colorStream.SetMode(selectedColorMode);
            }
            catch (System.Exception e)
            {
                Debug.Log("Couldn't initialize color stream: " + e.ToString());
            }

            _bodyStream = _readerBody.GetStream <BodyStream>();

            _maskedColorStream = _readerMaskedColor.GetStream <MaskedColorStream>();

            _colorizedBodyStream = _readerColorizedBody.GetStream <ColorizedBodyStream>();

            _areStreamsInitialized = true;

            Debug.Log("Stream initialize success");
            OnInitializeSuccess.Invoke();
        }
        catch (System.Exception e)
        {
            Debug.Log("Couldn't initialize streams: " + e.ToString());
            UninitializeStreams();

            if (_initializeCount > 0)
            {
                _initializeCount--;
            }
            else
            {
                Debug.Log("Initialize failed");
                OnInitializeFailed.Invoke();
            }
        }
    }
コード例 #39
0
 public void SetImageMode(ImageMode mode)
 {
     ImageMode = mode;
 }
コード例 #40
0
    private void InitializeStreams()
    {
        try
        {
            _streamSet           = Astra.StreamSet.Open();
            _reader1             = _streamSet.CreateReader();
            _reader1.FrameReady += FrameReady;

            _reader2             = _streamSet.CreateReader();
            _reader2.FrameReady += FrameReady;

            _reader3             = _streamSet.CreateReader();
            _reader3.FrameReady += FrameReady;

            _reader4             = _streamSet.CreateReader();
            _reader4.FrameReady += FrameReady;

            _reader5             = _streamSet.CreateReader();
            _reader5.FrameReady += FrameReady;

            _depthStream = _reader1.GetStream <DepthStream>();

            var       depthModes        = _depthStream.AvailableModes;
            ImageMode selectedDepthMode = depthModes[0];

    #if ASTRA_UNITY_ANDROID_NATIVE
            int targetDepthWidth  = 160;
            int targetDepthHeight = 120;
            int targetDepthFps    = 30;
    #else
            int targetDepthWidth  = 320;
            int targetDepthHeight = 240;
            int targetDepthFps    = 60;
    #endif

            foreach (var m in depthModes)
            {
                if (m.Width == targetDepthWidth &&
                    m.Height == targetDepthHeight &&
                    m.FramesPerSecond == targetDepthFps)
                {
                    selectedDepthMode = m;
                    break;
                }
            }

            _depthStream.SetMode(selectedDepthMode);

            _colorStream = _reader2.GetStream <ColorStream>();

            var       colorModes        = _colorStream.AvailableModes;
            ImageMode selectedColorMode = colorModes[0];

    #if ASTRA_UNITY_ANDROID_NATIVE
            int targetColorWidth  = 320;
            int targetColorHeight = 240;
            int targetColorFps    = 30;
    #else
            int targetColorWidth  = 640;
            int targetColorHeight = 480;
            int targetColorFps    = 60;
    #endif

            foreach (var m in colorModes)
            {
                if (m.Width == targetColorWidth &&
                    m.Height == targetColorHeight &&
                    m.FramesPerSecond == targetColorFps)
                {
                    selectedColorMode = m;
                    break;
                }
            }

            _colorStream.SetMode(selectedColorMode);

            _bodyStream = _reader3.GetStream <BodyStream>();

            _maskedColorStream = _reader4.GetStream <MaskedColorStream>();

            _colorizedBodyStream = _reader5.GetStream <ColorizedBodyStream>();

            _areStreamsInitialized = true;
        }
        catch (AstraException e)
        {
            Debug.Log("AstraController: Couldn't initialize streams: " + e.ToString());
            UninitializeStreams();
        }
    }
コード例 #41
0
        private Task <Stream> ProcessImageAsync(Stream source, int width, int height, int quality, ImageMode mode, ImageFormat?format)
        {
            // this represents the EXIF orientation
            var bitmap = LoadBitmap(source, out var encodedOrigin, out var encodedFormat); // always load as 32bit (to overcome issues with indexed color)

            // if either w or h is 0, set it based on ratio of original image
            if (height == 0)
            {
                height = (int)Math.Round(bitmap.Height * (float)width / bitmap.Width);
            }

            else if (width == 0)
            {
                width = (int)Math.Round(bitmap.Width * (float)height / bitmap.Height);
            }

            // if we need to crop, crop the original before resizing
            if (mode == ImageMode.Crop)
            {
                bitmap = CropBitmap(bitmap, width, height);
            }

            if (mode == ImageMode.Scale)
            {
                bitmap = ScaleBitmap(bitmap, width);
            }

            if (mode == ImageMode.CropScale)
            {
                bitmap = CropScaleBitmap(bitmap, width, height);
            }

            // store padded height and width
            int paddedWidth  = width;
            int paddedHeight = height;

            // if we need to pad, or max, set the height or width according to ratio
            if (mode == ImageMode.Pad || mode == ImageMode.Max)
            {
                float bitmapRatio = (float)bitmap.Width / bitmap.Height;
                float resizeRatio = (float)width / height;

                if (bitmapRatio > resizeRatio) // original is more "landscape"
                {
                    height = (int)Math.Round(bitmap.Height * ((float)width / bitmap.Width));
                }
                else
                {
                    width = (int)Math.Round(bitmap.Width * ((float)height / bitmap.Height));
                }
            }

            if (mode == ImageMode.Pad)
            {
                bitmap = ScaleBitmap(bitmap, width);
                bitmap = PadBitmap(bitmap, paddedWidth, paddedHeight, format != ImageFormat.Png);
            }

            var image = SKImage.FromBitmap(bitmap);

            switch (format)
            {
            case ImageFormat.Bmp: encodedFormat = SKEncodedImageFormat.Bmp; break;

            case ImageFormat.Gif: encodedFormat = SKEncodedImageFormat.Gif; break;

            case ImageFormat.Ico: encodedFormat = SKEncodedImageFormat.Ico; break;

            case ImageFormat.Jpg: encodedFormat = SKEncodedImageFormat.Jpeg; break;

            case ImageFormat.Png: encodedFormat = SKEncodedImageFormat.Png; break;

            case ImageFormat.Wbmp: encodedFormat = SKEncodedImageFormat.Wbmp; break;

            case ImageFormat.Webp: encodedFormat = SKEncodedImageFormat.Webp; break;

            case ImageFormat.Pkm: encodedFormat = SKEncodedImageFormat.Pkm; break;

            case ImageFormat.Ktx: encodedFormat = SKEncodedImageFormat.Ktx; break;

            case ImageFormat.Astc: encodedFormat = SKEncodedImageFormat.Astc; break;

            case ImageFormat.Dng: encodedFormat = SKEncodedImageFormat.Dng; break;

            case ImageFormat.Heif: encodedFormat = SKEncodedImageFormat.Heif; break;
            }

            var imageData = image.Encode(encodedFormat, quality);

            // cleanup
            image.Dispose();
            bitmap.Dispose();
            source.Dispose();

            return(Task.FromResult(imageData.AsStream(true)));
        }