Ejemplo n.º 1
0
        /// <summary>
        /// Get a Preview image for the current job and preview number.
        /// </summary>
        /// <param name="job">
        /// The job.
        /// </param>
        /// <param name="preview">
        /// The preview.
        /// </param>
        /// <param name="configuraiton">
        /// The configuraiton.
        /// </param>
        /// <returns>
        /// The <see cref="BitmapImage"/>.
        /// </returns>
        public BitmapImage GetPreview(EncodeTask job, int preview, HBConfiguration configuraiton)
        {
            if (this.instance == null)
            {
                return(null);
            }

            BitmapImage bitmapImage = null;

            try
            {
                PreviewSettings settings = new PreviewSettings
                {
                    Cropping          = new Cropping(job.Cropping),
                    MaxWidth          = job.MaxWidth ?? 0,
                    MaxHeight         = job.MaxHeight ?? 0,
                    KeepDisplayAspect = job.KeepDisplayAspect,
                    TitleNumber       = job.Title,
                    Anamorphic        = job.Anamorphic,
                    Modulus           = job.Modulus,
                    Width             = job.Width ?? 0,
                    Height            = job.Height ?? 0,
                    PixelAspectX      = job.PixelAspectX,
                    PixelAspectY      = job.PixelAspectY
                };

                bitmapImage = this.instance.GetPreview(settings, preview);
            }
            catch (AccessViolationException e)
            {
                Console.WriteLine(e);
            }

            return(bitmapImage);
        }
Ejemplo n.º 2
0
        void Init()
        {
            if (m_PreviewUtility == null)
            {
                m_PreviewUtility = new PreviewRenderUtility();
                m_PreviewUtility.camera.fieldOfView        = 30.0f;
                m_PreviewUtility.camera.transform.position = new Vector3(5, 5, 0);
            }

            if (m_Settings == null)
            {
                m_Settings = new PreviewSettings();
                m_Settings.shadedPreviewMaterial    = new Material(Shader.Find("Standard"));
                m_Settings.wireMaterial             = CreateWireframeMaterial();
                m_Settings.meshMultiPreviewMaterial = CreateMeshMultiPreviewMaterial();
                m_Settings.lineMaterial             = CreateLineMaterial();
                m_Settings.activeMaterial           = m_Settings.shadedPreviewMaterial;

                m_Settings.orthoPosition = new Vector3(0.5f, 0.5f, -1);
                m_Settings.previewDir    = new Vector2(130, 0);
                m_Settings.lightDir      = new Vector2(-40, -40);
                m_Settings.zoomFactor    = 1.0f;

                m_BlendShapes = new List <string>();
                CheckAvailableAttributes();
            }

            m_CheckeredTexture = EditorGUIUtility.LoadRequired("Previews/Textures/textureChecker.png") as Texture2D;
        }
Ejemplo n.º 3
0
        void Init()
        {
            if (m_PreviewUtility == null)
            {
                m_PreviewUtility = new PreviewRenderUtility();
                m_PreviewUtility.camera.fieldOfView        = 30.0f;
                m_PreviewUtility.camera.transform.position = new Vector3(5, 5, 0);
            }

            if (m_Settings == null)
            {
                m_Settings = new PreviewSettings();
                m_Settings.shadedPreviewMaterial    = new Material(Shader.Find("Standard"));
                m_Settings.wireMaterial             = CreateWireframeMaterial();
                m_Settings.meshMultiPreviewMaterial = CreateMeshMultiPreviewMaterial();
                m_Settings.lineMaterial             = CreateLineMaterial();
                m_Settings.activeMaterial           = m_Settings.shadedPreviewMaterial;

                m_Settings.orthoPosition = new Vector3(0.5f, 0.5f, -1);
                m_Settings.previewDir    = new Vector2(-110, 0);
                m_Settings.zoomFactor    = 1.0f;

                m_Settings.availableDisplayModes = Enumerable.Repeat(true, 7).ToArray();
                m_Settings.availableUVChannels   = Enumerable.Repeat(true, 8).ToArray();

                CheckAvailableAttributes();
            }

            m_CheckeredTexture = EditorGUIUtility.LoadRequired("Previews/Textures/textureChecker.png") as Texture2D;
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Enables the SDK and sets updatemode to manual as well as the color of the background to black.
        /// </summary>
        public override void Enable()
        {
            lock (CorsairUtilities.SDKLock)
            {
                if (!CueSDK.IsInitialized)
                {
                    CueSDK.Initialize(true);
                }
            }

            CueSDK.UpdateMode = UpdateMode.Manual;
            _keyboard         = CueSDK.KeyboardSDK;
            switch (_keyboard.DeviceInfo.Model)
            {
            case "K95 RGB":
                Height          = 7;
                Width           = 25;
                Slug            = "corsair-k95-rgb";
                PreviewSettings = new PreviewSettings(new Rect(20, 26, 1066, 282), Resources.k95);
                break;

            case "K95 RGB PLATINUM":
                Height          = 9;
                Width           = 22;
                Slug            = "corsair-k95-rgb-platinum";
                PreviewSettings = new PreviewSettings(new Rect(12, 1, 1075, 346), Resources.k95_platinum);
                break;

            case "K70 RGB":
            case "K70 RGB RAPIDFIRE":
            case "K70 LUX RGB":
                Height          = 7;
                Width           = 21;
                Slug            = "corsair-k70-rgb";
                PreviewSettings = new PreviewSettings(new Rect(15, 26, 929, 282), Resources.k70);
                break;

            case "K65 RGB":
            case "CGK65 RGB":
            case "K65 LUX RGB":
            case "K65 RGB RAPIDFIRE":
                Height          = 7;
                Width           = 18;
                Slug            = "corsair-k65-rgb";
                PreviewSettings = new PreviewSettings(new Rect(15, 30, 751, 284), Resources.k65);
                break;

            case "STRAFE RGB":
                Height          = 8;
                Width           = 22;
                Slug            = "corsair-strafe-rgb";
                PreviewSettings = new PreviewSettings(new Rect(23, 12, 937, 324), Resources.strafe);
                break;
            }

            Logger.Debug("Corsair SDK reported device as: {0}", _keyboard.DeviceInfo.Model);

            _keyboard.Brush = _keyboardBrush ?? (_keyboardBrush = new ImageBrush());
        }
Ejemplo n.º 5
0
 public NoneKeyboard()
 {
     Name            = "None";
     Slug            = "none";
     CantEnableText  = "Waaaaah, this should not be happening!";
     Height          = 1;
     Width           = 1;
     PreviewSettings = new PreviewSettings(new Rect(), Resources.none);
 }
Ejemplo n.º 6
0
 public NoneKeyboard()
 {
     Name            = "None";
     Slug            = "none";
     CantEnableText  = "Waaaaah, this should not be happening!";
     Height          = 1;
     Width           = 1;
     PreviewSettings = new PreviewSettings(984, 375, new Thickness(0, 0, 0, 0), Resources.none);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Finds output geometry for the given preview settings and title.
        /// </summary>
        /// <param name="settings">
        /// The preview settings.
        /// </param>
        /// <param name="title">
        /// Information on the title to consider.
        /// </param>
        /// <returns>
        /// Geometry Information
        /// </returns>
        public static Geometry CreateGeometry(PreviewSettings settings, SourceVideoInfo title)
        {
            int settingMode = settings.KeepDisplayAspect ? 0x04 : 0;

            // Sanitize the Geometry First.
            AnamorphicGeometry anamorphicGeometry = new AnamorphicGeometry
            {
                SourceGeometry = new Geometry
                {
                    Width  = title.Resolution.Width,
                    Height = title.Resolution.Height,
                    PAR    = new PAR {
                        Num = title.ParVal.Width, Den = title.ParVal.Height
                    }
                },
                DestSettings = new DestSettings
                {
                    AnamorphicMode = (int)settings.Anamorphic,
                    Geometry       =
                    {
                        Width  = settings.Width,
                        Height = settings.Height,
                        PAR    = new PAR
                        {
                            Num = settings.Anamorphic != Anamorphic.Custom ? title.ParVal.Width : settings.PixelAspectX,
                            Den = settings.Anamorphic != Anamorphic.Custom ? title.ParVal.Height : settings.PixelAspectY,
                        }
                    },
                    Keep = settingMode,
                    Crop = new List <int> {
                        settings.Cropping.Top, settings.Cropping.Bottom, settings.Cropping.Left, settings.Cropping.Right
                    },
                    Modulus   = settings.Modulus ?? 16,
                    MaxWidth  = settings.MaxWidth,
                    MaxHeight = settings.MaxHeight,
                    ItuPAR    = false
                }
            };

            if (settings.Anamorphic == Anamorphic.Custom)
            {
                anamorphicGeometry.DestSettings.Geometry.PAR = new PAR {
                    Num = settings.PixelAspectX, Den = settings.PixelAspectY
                };
            }
            else
            {
                anamorphicGeometry.DestSettings.Geometry.PAR = new PAR {
                    Num = title.ParVal.Width, Den = title.ParVal.Height
                };
            }

            return(HandBrakeUtils.GetAnamorphicSize(anamorphicGeometry));
        }
Ejemplo n.º 8
0
        public BlackWidow()
        {
            Name           = "Razer BlackWidow Chroma";
            Slug           = "razer-blackwidow-chroma";
            CantEnableText = "Couldn't connect to your Razer BlackWidow Chroma.\n" +
                             "Please check your cables and try updating Razer Synapse.\n\n" +
                             "If needed, you can select a different keyboard in Artemis under settings.";

            Height          = Constants.MaxRows;
            Width           = Constants.MaxColumns;
            PreviewSettings = new PreviewSettings(665, 175, new Thickness(0, -15, 0, 0), Resources.blackwidow);
        }
Ejemplo n.º 9
0
 public G810()
 {
     Name           = "Logitech G810 RGB";
     Slug           = "logitech-g910"; // Shares slugs with the G910 because the layout is identical
     CantEnableText = "Couldn't connect to your Logitech G810.\n" +
                      "Please check your cables and updating the Logitech Gaming Software\n" +
                      "A minimum version of 8.81.15 is required.\n\n" +
                      "If needed, you can select a different keyboard in Artemis under settings.";
     Height          = 6;
     Width           = 21;
     PreviewSettings = new PreviewSettings(675, 185, new Thickness(0, 35, 0, 0), Resources.g810);
 }
Ejemplo n.º 10
0
        public BlackWidow()
        {
            Name = "Razer BlackWidow Chroma";
            Slug = "razer-blackwidow-chroma";
            CantEnableText = "Couldn't connect to your Razer BlackWidow Chroma.\n" +
                             "Please check your cables and try updating Razer Synapse.\n\n" +
                             "If needed, you can select a different keyboard in Artemis under settings.";

            Height = Constants.MaxRows;
            Width = Constants.MaxColumns;
            PreviewSettings = new PreviewSettings(665, 175, new Thickness(0, -15, 0, 0), Resources.blackwidow);
        }
Ejemplo n.º 11
0
 public G910()
 {
     Name           = "Logitech G910 RGB";
     Slug           = "logitech-g910";
     CantEnableText = "Couldn't connect to your Logitech G910.\n" +
                      "Please check your cables and updating the Logitech Gaming Software\n" +
                      "A minimum version of 8.81.15 is required.\n\n" +
                      "If needed, you can select a different keyboard in Artemis under settings.";
     Height          = 6;
     Width           = 21;
     PreviewSettings = new PreviewSettings(540, 154, new Thickness(25, -80, 0, 0), Resources.g910);
 }
Ejemplo n.º 12
0
 public G910()
 {
     Name           = "Logitech G910 RGB";
     Slug           = "logitech-g910";
     CantEnableText = "Couldn't connect to your Logitech G910.\n" +
                      "Please check your cables and updating the Logitech Gaming Software\n" +
                      "A minimum version of 8.81.15 is required.\n\n" +
                      "If needed, you can select a different keyboard in Artemis under settings.";
     Height           = 7;
     Width            = 22;
     PreviewSettings  = new PreviewSettings(570, 175, new Thickness(-10, -105, 0, 0), Resources.g910);
     _generalSettings = SettingsProvider.Load <GeneralSettings>();
 }
Ejemplo n.º 13
0
        public BlackWidow()
        {
            Name           = "Razer BlackWidow Chroma";
            Slug           = "razer-blackwidow-chroma";
            CantEnableText = "Couldn't connect to your Razer BlackWidow Chroma.\n" +
                             "Please check your cables and try updating Razer Synapse.\n\n" +
                             "If needed, you can select a different keyboard in Artemis under settings.";

            Height           = Constants.MaxRows;
            Width            = Constants.MaxColumns;
            PreviewSettings  = new PreviewSettings(new Rect(26, 56, 906, 234), Resources.blackwidow);
            _generalSettings = SettingsProvider.Load <GeneralSettings>();
        }
Ejemplo n.º 14
0
 public SettingsWindow(MainWindow mainWindow)
 {
     InitializeComponent();
     table = new List <TableItem>();
     table.Add(new TableItem(1, "М", Convert.ToDateTime("11.12.1995"), 7, "A09"));
     table.Add(new TableItem(1, "М", Convert.ToDateTime("11.12.1995"), 7, "A09"));
     table.Add(new TableItem(1, "М", Convert.ToDateTime("11.12.1995"), 7, "A09"));
     table.Add(new TableItem(1, "М", Convert.ToDateTime("11.12.1995"), 7, "A09"));
     previewSettings = new PreviewSettings();
     dataGrid_ExampleTable.ItemsSource = table;
     this.DataContext = this;
     baseStyle        = new Style(typeof(DataGridCell), (FindResource("customCell") as Style));
 }
Ejemplo n.º 15
0
 public G910()
 {
     Name = "Logitech G910 RGB";
     Slug = "logitech-g910";
     CantEnableText = "Couldn't connect to your Logitech G910.\n" +
                      "Please check your cables and updating the Logitech Gaming Software\n" +
                      "A minimum version of 8.81.15 is required.\n\n" +
                      "If needed, you can select a different keyboard in Artemis under settings.";
     Height = 7;
     Width = 22;
     PreviewSettings = new PreviewSettings(570, 175, new Thickness(-10, -105, 0, 0), Resources.g910);
     _generalSettings = SettingsProvider.Load<GeneralSettings>();
 }
Ejemplo n.º 16
0
        public RawPreviewData GetPreview(PreviewSettings settings, int previewNumber, bool deinterlace)
        {
            SourceTitle title = this.Titles.TitleList.FirstOrDefault(t => t.Index == settings.TitleNumber);

            // Create the Expected Output Geometry details for libhb.
            hb_geometry_settings_s uiGeometry = new hb_geometry_settings_s
            {
                crop      = new[] { settings.Cropping.Top, settings.Cropping.Bottom, settings.Cropping.Left, settings.Cropping.Right },
                itu_par   = 0,
                keep      = (int)AnamorphicFactory.KeepSetting.HB_KEEP_WIDTH + (settings.KeepDisplayAspect ? 0x04 : 0), // TODO Keep Width?
                maxWidth  = settings.MaxWidth,
                maxHeight = settings.MaxHeight,
                mode      = (int)(hb_anamorphic_mode_t)settings.Anamorphic,
                modulus   = settings.Modulus ?? 16,
                geometry  = new hb_geometry_s
                {
                    height = settings.Height,
                    width  = settings.Width,
                    par    = settings.Anamorphic != Anamorphic.Custom && settings.Anamorphic != Anamorphic.Automatic
                        ? new hb_rational_t {
                        den = title.Geometry.PAR.Den, num = title.Geometry.PAR.Num
                    }
                        : new hb_rational_t {
                        den = settings.PixelAspectY, num = settings.PixelAspectX
                    }
                }
            };

            // Fetch the image data from LibHb
            IntPtr     resultingImageStuct = hbFunctions.hb_get_preview2(this.Handle, settings.TitleNumber, previewNumber, ref uiGeometry, deinterlace ? 1 : 0);
            hb_image_s image = InteropUtilities.ToStructureFromPtr <hb_image_s>(resultingImageStuct);

            // Copy the filled image buffer to a managed array.
            int stride_width    = image.plane[0].stride;
            int stride_height   = image.plane[0].height_stride;
            int imageBufferSize = stride_width * stride_height;  // int imageBufferSize = outputWidth * outputHeight * 4;

            byte[] managedBuffer = new byte[imageBufferSize];
            Marshal.Copy(image.plane[0].data, managedBuffer, 0, imageBufferSize);

            RawPreviewData preview = new RawPreviewData(managedBuffer, stride_width, stride_height, image.width, image.height);

            // Close the image so we don't leak memory.
            IntPtr nativeJobPtrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));

            Marshal.WriteIntPtr(nativeJobPtrPtr, resultingImageStuct);
            hbFunctions.hb_image_close(nativeJobPtrPtr);
            Marshal.FreeHGlobal(nativeJobPtrPtr);

            return(preview);
        }
Ejemplo n.º 17
0
        public MasterkeysProL()
        {
            Name = "CM Masterkeys Pro L";
            Slug = "cm-masterkeys-pro-l";

            CantEnableText = "Couldn't connect to your CM Masterkeys Pro L.\n" +
                             "Please check your cables and try updating your CM software.\n\n" +
                             "If needed, you can select a different keyboard in Artemis under settings.";

            Height = 6;
            Width  = 22;

            PreviewSettings  = new PreviewSettings(670, 189, new Thickness(-2, -5, 0, 0), Resources.masterkeys_pro_l);
            _generalSettings = SettingsProvider.Load <GeneralSettings>();
        }
Ejemplo n.º 18
0
        public MasterkeysProS()
        {
            Name = "CM Masterkeys Pro S";
            Slug = "cm-masterkeys-pro-s";

            CantEnableText = "Couldn't connect to your CM Masterkeys Pro S.\n" +
                             "Please check your cables and try updating your CM software.\n\n" +
                             "If needed, you can select a different keyboard in Artemis under settings.";

            Height = 6;
            Width  = 18;

            PreviewSettings  = new PreviewSettings(new Rect(13, 12, 657, 219), Resources.masterkeys_pro_s);
            _generalSettings = SettingsProvider.Load <GeneralSettings>();
        }
Ejemplo n.º 19
0
        /// <summary>
        ///     Enables the SDK and sets updatemode to manual as well as the color of the background to black.
        /// </summary>
        public override void Enable()
        {
            if (!CueSDK.IsInitialized)
            {
                CueSDK.Initialize();
            }

            CueSDK.UpdateMode = UpdateMode.Manual;
            _keyboard         = CueSDK.KeyboardSDK;
            switch (_keyboard.DeviceInfo.Model)
            {
            case "K95 RGB":
                Height          = 7;
                Width           = 25;
                Slug            = "corsair-k95-rgb";
                PreviewSettings = new PreviewSettings(676, 190, new Thickness(0, -15, 0, 0), Resources.k95);
                break;

            case "K70 RGB":
            case "K70 RGB RAPIDFIRE":
            case "K70 LUX RGB":
                Height          = 7;
                Width           = 21;
                Slug            = "corsair-k70-rgb";
                PreviewSettings = new PreviewSettings(676, 210, new Thickness(0, -25, 0, 0), Resources.k70);
                break;

            case "K65 RGB":
            case "CGK65 RGB":
            case "K65 LUX RGB":
            case "K65 RGB RAPIDFIRE":
                Height          = 7;
                Width           = 18;
                Slug            = "corsair-k65-rgb";
                PreviewSettings = new PreviewSettings(610, 240, new Thickness(0, -30, 0, 0), Resources.k65);
                break;

            case "STRAFE RGB":
                Height          = 7;
                Width           = 22;
                Slug            = "corsair-strafe-rgb";
                PreviewSettings = new PreviewSettings(665, 215, new Thickness(0, -5, 0, 0), Resources.strafe);
                break;
            }

            Logger.Debug("Corsair SDK reported device as: {0}", _keyboard.DeviceInfo.Model);
            _keyboard.Brush = _keyboardBrush ?? (_keyboardBrush = new ImageBrush());
        }
Ejemplo n.º 20
0
        internal static void RenderMeshPreview(
            Mesh mesh,
            PreviewRenderUtility previewUtility,
            PreviewSettings settings,
            int meshSubset)
        {
            if (mesh == null || previewUtility == null)
            {
                return;
            }

            Bounds bounds = mesh.bounds;

            Transform renderCamTransform = previewUtility.camera.GetComponent <Transform>();

            previewUtility.camera.nearClipPlane = 0.0001f;
            previewUtility.camera.farClipPlane  = 1000f;

            if (settings.displayMode == DisplayMode.UVLayout)
            {
                previewUtility.camera.orthographic     = true;
                previewUtility.camera.orthographicSize = settings.zoomFactor;
                renderCamTransform.position            = settings.orthoPosition;
                renderCamTransform.rotation            = Quaternion.identity;
                DrawUVLayout(mesh, previewUtility, settings);
                return;
            }

            float halfSize = bounds.extents.magnitude;
            float distance = 4.0f * halfSize;

            previewUtility.camera.orthographic = false;
            Quaternion camRotation = Quaternion.identity;
            Vector3    camPosition = camRotation * Vector3.forward * (-distance * settings.zoomFactor) + settings.pivotPositionOffset;

            renderCamTransform.position = camPosition;
            renderCamTransform.rotation = camRotation;

            previewUtility.lights[0].intensity          = 1.1f;
            previewUtility.lights[0].transform.rotation = Quaternion.Euler(-settings.lightDir.y, -settings.lightDir.x, 0);
            previewUtility.lights[1].intensity          = 1.1f;
            previewUtility.lights[1].transform.rotation = Quaternion.Euler(settings.lightDir.y, settings.lightDir.x, 0);

            previewUtility.ambientColor = new Color(.1f, .1f, .1f, 0);

            RenderMeshPreviewSkipCameraAndLighting(mesh, bounds, previewUtility, settings, null, meshSubset);
        }
Ejemplo n.º 21
0
        static void DrawUVLayout(Mesh mesh, PreviewRenderUtility previewUtility, PreviewSettings settings)
        {
            GL.PushMatrix();

            // draw UV grid
            settings.lineMaterial.SetPass(0);

            GL.LoadProjectionMatrix(previewUtility.camera.projectionMatrix);
            GL.MultMatrix(previewUtility.camera.worldToCameraMatrix);

            GL.Begin(GL.LINES);
            const float step = 0.125f;

            for (var g = -2.0f; g <= 3.0f; g += step)
            {
                var majorLine = Mathf.Abs(g - Mathf.Round(g)) < 0.01f;
                if (majorLine)
                {
                    // major grid lines: larger area than [0..1] range, more opaque
                    GL.Color(new Color(0.6f, 0.6f, 0.7f, 1.0f));
                    GL.Vertex3(-2, g, 0);
                    GL.Vertex3(+3, g, 0);
                    GL.Vertex3(g, -2, 0);
                    GL.Vertex3(g, +3, 0);
                }
                else if (g >= 0 && g <= 1)
                {
                    // minor grid lines: only within [0..1] area, more transparent
                    GL.Color(new Color(0.6f, 0.6f, 0.7f, 0.5f));
                    GL.Vertex3(0, g, 0);
                    GL.Vertex3(1, g, 0);
                    GL.Vertex3(g, 0, 0);
                    GL.Vertex3(g, 1, 0);
                }
            }
            GL.End();

            // draw the mesh
            GL.LoadIdentity();
            settings.meshMultiPreviewMaterial.SetPass(0);
            GL.wireframe = true;
            Graphics.DrawMeshNow(mesh, previewUtility.camera.worldToCameraMatrix);
            GL.wireframe = false;

            GL.PopMatrix();
        }
Ejemplo n.º 22
0
        /// <summary>
        ///     Enables the SDK and sets updatemode to manual as well as the color of the background to black.
        /// </summary>
        public override void Enable()
        {
            if (!CueSDK.IsInitialized)
                CueSDK.Initialize(true);

            CueSDK.UpdateMode = UpdateMode.Manual;
            _keyboard = CueSDK.KeyboardSDK;
            switch (_keyboard.DeviceInfo.Model)
            {
                case "K95 RGB":
                    Height = 7;
                    Width = 25;
                    Slug = "corsair-k95-rgb";
                    PreviewSettings = new PreviewSettings(676, 190, new Thickness(0, -15, 0, 0), Resources.k95);
                    break;
                case "K70 RGB":
                case "K70 RGB RAPIDFIRE":
                case "K70 LUX RGB":
                    Height = 7;
                    Width = 21;
                    Slug = "corsair-k70-rgb";
                    PreviewSettings = new PreviewSettings(676, 210, new Thickness(0, -25, 0, 0), Resources.k70);
                    break;
                case "K65 RGB":
                case "CGK65 RGB":
                case "K65 LUX RGB":
                case "K65 RGB RAPIDFIRE":
                    Height = 7;
                    Width = 18;
                    Slug = "corsair-k65-rgb";
                    PreviewSettings = new PreviewSettings(610, 240, new Thickness(0, -30, 0, 0), Resources.k65);
                    break;
                case "STRAFE RGB":
                    Height = 7;
                    Width = 22;
                    Slug = "corsair-strafe-rgb";
                    PreviewSettings = new PreviewSettings(665, 215, new Thickness(0, -5, 0, 0), Resources.strafe);
                    break;
            }

            Logger.Debug("Corsair SDK reported device as: {0}", _keyboard.DeviceInfo.Model);
            _keyboard.Brush = _keyboardBrush ?? (_keyboardBrush = new ImageBrush());
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Get a Preview image for the current job and preview number.
        /// </summary>
        /// <param name="job">
        /// The job.
        /// </param>
        /// <param name="preview">
        /// The preview.
        /// </param>
        /// <param name="configuraiton">
        /// The configuraiton.
        /// </param>
        /// <returns>
        /// The <see cref="BitmapImage"/>.
        /// </returns>
        public BitmapImage GetPreview(EncodeTask job, int preview, HBConfiguration configuraiton)
        {
            if (this.instance == null)
            {
                return(null);
            }

            BitmapImage bitmapImage = null;

            try
            {
                PreviewSettings settings = new PreviewSettings
                {
                    Cropping          = new Cropping(job.Cropping),
                    MaxWidth          = job.MaxWidth ?? 0,
                    MaxHeight         = job.MaxHeight ?? 0,
                    KeepDisplayAspect = job.KeepDisplayAspect,
                    TitleNumber       = job.Title,
                    Anamorphic        = job.Anamorphic,
                    Modulus           = job.Modulus,
                    Width             = job.Width ?? 0,
                    Height            = job.Height ?? 0,
                    PixelAspectX      = job.PixelAspectX,
                    PixelAspectY      = job.PixelAspectY
                };

                int deinterlaceOn = 0;
                if (job.DeinterlaceFilter != DeinterlaceFilter.Off)
                {
                    deinterlaceOn = 1;
                }

                bitmapImage = BitmapUtilities.ConvertToBitmapImage(this.instance.GetPreview(settings, preview, deinterlaceOn));
            }
            catch (AccessViolationException e)
            {
                Debug.WriteLine(e);
            }

            return(bitmapImage);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Get a Preview image for the current job and preview number.
        /// </summary>
        /// <param name="job">
        /// The job.
        /// </param>
        /// <param name="preview">
        /// The preview.
        /// </param>
        /// <param name="configuraiton">
        /// The configuraiton.
        /// </param>
        /// <returns>
        /// The <see cref="BitmapImage"/>.
        /// </returns>
        public BitmapImage GetPreview(EncodeTask job, int preview, HBConfiguration configuraiton)
        {
            if (this.instance == null)
            {
                return(null);
            }

            BitmapImage bitmapImage = null;

            try
            {
                PreviewSettings settings = new PreviewSettings(job);
                bitmapImage = this.instance.GetPreview(settings, preview);
            }
            catch (AccessViolationException e)
            {
                Console.WriteLine(e);
            }

            return(bitmapImage);
        }
Ejemplo n.º 25
0
        public async Task ShouldBeAbleToGenerateAPreview(string fileName)
        {
            var settings = new PreviewSettings
            {
                RenderingFormat = ImageFormat.Png,
                UpScaleForPrint = 4
            };

            using (var fileStream = File.OpenRead(@"..\..\..\" + fileName))
            {
                var drawing = new Drawing(fileStream, new FileDetail("file", DateTime.MinValue));
                var previewGeneratorFactory = new PreviewGeneratorFactory(settings);
                var generator = previewGeneratorFactory.Create();

                var preview = await drawing.GeneratePreview(generator, new Size(100, 100), CancellationToken.None);

                Assert.That(preview.ImageData.Length, Is.GreaterThan(0));
                Assert.That(
                    () => Image.FromStream(preview.ImageData),
                    Throws.Nothing);
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        ///     Enables the SDK and sets updatemode to manual as well as the color of the background to black.
        /// </summary>
        public override void Enable()
        {
            if (!CueSDK.IsInitialized)
            {
                CueSDK.Initialize();
            }

            _keyboard = CueSDK.KeyboardSDK;
            switch (_keyboard.DeviceInfo.Model)
            {
            case "K95 RGB":
                Height          = 7;
                Width           = 25;
                PreviewSettings = new PreviewSettings(676, 190, new Thickness(0, -15, 0, 0), Resources.k95);
                break;

            case "K70 RGB":
            case "K70 RGB RAPIDFIRE":
                Height          = 7;
                Width           = 21;
                PreviewSettings = new PreviewSettings(676, 210, new Thickness(0, -25, 0, 0), Resources.k70);
                break;

            case "K65 RGB":
                Height          = 7;
                Width           = 18;
                PreviewSettings = new PreviewSettings(610, 240, new Thickness(0, -30, 0, 0), Resources.k65);
                break;

            case "STRAFE RGB":
                Height          = 7;
                Width           = 22;
                PreviewSettings = new PreviewSettings(665, 215, new Thickness(0, -5, 0, 0), Resources.strafe);
                break;
            }
            Logger.Debug("Corsair SDK reported device as: {0}", _keyboard.DeviceInfo.Model);
            Slug            = "corsair-" + _keyboard.DeviceInfo.Model.Replace(' ', '-').ToLower();
            _keyboard.Brush = _keyboardBrush ?? (_keyboardBrush = new ImageBrush());
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PreviewDocumentRequest"/> class.
 /// </summary>
 /// <param name="previewSettings">Document preview settings</param>
 public PreviewDocumentRequest(PreviewSettings previewSettings)
 {
     this.previewSettings = previewSettings;
 }
Ejemplo n.º 28
0
        //StorageFile file,
        public DiagramVM(string file, bool isValidXml)
        {
            _isValidXml    = isValidXml;
            _file          = file;
            Nodes          = new ObservableCollection <NodeVM>();
            Connectors     = new ObservableCollection <ConnectorVM>();
            Groups         = new ObservableCollection <GroupVM>();
            SelectedItems  = new SelectorVM(this);
            PortVisibility = PortVisibility.MouseOverOnConnect;
            Select         = new Command(param => IsSelected = true);
            FirstLoad      = new Command(OnViewLoaded);
            HistoryManager = new customManager();
            SnapSettings   = new SnapSettings()
            {
                SnapConstraints = SnapConstraints.All,
                SnapToObject    = SnapToObject.All
            };

            PreviewSettings = new PreviewSettings()
            {
                PreviewMode = PreviewMode.Preview
            };

            PageSettings = new PageVM();

            (PageSettings as PageVM).InitDiagram(this);

            this.HorizontalRuler = new Ruler()
            {
                Orientation = Orientation.Horizontal
            };
            this.VerticalRuler = new Ruler()
            {
                Orientation = Orientation.Vertical
            };
            //OffPageBackground = new SolidColorBrush(new Color() { A = 0xFF, R = 0xEC, G = 0xEC, B = 0xEC });
            //OffPageBackground = new SolidColorBrush(new Color() { A = 0xFF, R = 0x2D, G = 0x2D, B = 0x2D });
            InitLocation();
            PrintingService = new PrintingService();
            ExportSettings  = new ExportSettings()
            {
                ImageStretch = Stretch.Uniform,
                ExportMode   = ExportMode.PageSettings
            };
#if SyncfusionFramework4_5_1
            ExportSettings = new ExportSettings()
            {
                ImageStretch = Stretch.Uniform,
                ExportMode   = ExportMode.PageSettings
            };
            PrintingService = new PrintingService();
#endif
            FlipCommand            = new Command(OnFlipCommand);
            ExportCommand          = new Command(OnExportCommand);
            PrintCommand           = new Command(OnPrintCommand);
            Captures               = new Command(OnCapturesCommand);
            ClearDiagram           = new Command(OnClearCommand);
            Upload                 = new Command(Onuploadcommand);
            Draw                   = new Command(OnDrawCommand);
            SingleSelect           = new Command(OnSingleSelectCommand);
            SelectAll              = new Command(OnSelectAllCommand);
            Manipulate             = new Command(OnManipulateCommand);
            LoadExt                = new Command(OnLoadExt);
            AddImageNode           = new Command(OnAddImageNodeCommand);
            PageOrientationCommand = new Command(OnPageOrientationCommand);
            PageSizeCommand        = new Command(OnPageSizeCommand);
            ConnectTypeCommand     = new Command(OnConnectTypeCommand);
            RotateTextCommand      = new Command(OnRotateTextCommand);
            //SelectTextCommand = new Command(OnSelectTextCommand);
            SizeandPositionCommand = new Command(OnSizeandPositionCommand);
            PanZoomCommand         = new Command(OnPanZoomCommand);
            FitToWidthCommand      = new Command(OnFitToWidthCommand);
            FitToPageCommand       = new Command(OnFitToPageCommand);

            //Tool = Tool.ZoomPan | Tool.SingleSelect;
            ;

            //ConnectorVM c = new ConnectorVM()
            //{
            //    SourcePoint = new Point(100, 100),
            //    TargetPoint = new Point(300, 300)
            //};

            //(this.ConnectorCollection as ICollection<ConnectorVM>).Add(c);
        }
Ejemplo n.º 29
0
        public BitmapImage GetPreview(PreviewSettings settings, int previewNumber)
        {
            SourceTitle title = this.Titles.TitleList.FirstOrDefault(t => t.Index == settings.TitleNumber);

            Validate.NotNull(title, "GetPreview: Title should not have been null. This is probably a bug.");

            // Create the Expected Output Geometry details for libhb.
            hb_geometry_settings_s uiGeometry = new hb_geometry_settings_s
            {
                crop      = new[] { settings.Cropping.Top, settings.Cropping.Bottom, settings.Cropping.Left, settings.Cropping.Right },
                itu_par   = 0,
                keep      = (int)AnamorphicFactory.KeepSetting.HB_KEEP_WIDTH + (settings.KeepDisplayAspect ? 0x04 : 0), // TODO Keep Width?
                maxWidth  = settings.MaxWidth,
                maxHeight = settings.MaxHeight,
                mode      = (int)(hb_anamorphic_mode_t)settings.Anamorphic,
                modulus   = settings.Modulus ?? 16,
                geometry  = new hb_geometry_s
                {
                    height = settings.Height,
                    width  = settings.Width,
                    par    = settings.Anamorphic != Anamorphic.Custom
                        ? new hb_rational_t {
                        den = title.Geometry.PAR.Den, num = title.Geometry.PAR.Num
                    }
                        : new hb_rational_t {
                        den = settings.PixelAspectY, num = settings.PixelAspectX
                    }
                }
            };

            // Sanitize the input.
            Geometry resultGeometry = AnamorphicFactory.CreateGeometry(settings, new SourceVideoInfo(new Size(title.Geometry.Width, title.Geometry.Height), new Size(title.Geometry.PAR.Num, title.Geometry.PAR.Den)));
            int      width          = resultGeometry.Width * resultGeometry.PAR.Num / resultGeometry.PAR.Den;
            int      height         = resultGeometry.Height;

            uiGeometry.geometry.width   = width;
            uiGeometry.geometry.height  = height;
            uiGeometry.geometry.par.num = settings.PixelAspectX;
            uiGeometry.geometry.par.den = settings.PixelAspectY;

            // Fetch the image data from LibHb
            IntPtr     resultingImageStuct = HBFunctions.hb_get_preview2(this.hbHandle, settings.TitleNumber, previewNumber, ref uiGeometry, 0);
            hb_image_s image = InteropUtilities.ToStructureFromPtr <hb_image_s>(resultingImageStuct);

            // Copy the filled image buffer to a managed array.
            int stride_width    = image.plane[0].stride;
            int stride_height   = image.plane[0].height_stride;
            int imageBufferSize = stride_width * stride_height;  // int imageBufferSize = outputWidth * outputHeight * 4;

            byte[] managedBuffer = new byte[imageBufferSize];
            Marshal.Copy(image.plane[0].data, managedBuffer, 0, imageBufferSize);

            var        bitmap     = new Bitmap(width, height);
            BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb);

            IntPtr ptr = bitmapData.Scan0; // Pointer to the first pixel.

            for (int i = 0; i < image.height; i++)
            {
                try
                {
                    Marshal.Copy(managedBuffer, i * stride_width, ptr, stride_width);
                    ptr = IntPtr.Add(ptr, width * 4);
                }
                catch (Exception exc)
                {
                    Debug.WriteLine(exc); // In theory, this will allow a partial image display if this happens. TODO add better logging of this.
                }
            }

            bitmap.UnlockBits(bitmapData);

            // Close the image so we don't leak memory.
            IntPtr nativeJobPtrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));

            Marshal.WriteIntPtr(nativeJobPtrPtr, resultingImageStuct);
            HBFunctions.hb_image_close(nativeJobPtrPtr);
            Marshal.FreeHGlobal(nativeJobPtrPtr);

            // Create a Bitmap Image for display.
            using (var memoryStream = new MemoryStream())
            {
                try
                {
                    bitmap.Save(memoryStream, ImageFormat.Bmp);
                }
                finally
                {
                    bitmap.Dispose();
                }

                var wpfBitmap = new BitmapImage();
                wpfBitmap.BeginInit();
                wpfBitmap.CacheOption  = BitmapCacheOption.OnLoad;
                wpfBitmap.StreamSource = memoryStream;
                wpfBitmap.EndInit();
                wpfBitmap.Freeze();

                return(wpfBitmap);
            }
        }
Ejemplo n.º 30
0
        public MemoryStream GetPreview(PreviewSettings settings, int previewNumber, bool deinterlace)
        {
            SourceTitle title = this.Titles.TitleList.FirstOrDefault(t => t.Index == settings.TitleNumber);

            // Create the Expected Output Geometry details for libhb.
            hb_geometry_settings_s uiGeometry = new hb_geometry_settings_s
            {
                crop      = new[] { settings.Cropping.Top, settings.Cropping.Bottom, settings.Cropping.Left, settings.Cropping.Right },
                itu_par   = 0,
                keep      = (int)AnamorphicFactory.KeepSetting.HB_KEEP_WIDTH + (settings.KeepDisplayAspect ? 0x04 : 0), // TODO Keep Width?
                maxWidth  = settings.MaxWidth,
                maxHeight = settings.MaxHeight,
                mode      = (int)(hb_anamorphic_mode_t)settings.Anamorphic,
                modulus   = settings.Modulus ?? 16,
                geometry  = new hb_geometry_s
                {
                    height = settings.Height,
                    width  = settings.Width,
                    par    = settings.Anamorphic != Anamorphic.Custom
                        ? new hb_rational_t {
                        den = title.Geometry.PAR.Den, num = title.Geometry.PAR.Num
                    }
                        : new hb_rational_t {
                        den = settings.PixelAspectY, num = settings.PixelAspectX
                    }
                }
            };

            // Fetch the image data from LibHb
            IntPtr     resultingImageStuct = HBFunctions.hb_get_preview2(this.hbHandle, settings.TitleNumber, previewNumber, ref uiGeometry, deinterlace ? 1 : 0);
            hb_image_s image = InteropUtilities.ToStructureFromPtr <hb_image_s>(resultingImageStuct);

            // Copy the filled image buffer to a managed array.
            int stride_width    = image.plane[0].stride;
            int stride_height   = image.plane[0].height_stride;
            int imageBufferSize = stride_width * stride_height;  // int imageBufferSize = outputWidth * outputHeight * 4;

            byte[] managedBuffer = new byte[imageBufferSize];
            Marshal.Copy(image.plane[0].data, managedBuffer, 0, imageBufferSize);

            var bitmap = new Bitmap(image.width, image.height);

            BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, image.width, image.height), ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb);

            IntPtr ptr = bitmapData.Scan0; // Pointer to the first pixel.

            for (int i = 0; i < image.height; i++)
            {
                try
                {
                    Marshal.Copy(managedBuffer, i * stride_width, ptr, stride_width);
                    ptr = IntPtr.Add(ptr, image.width * 4);
                }
                catch (Exception exc)
                {
                    Debug.WriteLine(exc); // In theory, this will allow a partial image display if this happens. TODO add better logging of this.
                }
            }

            bitmap.UnlockBits(bitmapData);

            // Close the image so we don't leak memory.
            IntPtr nativeJobPtrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));

            Marshal.WriteIntPtr(nativeJobPtrPtr, resultingImageStuct);
            HBFunctions.hb_image_close(nativeJobPtrPtr);
            Marshal.FreeHGlobal(nativeJobPtrPtr);

            // Converts Bitmap into MemoryStream for transport.
            var memoryStream = new MemoryStream();

            try
            {
                bitmap.Save(memoryStream, ImageFormat.Bmp);
            }
            finally
            {
                bitmap.Dispose();
            }

            return(memoryStream);
        }
Ejemplo n.º 31
0
        internal static void RenderMeshPreviewSkipCameraAndLighting(
            Mesh mesh,
            Bounds bounds,
            PreviewRenderUtility previewUtility,
            PreviewSettings settings,
            MaterialPropertyBlock customProperties,
            int meshSubset) // -1 for whole mesh
        {
            if (mesh == null || previewUtility == null)
            {
                return;
            }

            Quaternion rot = Quaternion.Euler(settings.previewDir.y, 0, 0) * Quaternion.Euler(0, settings.previewDir.x, 0);
            Vector3    pos = rot * (-bounds.center);

            bool oldFog = RenderSettings.fog;

            Unsupported.SetRenderSettingsUseFogNoDirty(false);

            int submeshes     = mesh.subMeshCount;
            var tintSubmeshes = false;
            var colorPropID   = 0;

            if (submeshes > 1 && settings.displayMode == DisplayMode.Shaded && customProperties == null & meshSubset == -1)
            {
                tintSubmeshes    = true;
                customProperties = new MaterialPropertyBlock();
                colorPropID      = Shader.PropertyToID("_Color");
            }

            if (settings.activeMaterial != null)
            {
                previewUtility.camera.clearFlags = CameraClearFlags.Nothing;
                if (meshSubset < 0 || meshSubset >= submeshes)
                {
                    for (int i = 0; i < submeshes; ++i)
                    {
                        if (tintSubmeshes)
                        {
                            customProperties.SetColor(colorPropID, GetSubMeshTint(i));
                        }
                        previewUtility.DrawMesh(mesh, pos, rot, settings.activeMaterial, i, customProperties);
                    }
                }
                else
                {
                    previewUtility.DrawMesh(mesh, pos, rot, settings.activeMaterial, meshSubset, customProperties);
                }
                previewUtility.Render();
            }

            if (settings.wireMaterial != null && settings.drawWire)
            {
                previewUtility.camera.clearFlags = CameraClearFlags.Nothing;
                GL.wireframe = true;
                if (tintSubmeshes)
                {
                    customProperties.SetColor(colorPropID, settings.wireMaterial.color);
                }
                if (meshSubset < 0 || meshSubset >= submeshes)
                {
                    for (int i = 0; i < submeshes; ++i)
                    {
                        // lines/points already are wire-like; it does not make sense to overdraw
                        // them again with dark wireframe color
                        var topology = mesh.GetTopology(i);
                        if (topology == MeshTopology.Lines || topology == MeshTopology.LineStrip || topology == MeshTopology.Points)
                        {
                            continue;
                        }
                        previewUtility.DrawMesh(mesh, pos, rot, settings.wireMaterial, i, customProperties);
                    }
                }
                else
                {
                    previewUtility.DrawMesh(mesh, pos, rot, settings.wireMaterial, meshSubset, customProperties);
                }
                previewUtility.Render();
                GL.wireframe = false;
            }

            Unsupported.SetRenderSettingsUseFogNoDirty(oldFog);
        }