コード例 #1
0
ファイル: Treshold.cs プロジェクト: quavepl/APOBlabs
        public Treshold(ImageWindow iw)
        {
            InitializeComponent();
            this.iw = iw;
            MdiParent = iw.MdiParent;
            Text = Text + " " + iw.Text;
            HistogramImage.Image = new Bitmap(HistogramImage.Width, HistogramImage.Height);
            LUT = (UInt32[,])iw.LUT.Clone();

            max = 0;
            for (int i = 0; i < 256; i++)
            {
                if (LUT[0, i] > max) max = LUT[0, i];
                if (LUT[1, i] > max) max = LUT[1, i];
                if (LUT[2, i] > max) max = LUT[2, i];
                if (LUT[3, i] > max) max = LUT[3, i];
            }

            prevImg = iw.getBitmap();
            iw.Treshold(ZipVal.Value,Reverse.Checked);
            hHeight = HistogramImage.Height;
            hWidth = HistogramImage.Width;
            x_scale = ((float)hWidth - 10.0F) / 256.0F;
            y_scale = ((float)hHeight - 15.0F) / (float)max;

            DrawHistogram();
            Show();
        }
コード例 #2
0
        //открытие изображения
        private void открытьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog open_dialog = new OpenFileDialog();

            open_dialog.Filter = "Image Files(*.BMP;*.JPG;*.GIF;*.PNG)|*.BMP;*.JPG;*.GIF;*.PNG|All files (*.*)|*.*";
            if (open_dialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    full_name_of_image = open_dialog.FileName;
                    image = new Bitmap(open_dialog.FileName);
                    //this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                    this.Width            = image.Width + 40;
                    this.Height           = image.Height + 75;
                    this.pictureBox1.Size = image.Size;
                    pictureBox1.Image     = image;
                    pictureBox1.Invalidate(); //????
                    //получение матрицы с пикселями
                    pixel = new UInt32[image.Height, image.Width];
                    for (int y = 0; y < image.Height; y++)
                    {
                        for (int x = 0; x < image.Width; x++)
                        {
                            pixel[y, x] = (UInt32)(image.GetPixel(x, y).ToArgb());
                        }
                    }
                }
                catch
                {
                    full_name_of_image = "\0";
                    DialogResult rezult = MessageBox.Show("Невозможно открыть выбранный файл",
                                                          "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: ElenaBar/FileView
        private void открытьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openDialog = new OpenFileDialog();

            openDialog.Filter = string.Format("{0}Image Files(*.BMP;*.JPG;*.GIF;*.PNG)|*.BMP;*.JPG;*.GIF;*.PNG|All files (*.*)|*.*", "ARG0");
            if (openDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    FullNameOfImage   = openDialog.FileName;
                    MyImg             = new Bitmap(openDialog.FileName);
                    pictureBox1.Image = MyImg;

                    pictureBox1.Invalidate();

                    //получение матрицы с пикселями
                    Pixel = new UInt32[MyImg.Height, MyImg.Width];
                    for (int y = 0; y < MyImg.Height; y++)
                    {
                        for (int x = 0; x < MyImg.Width; x++)
                        {
                            Pixel[y, x] = (UInt32)(MyImg.GetPixel(x, y).ToArgb());
                        }
                    }
                }
                catch
                {
                    FullNameOfImage = "\0";
                    DialogResult rezult = MessageBox.Show("Невозможно открыть выбранный файл", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #4
0
        static public UInt32[,] Move(UInt32[,] imageMatrix, int width, int height, int moveX, int moveY)
        {
            UInt32[,] newImage = new UInt32[height, width];
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    newImage[i, j] = 0;
                }
            }

            double[,] translation = GetTranslationMatrix(moveX, moveY);

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    UInt32 color = imageMatrix[i, j];
                    double[,] vector = { { j, i, 1 } };
                    double[,] result = MatrixMultiplication(vector, translation);

                    int x = (int)result[0, 0];
                    int y = (int)result[0, 1];

                    if (CheckLimit(x, y, width, height))
                    {
                        newImage[y, x] = color;
                    }
                }
            }

            return(newImage);
        }
コード例 #5
0
 private void збільшитиРізкістьToolStripMenuItem_Click(object sender, EventArgs e)
 {
     pixel = Filter.matrix_filtration(image.Width, image.Height, pixel, Filter.N1, Filter.sharpness);
     //pixel = Filter.matrix_filtration(image.Width, image.Height, pixel, Filter.N5, Filter.sharpness_d);
     FromPixelToBitmap();
     FromBitmapToScreen();
 }
コード例 #6
0
        static public UInt32[,] Scale(UInt32[,] imageMatrix, int width, int height, double scaleX, double scaleY)
        {
            int newWidth  = (int)(width * scaleX);
            int newHeight = (int)(height * scaleY);

            UInt32[,] newImage = new UInt32[newHeight, newWidth];
            for (int i = 0; i < newHeight; i++)
            {
                for (int j = 0; j < newWidth; j++)
                {
                    newImage[i, j] = 0;
                }
            }

            double[,] scaling = GetScalingMatrix(1 / scaleX, 1 / scaleY);

            for (int i = 0; i < newHeight; i++)
            {
                for (int j = 0; j < newWidth; j++)
                {
                    double[,] vector = { { j, i, 1 } };
                    double[,] result = MatrixMultiplication(vector, scaling);

                    double x = result[0, 0];
                    double y = result[0, 1];

                    int x0 = (int)Math.Floor(x);
                    int x1 = x0 + 1;
                    int y0 = (int)Math.Floor(y);
                    int y1 = y0 + 1;

                    UInt32 color1 = 0, color2 = 0, color3 = 0, color4 = 0;
                    if (CheckLimit(x0, y0, width, height))
                    {
                        color1 = imageMatrix[y0, x0];
                    }
                    if (CheckLimit(x1, y0, width, height))
                    {
                        color2 = imageMatrix[y0, x1];
                    }
                    if (CheckLimit(x0, y1, width, height))
                    {
                        color3 = imageMatrix[y1, x0];
                    }
                    if (CheckLimit(x1, y1, width, height))
                    {
                        color4 = imageMatrix[y1, x1];
                    }

                    double dx = x - x0;
                    double dy = y - y0;

                    UInt32 resColor = (color1 + Convert.ToUInt32(dx) * (color2 - color1) + Convert.ToUInt32(dy) * (color3 - color1) + Convert.ToUInt32(dx) * Convert.ToUInt32(dy) * (color4 + color1 - color2 - color3));

                    newImage[i, j] = resColor;
                }
            }

            return(newImage);
        }
コード例 #7
0
ファイル: DotWave.cs プロジェクト: jkulvich/DotWave
        // Готовые шаблоны обработки аудио
        #region public static UInt32[,] Make8Bit(UInt32[,] audio, UInt32 steps)
        public static UInt32[,] Make8Bit(UInt32[,] audio, UInt32 sampleRate, UInt32 Vsteps, UInt32 Hsteps)
        {
            UInt32[,] naudio = new UInt32[audio.GetLength(0), audio.GetLength(1)];
            uint Vstep = UInt32.MaxValue / Vsteps;
            uint Hstep = sampleRate / Hsteps;

            for (int ch = 0; ch < audio.GetLength(1); ch++)
            {
                for (uint i = 0; i < audio.GetLength(0) / Hstep; i++)
                {
                    ulong value = 0;
                    for (uint ist = 0; ist < Hstep; ist++)
                    {
                        value += audio[i * Hstep + ist, ch];
                    }
                    value = (uint)((double)value / Hstep);
                    for (uint ist = 0; ist < Hstep; ist++)
                    {
                        uint bval = (uint)((Math.Sin(Math.PI * ((ist + i * Hstep) * 0.01f)) * Int32.MaxValue * ((double)value / UInt32.MaxValue)) + Int32.MaxValue); // TODO Отследить среднюю частоту волн
                        if (bval > Int32.MaxValue)
                        {
                            bval -= Int32.MaxValue;
                        }
                        else
                        {
                            bval += Int32.MaxValue;
                        }
                        naudio[i * Hstep + ist, ch] = bval;
                    }
                }
            }
            return(naudio);
        }
コード例 #8
0
ファイル: Histogram.cs プロジェクト: ptaszkie/APOBlabs
        public Histogram(ImageWindow iw)
        {
            InitializeComponent();
            MdiParent            = iw.MdiParent;
            Text                 = Text + " " + iw.Text;
            image                = iw.getBitmap();
            HistogramImage.Image = new Bitmap(HistogramImage.Width, HistogramImage.Height);
            LUT = (UInt32[, ])iw.LUT.Clone();

            max = 0;
            for (int i = 0; i < 256; i++)
            {
                if (LUT[0, i] > max)
                {
                    max = LUT[0, i];
                }
                if (LUT[1, i] > max)
                {
                    max = LUT[1, i];
                }
                if (LUT[2, i] > max)
                {
                    max = LUT[2, i];
                }
                if (LUT[3, i] > max)
                {
                    max = LUT[3, i];
                }
            }

            Histogram_ResizeEnd();
            Show();
        }
コード例 #9
0
ファイル: Form1.cs プロジェクト: RisingKratos/AllFiltersBored
 //открытие изображения
 private void открытьToolStripMenuItem_Click(object sender, EventArgs e)
 {
     OpenFileDialog open_dialog = new OpenFileDialog();
     open_dialog.Filter = "Image Files(*.BMP;*.JPG;*.GIF;*.PNG)|*.BMP;*.JPG;*.GIF;*.PNG|All files (*.*)|*.*";
     if (open_dialog.ShowDialog() == DialogResult.OK)
     {
         try
         {
             full_name_of_image = open_dialog.FileName;
             image = new Bitmap(open_dialog.FileName);
             //this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
             this.Width = image.Width + 40;
             this.Height = image.Height + 75;
             this.pictureBox1.Size = image.Size;
             pictureBox1.Image = image;
             pictureBox1.Invalidate(); //????
             //получение матрицы с пикселями
             pixel = new UInt32[image.Height, image.Width];
             for (int y = 0; y < image.Height; y++)
                 for (int x = 0; x < image.Width; x++)
                     pixel[y, x] = (UInt32)(image.GetPixel(x, y).ToArgb());
         }
         catch
         {
             full_name_of_image = "\0";
             DialogResult rezult = MessageBox.Show("Невозможно открыть выбранный файл",
             "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
コード例 #10
0
        static public UInt32[,] MirrorX(UInt32[,] imageMatrix, int width, int height)
        {
            UInt32[,] newImage = new UInt32[height, width];
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    newImage[i, j] = 0;
                }
            }

            double[,] reflection = GetReflectionMatrix(Math.PI * 90 / 180.0);

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    UInt32 color = imageMatrix[i, j];
                    double[,] vector      = { { j - width / 2, i - height / 2, 1 } };
                    double[,] result      = MatrixMultiplication(vector, reflection);
                    double[,] translation = GetTranslationMatrix(width / 2, height / 2);
                    result = MatrixMultiplication(result, translation);

                    double x = result[0, 0];
                    double y = result[0, 1];

                    int x0 = (int)Math.Floor(x);
                    int x1 = x0 + 1;
                    int y0 = (int)Math.Floor(y);
                    int y1 = y0 + 1;

                    UInt32 color1 = 0, color2 = 0, color3 = 0, color4 = 0;
                    if (CheckLimit(x0, y0, width, height))
                    {
                        color1 = imageMatrix[y0, x0];
                    }
                    if (CheckLimit(x1, y0, width, height))
                    {
                        color2 = imageMatrix[y0, x1];
                    }
                    if (CheckLimit(x0, y1, width, height))
                    {
                        color3 = imageMatrix[y1, x0];
                    }
                    if (CheckLimit(x1, y1, width, height))
                    {
                        color4 = imageMatrix[y1, x1];
                    }

                    double dx = x - x0;
                    double dy = y - y0;

                    UInt32 resColor = (color1 + Convert.ToUInt32(dx) * (color2 - color1) + Convert.ToUInt32(dy) * (color3 - color1) + Convert.ToUInt32(dx) * Convert.ToUInt32(dy) * (color4 + color1 - color2 - color3));

                    newImage[i, j] = resColor;
                }
            }

            return(newImage);
        }
コード例 #11
0
        static UInt32 CalculateHash(UInt32[,] table, UInt32 seed, byte[] buffer, int start, int size)
        {
            var hash = seed;

            var length = size - start;
            var i      = start;

            unchecked
            {
                while (length >= 8)
                {
                    var one = BitConverter.ToInt32(buffer, i) ^ hash;
                    var two = BitConverter.ToInt32(buffer, i + 4);
                    hash =
                        table[0, (two >> 24) & 0xFF] ^
                        table[1, (two >> 16) & 0xFF] ^
                        table[2, (two >> 8) & 0xFF] ^
                        table[3, two & 0xFF] ^
                        table[4, (one >> 24) & 0xFF] ^
                        table[5, (one >> 16) & 0xFF] ^
                        table[6, (one >> 8) & 0xFF] ^
                        table[7, one & 0xFF];
                    length -= 8;
                    i      += 8;
                }

                while (length-- != 0)
                {
                    hash = (hash >> 8) ^ table[0, buffer[i++] ^ hash & 0xff];
                }
            }

            return(hash);
        }
コード例 #12
0
        public IActionResult UpdateBlurImage()  //размытие
        {
            image = new Bitmap(ActionPictureController.pathImage);

            pixel = new UInt32[image.Height, image.Width];
            for (int y = 0; y < image.Height; y++)
            {
                for (int x = 0; x < image.Width; x++)
                {
                    pixel[y, x] = (UInt32)(image.GetPixel(x, y).ToArgb());
                }
            }

            pixel = Filter.matrix_filtration(image.Width, image.Height, pixel, Filter.N2, Filter.blur);
            FromPixelToBitmap();

            bitmapBytes = BitmapToBytes(image);
            image.Dispose();

            string imreBase64Data = Convert.ToBase64String(bitmapBytes);
            string imgDataURL     = string.Format("data:image/jpeg;base64,{0}", imreBase64Data);

            ViewBag.ImageData = imgDataURL;
            return(View("~/Views/Home/UpdateImage.cshtml"));
        }
コード例 #13
0
ファイル: DotWave.cs プロジェクト: jkulvich/DotWave
 public DotWaveInfo(UInt32[,] Data, UInt32 SampleRate, UInt16 BitsPerSample)
 {
     data          = Data;
     sampleRate    = SampleRate;
     bitsPerSample = BitsPerSample;
     RecalcAll();
 }
コード例 #14
0
ファイル: Form1.cs プロジェクト: KorneevVitaly/XZPaint
 private void colorSharpeningToolStripMenuItem_Click(object sender, EventArgs e)
 {
     bmp   = (Bitmap)pictureBox1.Image;
     pixel = Filter.matrix_filtration(bmp.Width, bmp.Height, pixel, Filter.N1, Filter.sharpness);
     FromPixelToBitmap();
     FromBitmapToScreen();
 }
コード例 #15
0
ファイル: Form1.cs プロジェクト: KorneevVitaly/XZPaint
 private void bluurToolStripMenuItem_Click(object sender, EventArgs e)
 {
     bmp   = (Bitmap)pictureBox1.Image;
     pixel = Filter.matrix_filtration(bmp.Width, bmp.Height, pixel, Filter.N2, Filter.blur);
     FromPixelToBitmap();
     FromBitmapToScreen();
 }
コード例 #16
0
 public void Draw(IEnumerable <Model> models, UInt32[,] colors)
 {
     float[,] zBuffer = new float[res.Width, res.Height];
     foreach (var model in models)
     {
         foreach (var triangle in model)
         {
             List <Point3D> points3d = new List <Point3D>(Triangle.pointsCount);
             foreach (var edge in triangle.GetEdges())
             {
                 Point3D p1 = VertexShader(model.matrix, camera.Matrix, Mproj, edge.startPoint);
                 Point3D p2 = VertexShader(model.matrix, camera.Matrix, Mproj, edge.endPoint);
                 p1.Normalize();
                 p2.Normalize();
                 if (Math.Abs(p1.X) <= 1 && Math.Abs(p1.Y) <= 1 && Math.Abs(p2.X) <= 1 && Math.Abs(p2.Y) <= 1)
                 {
                     points3d.Add(NormalizeToScreen(p1));
                 }
             }
             if (points3d.Count == Triangle.pointsCount)
             {
                 PointFiller pf = new PointFiller(pl, triangle, colors, (x, y) => triangle.color, zBuffer, points3d.ToArray());
                 Filler.Draw(points3d, pf.Fill);
             }
         }
     }
 }
コード例 #17
0
ファイル: Form1.cs プロジェクト: AnnaLebedeva1001/MAI
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "Image files (*.BMP, *.JPG, *.GIF, *.TIF, *.PNG, *.ICO," +
                            " *.EMF, *.WMF)| *.bmp; *.jpg; *.gif; *.tif; *.png; *.ico; *.emf; *.wmf";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                bmp = new Bitmap(dialog.FileName);
                pictureBox1.Image = bmp;

                pixel = new UInt32[bmp.Height, bmp.Width];
                for (int y = 0; y < bmp.Height; y++)
                {
                    for (int x = 0; x < bmp.Width; x++)
                    {
                        pixel[y, x] = (UInt32)(bmp.GetPixel(x, y).ToArgb());
                    }
                }

                startPoint   = endPoint = Point.Empty;
                selectedArea = Rectangle.Empty;
                pictureBox1.Invalidate();;
            }
        }
コード例 #18
0
ファイル: Program.cs プロジェクト: goodwink/sxASCOM
        static void stats(UInt32[,] imageData)
        {
            UInt64[,] sums = new UInt64[2, 2];
            UInt64 sum = 0;
            UInt64 zeros = 0;
            int    x, y;

            for (x = 0; x < width; x++)
            {
                for (y = 0; y < height; y++)
                {
                    sums[x % 2, y % 2] += imageData[x, y];
                    sum += imageData[x, y];
                    if (imageData[x, y] == 0)
                    {
                        zeros++;
                    }
                }
            }

            Console.WriteLine("imaageRawData.Length = {0}", imageData.Length);
            Console.WriteLine("sum={0:N}, average={1}", sum, sum / numElements);
            Console.WriteLine("sums:\n\t{0,15:N0}\n\t{1,15:N0}\n\t{2,15:N0}\n\t{3,15:N0}", sums[0, 0], sums[0, 1], sums[1, 0], sums[1, 1]);
            Console.WriteLine("zeros = {0}", zeros);

            Console.WriteLine();
        }
コード例 #19
0
ファイル: Form1.cs プロジェクト: KorneevVitaly/XZPaint
        private void invertToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Bitmap temp = (Bitmap)pictureBox1.Image;
            Bitmap bmap = (Bitmap)temp.Clone();

            Color c;

            for (int i = 0; i < bmap.Width; i++)
            {
                for (int j = 0; j < bmap.Height; j++)
                {
                    c = bmap.GetPixel(i, j);
                    bmap.SetPixel(i, j, Color.FromArgb(255 - c.R, 255 - c.G, 255 - c.B));
                }
            }

            pixel = new UInt32[bmap.Height, bmap.Width];
            for (int y = 0; y < bmap.Height; y++)
            {
                for (int x = 0; x < bmap.Width; x++)
                {
                    pixel[y, x] = (UInt32)(bmap.GetPixel(x, y).ToArgb());
                }
            }


            pictureBox1.Image = (Bitmap)bmap.Clone();
            bmp = (Bitmap)bmap.Clone();
        }
コード例 #20
0
            /*-------------------------------------------------------------------------
             * キャプチャした内容をテクスチャにする
             * デバッグ用
             * ---------------------------------------------------------------------------*/
            public Texture CreateTexture(Device device)
            {
                if (base.image == null)
                {
                    return(null);
                }

                using (Texture tex = new Texture(device, base.size.Width, base.size.Height,
                                                 1, 0, Format.X8R8G8B8, Pool.SystemMemory)){
                    UInt32[,] buf = (UInt32[, ])tex.LockRectangle(typeof(UInt32), 0, LockFlags.Discard, base.size.Height, base.size.Width);

                    // テクスチャ内容の生成
                    int index = 0;
                    for (int y = 0; y < base.size.Height; y++)
                    {
                        for (int x = 0; x < base.size.Width; x++)
                        {
                            buf[y, x] = (UInt32)((image[index + x * 3 + 2] << 16)
                                                 | (image[index + x * 3 + 1] << 8)
                                                 | (image[index + x * 3 + 0] << 0)
                                                 | (255 << 24));
                        }
                        index += stride;
                    }
                    tex.UnlockRectangle(0);

                    // 使用できるメモリに転送
                    return(d3d_device.CreateTextureFromTexture(device, tex));
                }
            }
コード例 #21
0
ファイル: gvo_capture.cs プロジェクト: Killbook/GVTradeMap
            /*-------------------------------------------------------------------------
             * 캡처した내용を텍스쳐にする
             * デバッグ용
             * ---------------------------------------------------------------------------*/
            public Texture CreateTexture(Device device)
            {
                if (base.Image == null)
                {
                    return(null);
                }

                try {
                    using (Texture tex = new Texture(device, base.Size.Width, base.Size.Height,
                                                     1, Usage.Dynamic, Format.X8R8G8B8, Pool.SystemMemory)) {
                        UInt32[,] buf = (UInt32[, ])tex.LockRectangle(typeof(UInt32), 0, LockFlags.Discard, base.Size.Height, base.Size.Width);

                        // 텍스쳐내용の生成
                        int index = 0;
                        for (int y = 0; y < base.Size.Height; y++)
                        {
                            for (int x = 0; x < base.Size.Width; x++)
                            {
                                buf[y, x] = (UInt32)((Image[index + x * 3 + 2] << 16)
                                                     | (Image[index + x * 3 + 1] << 8)
                                                     | (Image[index + x * 3 + 0] << 0)
                                                     | (255 << 24));
                            }
                            index += Stride;
                        }
                        tex.UnlockRectangle(0);

                        // 사용できる메모リに전送
                        return(d3d_utility.CreateTextureFromTexture(device, tex));
                    }
                } catch {
                    // 실패
                    return(null);
                }
            }
コード例 #22
0
ファイル: Form1.cs プロジェクト: KorneevVitaly/XZPaint
        private void grayscaleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Bitmap temp = (Bitmap)pictureBox1.Image;
            Bitmap bmap = (Bitmap)temp.Clone();

            Color c;

            for (int i = 0; i < bmap.Width; i++)
            {
                for (int j = 0; j < bmap.Height; j++)
                {
                    c = bmap.GetPixel(i, j);
                    byte gray = (byte)(.299 * c.R + .587 * c.G + .114 * c.B);
                    bmap.SetPixel(i, j, Color.FromArgb(gray, gray, gray));
                }
            }

            pixel = new UInt32[bmap.Height, bmap.Width];
            for (int y = 0; y < bmap.Height; y++)
            {
                for (int x = 0; x < bmap.Width; x++)
                {
                    pixel[y, x] = (UInt32)(bmap.GetPixel(x, y).ToArgb());
                }
            }


            pictureBox1.Image = (Bitmap)bmap.Clone();
            bmp = (Bitmap)bmap.Clone();
        }
コード例 #23
0
ファイル: Form1.cs プロジェクト: KorneevVitaly/XZPaint
        private void mirrorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Bitmap originBitmap;

            originBitmap = (Bitmap)pictureBox1.Image;
            pixel        = new UInt32[originBitmap.Height, originBitmap.Width];
            for (int y = 0; y < originBitmap.Height; y++)
            {
                for (int x = 0; x < originBitmap.Width; x++)
                {
                    pixel[y, x] = (UInt32)(originBitmap.GetPixel(x, y).ToArgb());
                }
            }

            pixel = Transform.MirrorX(pixel, originBitmap.Width, originBitmap.Height);
            for (int i = 0; i < originBitmap.Height; i++)
            {
                for (int j = 0; j < originBitmap.Width; j++)
                {
                    originBitmap.SetPixel(j, i, Color.FromArgb((int)pixel[i, j]));
                }
            }

            pictureBox1.Image = originBitmap;
        }
コード例 #24
0
        private void Initialize(char[] _key)
        {
            _P = new UInt32[18];
            _S = new UInt32[4, 256];

            UInt32 L = 0;
            UInt32 R = 0;

            try
            {
                for (int i = 0; i < 18; i++)
                {
                    _P[i] ^= _key[i % _key.Length];
                }

                for (int i = 0; i < 17; i++)
                {
                    encrypt(ref L, ref R);
                    _P[i]     = L;
                    _P[i + 1] = R;
                }
                for (int i = 0; i < 4; i++)
                {
                    for (int j = 0; j < 255; j++)
                    {
                        encrypt(ref L, ref R);
                        _S[i, j]     = L;
                        _S[i, j + 1] = R;
                    }
                }
            }
            catch (Exception ex) { throw; }
        }
コード例 #25
0
ファイル: Form1.cs プロジェクト: rvmzes/University
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         OpenFileDialog o = new OpenFileDialog();
         o.ShowDialog();
         Bitmap image = new Bitmap(o.FileName);
         pic.Size        = new System.Drawing.Size(640, 480);
         pic.SizeMode    = PictureBoxSizeMode.StretchImage;
         pic.BorderStyle = BorderStyle.Fixed3D;
         pic.Image       = image;
         pixel           = new UInt32[image.Height, image.Width];
         for (int y = 0; y < image.Height; y++)
         {
             for (int x = 0; x < image.Width; x++)
             {
                 pixel[y, x] = (UInt32)(image.GetPixel(x, y).ToArgb());
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #26
0
        public IActionResult UpdateColorImage(int blueRed, int purpleGreen, int yellowDarkBlue) //изменение цветового баланса
        {
            UInt32 p;

            image = new Bitmap(ActionPictureController.pathImage);


            //получение матрицы с пикселями
            pixel = new UInt32[image.Height, image.Width];
            for (int y = 0; y < image.Height; y++)
            {
                for (int x = 0; x < image.Width; x++)
                {
                    pixel[y, x] = (UInt32)(image.GetPixel(x, y).ToArgb());
                }
            }

            //цветовой баланс R
            for (int i = 0; i < image.Height; i++)
            {
                for (int j = 0; j < image.Width; j++)
                {
                    p = ColorBalance.ColorBalance_R(pixel[i, j], blueRed, 10);
                    FromOnePixelToBitmap(i, j, p);
                    pixel[i, j] = (UInt32)(image.GetPixel(j, i).ToArgb());
                }
            }

            //цветовой баланс G
            for (int i = 0; i < image.Height; i++)
            {
                for (int j = 0; j < image.Width; j++)
                {
                    p = ColorBalance.ColorBalance_G(pixel[i, j], purpleGreen, 10);
                    FromOnePixelToBitmap(i, j, p);
                    pixel[i, j] = (UInt32)(image.GetPixel(j, i).ToArgb());
                }
            }

            //цветовой баланс B
            for (int i = 0; i < image.Height; i++)
            {
                for (int j = 0; j < image.Width; j++)
                {
                    p = ColorBalance.ColorBalance_B(pixel[i, j], yellowDarkBlue, 10);
                    FromOnePixelToBitmap(i, j, p);
                    pixel[i, j] = (UInt32)(image.GetPixel(j, i).ToArgb());
                }
            }

            bitmapBytes = BitmapToBytes(image);
            image.Dispose();

            string imreBase64Data = Convert.ToBase64String(bitmapBytes);
            string imgDataURL     = string.Format("data:image/jpeg;base64,{0}", imreBase64Data);

            ViewBag.ImageData = imgDataURL;
            return(View("~/Views/Home/UpdateImage.cshtml"));
        }
コード例 #27
0
ファイル: DotWave.cs プロジェクト: jkulvich/DotWave
 /// <summary>
 /// Добавляет канал в конец списка каналов указанного аудио
 /// </summary>
 /// <param name="audio">Аудио</param>
 /// <param name="channel">Новый канал</param>
 /// <returns></returns>
 public static UInt32[,] AddChannel(UInt32[,] audio, UInt32[] channel)
 {
     object[] channels  = SplitAudio(audio);
     object[] nchannels = new object[channels.Length + 1];
     channels.CopyTo(nchannels, 0);
     nchannels[nchannels.Length - 1] = channel;
     return(MergeToAudio(channels));
 }
コード例 #28
0
ファイル: BlowfishContext.cs プロジェクト: synfron/FiSH
        /// <summary>
        /// Constructor via Key.
        /// </summary>
        public BlowfishContext(byte[] Key) : base()
        {
            sbox = new UInt32[4, 256];
            Array.Copy(BlowfishConstants.sbox, sbox, BlowfishConstants.sbox.Length);

            Schedule = new KeySchedule(Key);
            Setup();
        }
コード例 #29
0
 /// <summary>
 /// Encrypts the given Action Replay GBA code (multiple lines).
 /// </summary>
 /// <param name="code">
 /// The decrypted/raw AR code, code[0,x] is the address, code[1,x] the value.
 /// </param>
 public static void encrypt(ref UInt32[,] code) // code[0,x] -> address, code[1,x] -> value
 {
     deadface();                                // initialize encryption seeds with 0
     for (int x = 0; x < code.Length / 2; x++)
     {
         encrypt_code(ref code[x, 0], ref code[x, 1]);
     }
 }
コード例 #30
0
ファイル: DotWave.cs プロジェクト: jkulvich/DotWave
 /// <summary>
 /// Линейно понижает громкость аудио на всех каналах
 /// </summary>
 /// <param name="audio">Аудио</param>
 /// <returns></returns>
 public static UInt32[,] LinearSoundDown(UInt32[,] audio)
 {
     Object[] channels = SplitAudio(audio);
     for (int ch = 0; ch < channels.Length; ch++)
     {
         channels[ch] = LinearSoundDown((UInt32[])channels[ch]);
     }
     return(MergeToAudio(channels));
 }
コード例 #31
0
ファイル: Form1.cs プロジェクト: krasnovandr/Personal
 private void button1_Click(object sender, EventArgs e)
 {
     if (full_name_of_image != "\0")
     {
         pixel = defaultpixel;
         FromPixelToBitmap();
         FromBitmapToScreen();
     }
 }
コード例 #32
0
ファイル: Form1.cs プロジェクト: rvmzes/University
 private void rezk_Click(object sender, EventArgs e)
 {
     if (full_name_of_image != "\0")
     {
         pixel = Filter.matrix_filtration(image.Width, image.Height, pixel, Filter.N1, Filter.sharpness);
         FromPixelToBitmap();
         FromBitmapToScreen();
     }
 }
コード例 #33
0
ファイル: Form1.cs プロジェクト: krasnovandr/Personal
 private void наращиваниеToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (full_name_of_image != "\0")
     {
         pixel = Filter.MedianFiltration(image.Width, image.Height, pixel, filterMatrixSize, Filters.BuildUp);
         FromPixelToBitmap();
         FromBitmapToScreen();
     }
 }
コード例 #34
0
 //размыть
 private void размытьToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (full_name_of_image != "\0")
     {
         pixel = Filter.matrix_filtration(image.Width, image.Height, pixel, Filter.N2, Filter.blur);
         FromPixelToBitmap();
         FromBitmapToScreen();
     }
 }
コード例 #35
0
ファイル: ImageWindow.cs プロジェクト: Laendasill/APOBlabs
        // take Image from another ImageWindow
        public ImageWindow(ImageWindow iw)
        {
            InitializeComponent();
            MdiParent = iw.MdiParent;
            Picture.Image = iw.getBitmap();

            Text = iw.Text + " (" + iw.CopyNumber++.ToString() + ")";
            LUT = (UInt32[,])iw.LUT.Clone();
            Width = iw.Width;
            Height = iw.Height;
            Show();
        }
コード例 #36
0
ファイル: ImageWindow.cs プロジェクト: Laendasill/APOBlabs
        // new ImageWindow from bitmap
        public ImageWindow(MainWindow parent, Bitmap bmp, string name)
        {
            InitializeComponent();
            MdiParent = parent;
            Picture.Image = (Bitmap)bmp.Clone();
            Text = name;
            LUT = new UInt32[4, 256];
            updateLUT();
            Width = Picture.Image.Width;
            Height = Picture.Image.Height + 15;

            Show();
        }
コード例 #37
0
ファイル: ImageWindow.cs プロジェクト: Laendasill/APOBlabs
        private Bitmap PreviousImage = null; // image before last change

        #endregion Fields

        #region Constructors

        // take Image from filepath
        public ImageWindow(MainWindow parent, string fp)
        {
            InitializeComponent();
            MdiParent = parent;
            filepath = fp;
            Picture.Image = Image.FromFile(filepath);
            Text = System.IO.Path.GetFileName(filepath);
            LUT = new UInt32[4, 256];
            updateLUT();
            Width = Picture.Image.Width;
            Height = Picture.Image.Height+15;

            Show();
        }
コード例 #38
0
ファイル: Histogram.cs プロジェクト: quavepl/APOBlabs
        public Histogram(ImageWindow iw)
        {
            InitializeComponent();
            MdiParent = iw.MdiParent;
            Text = Text + " " + iw.Text;
            image = iw.getBitmap();
            HistogramImage.Image = new Bitmap(HistogramImage.Width, HistogramImage.Height);
            LUT = (UInt32[,])iw.LUT.Clone();

            max = 0;
            for (int i = 0; i < 256; i++)
            {
                if (LUT[0, i] > max) max = LUT[0, i];
                if (LUT[1, i] > max) max = LUT[1, i];
                if (LUT[2, i] > max) max = LUT[2, i];
                if (LUT[3, i] > max) max = LUT[3, i];
            }

            Histogram_ResizeEnd();
            Show();
        }
コード例 #39
0
ファイル: RayCaster.cs プロジェクト: metaldemon/MiniLD50
        public WallTexture(string file)
        {


            GL.BindTexture(TextureTarget.Texture2D, (GLTexture = GL.Utils.LoadImage(file, true)));

            GL.GetTexLevelParameter(TextureTarget.Texture2D, 0, GetTextureParameter.TextureWidth, out Width);
            GL.GetTexLevelParameter(TextureTarget.Texture2D, 0, GetTextureParameter.TextureHeight, out Height);

            bitMap = new Bitmap(file);

            Pixels = new UInt32[Width, Height];

            for (int x = 0; x < Width; ++x)
            {
                for (int y = 0; y < Height; ++y)
                {
                    Color c = bitMap.GetPixel(x, y);
                    Pixels[x, y] = UintFromColor(0, c.R, c.G, c.B);
                }
            }
        }
コード例 #40
0
ファイル: Terrain.cs プロジェクト: jaredwfowler/College
        //Methods----------------------------------------------------------------------------------------
        private void constructorInit()
        {
            //Allocate space for terrain height map
            range = (UInt32)stage.Range;
            width = height = range;
            terrainHeight = new UInt32[width, height];

            //Allocate space for vertices
            nVertices = width * height;
            vertex = new VertexPositionColor[nVertices];

            //Allocate space for indices
            nIndices = (width - 1) * (height - 1) * 6;
            indices = new UInt32[nIndices];

            //Get a copy of the spacing value from stage
            spacing = (UInt32)stage.Spacing;

            // set display information
            display = stage.Display;
            effect  = stage.SceneEffect;
        }
コード例 #41
0
 public Weeco4mGPIO()
 {
     regsStorage = new UInt32[REGSTORAGE_NUMOF_INDEX, REGSTORAGE_NUMOF_REGS];
     isConnected = Directory.Exists(GPIO_INOUT_PATH) && Directory.Exists(GPIO_LED_PATH);
     if (DEBUG_API)
     {
         isConnected = true;
         isDesktopEmulation = true;
     }
     if (isConnected)
     {
         myThread = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadSendData));
         myThread.Start();
     }
 }
コード例 #42
0
ファイル: Program.cs プロジェクト: CTurt/dsgmGfx
		static void Main(string[] args) {
			DateTime Time = DateTime.Now;

			string FileName = "PAGfx.ini";
			if(args.Length > 0) {
				FileName = args[0].Trim();
				Directory.SetCurrentDirectory(Path.GetDirectoryName(FileName));
			}

			Log = new FileStream("PAGfx.log", FileMode.Create); // Créé le fichier
			LogWriter = new BinaryWriter(Log);  // Permet d'écrire dedans

            PAGfxWrite("dsgmGfx fork of PAGfx Converter " + verstring + " -- originally by Mollusk & fincs\r\n");
            PAGfxWrite("customised by DSGM team\r\n");
            PAGfxWrite("http://www.dsgamemaker.com/\r\n\n");
#if VER_MONO
			PAGfxWrite("Mono version\r\n");
#endif

			PAGfxWrite(string.Format("Converting {0}\r\n", FileName));
			string res = LoadINI.IniParse(FileName);
			if(res != "") {
				PAGfxWrite("\n -> " + res + "\r\n\nPress any key to end the program");
				Console.ReadKey();
				return;
			}

			KeepPal = 0; // optimize palettes by default

			Palette = new PaletteStruct[10000]; // Memory alloc for palettes

			InitIncludeFile(); // Inits the all_gfx.h file

			PAGfxWrite("Transparent Color: " + LoadINI.TranspColor.Name + "\r\n");

			//Create Bin directory
			DirectoryInfo directory = new DirectoryInfo("bin");
			directory.Create();

			if(LoadINI.NSprites > 0) {
				StringInCH("Sprite");
				PAGfxWriteLine("\r\n" + LoadINI.NSprites + " sprites:");
				for(int i = 0; i < LoadINI.NSprites; i++) CreateSprite(i); // Create all the sprites !
			}

			if(LoadINI.NBackgrounds > 0) {
				TilesInfo = new UInt32[4, 256, 100000];

				NTilesInfo = new UInt32[4, 256];
				StringInCH("Background");
				PAGfxWriteLine("\r\n" + LoadINI.NBackgrounds + " backgrounds:");
				for(int i = 0; i < LoadINI.NBackgrounds; i++) CreateBg(i); // Create all the backgrouds !
			}
			if(LoadINI.NTextures > 0) {
				StringInCH("Sprite");
				PAGfxWriteLine("\r\n" + LoadINI.NTextures + " textures:");
				for(int i = 0; i < LoadINI.NTextures; i++) CreateTexture(i); // Create all the textures !
			}

			StringInCH("Palette");
			PAGfxWriteLine("\r\n" + NPalettes + " palettes:");
			WritePalettes(); // On écrit les palettes

			hwriter.Write(Encoding.UTF8.GetBytes(
				"\r\n" +
				"#ifdef __cplusplus\r\n" +
				"}\r\n" +
				"#endif\r\n"

				));

			DateTime Time2 = DateTime.Now;
			TimeSpan TotalTime = Time2.Subtract(Time);
			PAGfxWriteLine("\r\nConverted in " +
				TotalTime.Minutes + " minute" + (TotalTime.Minutes == 1 ? "" : "s") + 
				" and " + TotalTime.Seconds + " second" + (TotalTime.Seconds == 1 ? "" : "s"));

			PAGfxWriteLine("\r\nFinished!");
		}
コード例 #43
0
ファイル: Form1.cs プロジェクト: krasnovandr/Personal
 //Повышение резкости
 private void повыситьРезкостьToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (full_name_of_image != "\0")
     {
         pixel = Filter.matrix_filtration(image.Width, image.Height, pixel, Filter.N1, Filter.sharpness);
         FromPixelToBitmap();
         FromBitmapToScreen();
     }
 }
コード例 #44
0
ファイル: Form1.cs プロジェクト: krasnovandr/Personal
 //размыть
 private void размытьToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (full_name_of_image != "\0")
     {
         pixel = Filter.matrix_filtration(image.Width, image.Height, pixel, Filter.N2, Filter.blur);
         FromPixelToBitmap();
         FromBitmapToScreen();
     }
 }
コード例 #45
0
        public virtual Task<Image> Apply(Image image)
        {
            return Task.Run(() =>
            {
                var srcBitmap = (Bitmap)image;
                var resultBitmap = new Bitmap(image);

                pixel = new uint[srcBitmap.Height, srcBitmap.Width];
                for (int y = 0; y < srcBitmap.Height; y++)
                    for (int x = 0; x < srcBitmap.Width; x++)
                        pixel[y, x] = (UInt32)(srcBitmap.GetPixel(x, y).ToArgb());
                    newpixel = matrix_filtration(srcBitmap.Width, srcBitmap.Height, pixel, N1, sharpness);

                for (int y = 0; y < srcBitmap.Height; y++)
                    for (int x = 0; x < srcBitmap.Width; x++)
                        resultBitmap.SetPixel(x, y, Color.FromArgb((int)newpixel[y, x]));

                return (Image)resultBitmap;
            });
        }
コード例 #46
0
ファイル: MHSH.cs プロジェクト: salahmyn/galileovietnam
        /// <summary>
        /// Method that initialize the SBox and PBox.
        /// Client can use this method to reset the SBox and PBox.
        /// </summary>
        public void InitBoxes(byte[] key)
        {
            //.. Assign Key.
            Key = key.Clone() as byte[];

            //.. Initialize P-Box and four S-Boxes.
            P = _P.Clone() as UInt32[];
            S = _S.Clone() as UInt32[,];

            int i, j, k;
            UInt32 data = 0x00000000;

            //.. Assign elements of P-Box
            j = 0;
            for (i = 0; i < N + 2; ++i)
            {
                data = 0x00000000;
                //.. Get four bytes from Key array.
                for (k = 0; k < 4; ++k)
                {
                    data = (data << 8) | Key[j];
                    j = j + 1;
                    if (j >= Key.Length)
                    {
                        j = 0;
                    }
                }
                //.. be XORed and assign into P[i]
                P[i] = P[i] ^ data;
            }

            //... Generate subkey
            UInt32 bl = 0x0;
            UInt32 br = 0x0;
            for (i = 0; i < N + 2; i+=2)
            {
                Encipher(ref bl, ref br);
                P[i] = bl; P[i+1] = br;
            }
            for (int row = 0; row < 4; row++)
            {
                for (int col = 0; col < 256; col+=2)
                {
                    Encipher(ref bl, ref br);
                    S[row, col] = bl; S[row, col + 1] = br;
                }
            }
        }