예제 #1
0
파일: p2p.cs 프로젝트: soleiyu/CSharp
        static void mkPix()
        {
            pixelData = new byte[pict.Width, pict.Height, 3];

            BitmapPlus bp = new BitmapPlus(pict);

            bp.BeginAccess();

            for (int y = 0; y < pict.Height; y++)
            {
                for (int x = 0; x < pict.Width; x++)
                {
                    Color cc = bp.GetPixel(x, y);
                    pixelData[x, y, 0] = cc.R;
                    pixelData[x, y, 1] = cc.G;
                    pixelData[x, y, 2] = cc.B;
                }
            }

            bp.EndAccess();
        }
예제 #2
0
        /// <summary>
        /// 画像の中心線上のRGBの合計値を計算し、該当する数字を返す
        /// </summary>
        /// <param name="img">画像</param>
        /// <returns></returns>
        public int RGBsum_to_number(BitmapPlus img_bit_p, int pos_x, int pos_y, int cell_width, int cell_height)
        {
            int R_sum = 0, G_sum = 0, B_sum = 0;

            for (int x = 0; x < cell_width; x++)
            {
                Color pixeldata = img_bit_p.GetPixel(cell_width * pos_x + x, cell_height * pos_y + cell_height / 2);
                R_sum += pixeldata.R;
                G_sum += pixeldata.G;
                B_sum += pixeldata.B;
            }

            if (pos_x == 0 && pos_y == 0)
            {
                //label1.Text = R_sum.ToString() + ", " + G_sum.ToString() + ", " + B_sum.ToString();
            }

            if (R_sum == 3008 && G_sum == 3008 && B_sum == 3008)
            {
                return(0);
            }
            else if (R_sum == 2432 && G_sum == 2432 && B_sum == 3197)
            {
                return(1);
            }
            else if (R_sum == 2048 && G_sum == 2688 && B_sum == 2048)
            {
                return(2);
            }
            else if (R_sum == 3386 && G_sum == 1856 && B_sum == 1856)
            {
                return(3);
            }
            else if (R_sum == 1088 && G_sum == 1088 && B_sum == 2368)
            {
                return(4);
            }
            else if (R_sum == 2368 && G_sum == 1088 && B_sum == 1088)
            {
                return(5);
            }
            else if (R_sum == 1088 && G_sum == 2368 && B_sum == 2368)
            {
                return(6);
            }
            else if (R_sum == 2432 && G_sum == 2432 && B_sum == 2432)
            {
                return(7);
            }
            else if (R_sum == 3070 && G_sum == 3070 && B_sum == 3070)
            {
                return(-1);
            }
            else if (R_sum == 2878 && G_sum == 2878 && B_sum == 2878)
            {
                return(-10);
            }
            else if (R_sum == 512 && G_sum == 512 && B_sum == 512)
            {
                restart_ = true;
            }
            else if (R_sum == 638 && G_sum == 128 && B_sum == 128)
            {
                restart_ = true;
            }
            else
            {
                label1.Text = "error";
                //is_running = false;
            }
            return(-1);
            // メモ
            // 埋: 3070, 3070, 3070
            // 旗: 2878, 2878, 2878
            // 0 : 3008, 3008, 3008
            // 1 : 2432, 2432, 3197
            // 2 : 2048, 2688, 2048
            // 3 : 3386, 1856, 1856
            // 4 : 1088, 1088, 2368
            // 5 : 2368, 1088, 1088
            // 6 : 1088, 2368, 2368
            // 7 : 2432, 2432, 2432
            // × :  512,  512,  512
            // ×2:  638,  128,  128
        }