Beispiel #1
0
        private void dosyaAcBtn_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "YUV dosyası (*.yuv)|*.yuv";

            byte[] fileData;
            openFileDialog.ShowDialog();
            Form2 ayarlar = new Form2();

            ayarlar.ShowDialog();
            acilanDosya = true;
            video1      = new RGBVideo(ayarlar.video1);
            try
            {
                fileData = File.ReadAllBytes(openFileDialog.FileName);
            }
            catch (Exception ex)
            {
                MessageBox.Show("dosya okunamadı" + ex.Message, "Error", MessageBoxButtons.OK);
                return;
            }

            int width = video1.genislik, height = video1.yukseklik;

            video1            = RGBConvert.rgbDonustur(fileData, width, height, video1.Format);
            pictureBox1.Image = video1.Source[0];
        }
Beispiel #2
0
 public RGBVideo(RGBVideo nesne1)
 {
     Source    = nesne1.Source;
     Format    = nesne1.Format;
     Frame     = nesne1.Frame;
     genislik  = nesne1.genislik;
     yukseklik = nesne1.yukseklik;
 }
Beispiel #3
0
        private static RGBVideo yuv420Donustur(byte[] data, int genislik, int yukseklik)
        {
            int pixelSayisi = genislik * yukseklik,
                frame       = (data.Length * 2) / (pixelSayisi * 3),
                ySayisi     = pixelSayisi,
                uSayisi     = pixelSayisi / 4,
                vCount      = uSayisi,
                byteCount   = pixelSayisi * 3 / 2;
            RGBVideo video  = new RGBVideo(Form1.YUVFormat.YUV420, frame, genislik, yukseklik);

            byte[] rgbData = new byte[ySayisi * 3];
            for (int f = 0, j = 0; f < frame; f++, j = 0)
            {
                byte[] y = new byte[ySayisi], u = new byte[uSayisi], v = new byte[vCount];
                for (int p = 0, i = 0; p < ySayisi; p++)
                {
                    y[i++] = data[f * byteCount + j++];
                }

                for (int p = 0, i = 0; p < uSayisi; p++)
                {
                    u[i++] = data[f * byteCount + j++];
                }

                for (int p = 0, i = 0; p < vCount; p++)
                {
                    v[i++] = data[f * byteCount + j++];
                }

                for (int d = 0; d < ySayisi * 3; d++)
                {
                    rgbData[d] = y[d / 3];
                }


                Bitmap     bitmap     = new Bitmap(genislik, yukseklik, PixelFormat.Format24bppRgb);
                BitmapData bitmapData = bitmap.LockBits(
                    new Rectangle(0, 0, bitmap.Width, bitmap.Height),
                    ImageLockMode.WriteOnly, bitmap.PixelFormat);
                Marshal.Copy(rgbData, 0, bitmapData.Scan0, rgbData.Length);
                bitmap.UnlockBits(bitmapData);

                video.Source[f] = bitmap;
            }

            return(video);
        }
Beispiel #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            Form1.YUVFormat format = (comboBox1.SelectedItem.ToString() == "yuv444") ? Form1.YUVFormat.YUV444 : (comboBox1.SelectedItem.ToString() == "yuv422") ? Form1.YUVFormat.YUV422 : Form1.YUVFormat.YUV420;
            int             width = 0, height = 0;

            if (Int32.TryParse(textBox2.Text, out width))
            {
                MessageBox.Show("değer atama başarılı", "", MessageBoxButtons.OK);
            }
            if (!Int32.TryParse(textBox1.Text, out height))
            {
                MessageBox.Show("değer atama başarılı", "", MessageBoxButtons.OK);
            }

            video1 = new RGBVideo(format, width, height);
            this.Close();
        }