返回图片指定点的RGB值

 #region 返回图片指定点的RGB值
        /// <summary>
        /// 返回图片指定点的RGB值
        /// </summary>
        /// <param name="ImageName"></param>
        /// <returns></returns>
        public static string GetImageRGB(string ImageName)
        {
            string temp = string.Empty;
            if (File.Exists(ImageName))
            {
                Bitmap bmp = new Bitmap(ImageName);
                Color pixelColor = bmp.GetPixel(50, 50);
                int rgb = pixelColor.ToArgb() & 0xFFFFFF;
                temp = "#" + rgb.ToString("X6");
            }
            else
            {
                temp = "#FBAA1A";
            }
            return temp;
        }
        #endregion

 

posted @ 2015-07-08 12:02  好吧的啊  阅读(308)  评论(0编辑  收藏  举报