Exemple #1
0
        public ColorYUV(float y, float u, float v, float a, ColorStandard standard = ColorStandard.BT_601)
        {
            this.y = y;
            this.u = u;
            this.v = v;
            this.a = a;

            bool use709 = standard == ColorStandard.BT_709;

            wr = use709 ? wr709 : wr601;
            wg = use709 ? wg709 : wg601;
            wb = use709 ? wb709 : wb601;
        }
Exemple #2
0
        public ColorYUV(Color rgb, float gamma = 2.2f, ColorStandard standard = ColorStandard.BT_601)
        {
            if (gamma != 1.0f)
            {
                rgb = rgb.GammaToLinear(gamma);
            }

            bool use709 = standard == ColorStandard.BT_709;

            wr = use709 ? wr709 : wr601;
            wg = use709 ? wg709 : wg601;
            wb = use709 ? wb709 : wb601;

            y = wr * rgb.r + wg * rgb.g + wb * rgb.b;
            u = uMax * ((rgb.b - y) / (1.0f - wb));
            v = vMax * ((rgb.r - y) / (1.0f - wr));
            a = rgb.a;

            if (gamma != 1.0f)
            {
                y = Mathf.Pow(y, 1.0f / gamma);
            }
        }
        public List <SoftwarePackage> GetAllSoftwarePackage(int pageNo, int pageSize, string searchText, string sortColumn, string sortDirection)
        {
            try
            {
                OpenConnection();

                List <SoftwarePackage> inventory = new List <SoftwarePackage>();
                int totalRecs = 0;

                using (SqlCommand command = new SqlCommand("Inventory.usp_GetAllSoftwarePackages", _sqlConnection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add(new SqlParameter {
                        ParameterName = "@PageNo", SqlDbType = SqlDbType.Int, Value = pageNo
                    });
                    command.Parameters.Add(new SqlParameter {
                        ParameterName = "@PageSize", SqlDbType = SqlDbType.Int, Value = pageSize
                    });
                    command.Parameters.Add(new SqlParameter {
                        ParameterName = "@SearchText", SqlDbType = SqlDbType.VarChar, Value = searchText
                    });
                    command.Parameters.Add(new SqlParameter {
                        ParameterName = "@SortColumn", SqlDbType = SqlDbType.VarChar, Value = sortColumn.ToUpper()
                    });
                    command.Parameters.Add(new SqlParameter {
                        ParameterName = "@SortDirection", SqlDbType = SqlDbType.VarChar, Value = sortDirection.ToUpper()
                    });

                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            ColorStandard colorStandard = ((ColorStandard)Convert.ToInt32(reader["SwColorStandardID"]));

                            inventory.Add(
                                new SoftwarePackage
                            {
                                SwPkgUID          = new Guid(reader["SwPkgUID"].ToString()),
                                SwPkgVersion      = reader["SwPkgVersion"].ToString(),
                                SwColorStandardID = colorStandard.GetType()
                                                    .GetMember(colorStandard.ToString())
                                                    .First()
                                                    .GetCustomAttribute <DisplayAttribute>()
                                                    .GetName(),
                                SwAddedDate  = Convert.ToDateTime(reader["AddedDate"]),
                                SwFileName   = reader["FileName"].ToString(),
                                SwFileSize   = String.IsNullOrEmpty(reader["FileSize"].ToString()) ? 0 : (Convert.ToInt64(reader["FileSize"]) / 1024f) / 1024f,
                                Manufacturer = reader["Manufacturer"].ToString(),
                                DeviceType   = reader["DeviceType"].ToString()
                            }
                                );
                        }

                        reader.NextResult();
                        while (reader.Read())
                        {
                            totalRecs = Convert.ToInt32(reader["TotalRecords"]);
                        }

                        reader.NextResult();
                        Dictionary <Guid, string> keyValuePairs = new Dictionary <Guid, string>();
                        while (reader.Read())
                        {
                            keyValuePairs.Add(new Guid(reader["SwPkgUID"].ToString()), reader["FileName"].ToString());
                        }
                        inventory.ForEach(i =>
                        {
                            if (keyValuePairs.ContainsKey(i.SwPkgUID))
                            {
                                i.HelpDocFileName = keyValuePairs[i.SwPkgUID];
                            }
                        });

                        reader.NextResult();
                        Dictionary <Guid, List <CameraModelName> > swModelMap = new Dictionary <Guid, List <CameraModelName> >();
                        while (reader.Read())
                        {
                            var key   = new Guid(reader["SwPkgUID"].ToString());
                            var value = reader["DeviceModelName"].ToString();

                            if (swModelMap.ContainsKey(key))
                            {
                                swModelMap[key].Add(new CameraModelName {
                                    ModelName = value
                                });
                            }
                            else
                            {
                                swModelMap.Add(key, new List <CameraModelName> {
                                    new CameraModelName {
                                        ModelName = value
                                    }
                                });
                            }
                        }
                        inventory.ForEach(i =>
                        {
                            if (swModelMap.ContainsKey(i.SwPkgUID))
                            {
                                i.CameraModels = swModelMap[i.SwPkgUID];
                                i.TotalRecords = totalRecs;
                            }
                        });
                        if ("TYPE" == sortColumn.ToUpper() && "ASC" == sortDirection.ToUpper())
                        {
                            inventory = inventory.OrderBy(i => i.SwColorStandardID).ToList();
                        }
                        if ("TYPE" == sortColumn.ToUpper() && "DESC" == sortDirection.ToUpper())
                        {
                            inventory = inventory.OrderByDescending(i => i.SwColorStandardID).ToList();
                        }
                    }
                }

                return(inventory);
            }
            catch (SqlException ex)
            {
                throw;
            }
            finally
            {
                CloseConnection();
            }
        }