Beispiel #1
0
        public AdvImageSection(BinaryReader reader)
        {
            byte version = reader.ReadByte();

            if (version >= 1)
            {
                Width = reader.ReadUInt32();
                Height = reader.ReadUInt32();
                BitsPerPixel = reader.ReadByte();

                byte lyCnt = reader.ReadByte();
                for (int i = 0; i < lyCnt; i++)
                {
                    byte layoutId = reader.ReadByte();
                    var layout = new AdvImageLayout(this, layoutId, Width, Height, reader);
                    ImageLayouts.Add(layoutId, layout);
                }

                byte propCnt = reader.ReadByte();
                for (int i = 0; i < propCnt; i++)
                {
                    string propName = reader.ReadAsciiString256();
                    string propValue = reader.ReadAsciiString256();

                    ImageSerializationProperties.Add(propName, propValue);
                }

                InitSerializationProperties();
            }
        }
Beispiel #2
0
        public AdvImageSection(BinaryReader reader)
        {
            byte version = reader.ReadByte();

            if (version >= 1)
            {
                Width        = reader.ReadUInt32();
                Height       = reader.ReadUInt32();
                BitsPerPixel = reader.ReadByte();

                byte lyCnt = reader.ReadByte();
                for (int i = 0; i < lyCnt; i++)
                {
                    byte layoutId = reader.ReadByte();
                    var  layout   = new AdvImageLayout(this, layoutId, Width, Height, reader);
                    ImageLayouts.Add(layoutId, layout);
                }

                byte propCnt = reader.ReadByte();
                for (int i = 0; i < propCnt; i++)
                {
                    string propName  = reader.ReadAsciiString256();
                    string propValue = reader.ReadAsciiString256();

                    ImageSerializationProperties.Add(propName, propValue);
                }

                InitSerializationProperties();
            }
        }
Beispiel #3
0
        private void lvImageLayouts_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvImageLayouts.SelectedItems.Count == 1)
            {
                AdvImageLayout layout = (AdvImageLayout)lvImageLayouts.SelectedItems[0].Tag;

                var bindingList = new List <AdvTagValuePair>();
                foreach (string key in layout.ImageSerializationProperties.Keys)
                {
                    bindingList.Add(new AdvTagValuePair()
                    {
                        Tag = key, Value = layout.ImageSerializationProperties[key]
                    });
                }
                dgvLayoutTags.DataSource = bindingList;
            }
        }
Beispiel #4
0
        public object GetDataFromDataBytes(byte[] bytes, ushort[,] prevImageData, int size, int startIndex)
        {
            byte layoutId = bytes[startIndex];
            byte byteMode = bytes[startIndex + 1];

            startIndex += 2;
            size       -= 2;

            AdvImageLayout imageLayout = ImageLayouts[layoutId];

            AdvImageData rv = imageLayout.IsNoImageLayout
                                        ? new AdvImageData()
            {
                Bpp = 8, ImageData = new ushort[imageLayout.Width, imageLayout.Height], LayoutId = layoutId, ByteMode = AdvImageLayout.GetByteMode.Normal
            }
                                    : (AdvImageData)imageLayout.GetDataFromDataBytes(bytes, prevImageData, (AdvImageLayout.GetByteMode)byteMode, size, startIndex);

            rv.LayoutId             = layoutId;
            rv.ByteMode             = (AdvImageLayout.GetByteMode)byteMode;
            rv.DataBlocksBytesCount = size;

            return(rv);
        }
Beispiel #5
0
        public void GetFrameImageSectionHeader(int frameNo, out byte layoutId, out AdvImageLayout.GetByteMode byteMode)
        {
            AdvFramesIndexEntry idxEntry = m_Index.Index[frameNo];
            m_InputFile.Seek(idxEntry.Offset, SeekOrigin.Begin);

            uint frameDataMagic = m_FileReader.ReadUInt32();
            Trace.Assert(frameDataMagic == 0xEE0122FF);

            // 8 bytes timestamp + 4 bytes exposure + 4 bytes image section length
            m_InputFile.Seek(16, SeekOrigin.Current);

            layoutId = m_FileReader.ReadByte();
            byteMode = (AdvImageLayout.GetByteMode)m_FileReader.ReadByte();
        }
Beispiel #6
0
        internal Pixelmap GetFrameData(int index, out AdvImageData imageData, out AdvStatusData statusData, out Bitmap displayBitmap)
        {
            imageData = null;

            if (index < NumberOfFrames)
            {
                byte layoutId;
                AdvImageLayout.GetByteMode byteMode;

                GetFrameImageSectionHeader(index, out layoutId, out byteMode);

                AdvImageLayout layout = ImageSection.GetImageLayoutFromLayoutId(layoutId);

                if (layout.IsDiffCorrLayout && byteMode == AdvImageLayout.GetByteMode.DiffCorrBytes && prevFrameNo != index - 1)
                {
                    // Move back and find the nearest previous key frame
                    int keyFrameIdx = index;
                    do
                    {
                        keyFrameIdx--;
                        GetFrameImageSectionHeader(keyFrameIdx, out layoutId, out byteMode);
                    }while (keyFrameIdx > 0 && byteMode != AdvImageLayout.GetByteMode.KeyFrameBytes);

                    object[] keyFrameData = GetFrameSectionData(keyFrameIdx, null);
                    prevFramePixels = ((AdvImageData)keyFrameData[0]).ImageData;

                    if (layout.DiffCorrFrame == DiffCorrFrameMode.PrevFrame)
                    {
                        for (int i = keyFrameIdx + 1; i < index; i++)
                        {
                            object[] frameData = GetFrameSectionData(i, prevFramePixels);

                            prevFramePixels = ((AdvImageData)frameData[0]).ImageData;
                        }
                    }
                }

                object[] data;

                data = GetFrameSectionData(index, prevFramePixels);

                imageData  = (AdvImageData)data[0];
                statusData = (AdvStatusData)data[1];

                if (prevFramePixels == null)
                {
                    prevFramePixels = new ushort[ImageSection.Width, ImageSection.Height];
                }

                if (layout.IsDiffCorrLayout)
                {
                    for (int x = 0; x < ImageSection.Width; x++)
                    {
                        for (int y = 0; y < ImageSection.Height; y++)
                        {
                            prevFramePixels[x, y] = imageData.ImageData[x, y];
                        }
                    }
                }

                prevFrameNo = index;

                Pixelmap rv = ImageSection.CreatePixelmap(imageData);

                //Pixelmap rv = new Pixelmap((int)m_AdvFile.ImageSection.Width, (int)m_AdvFile.ImageSection.Height, m_AdvFile.ImageSection.BitsPerPixel, null, null, null);
                //rv.Width = (int) m_AdvFile.ImageSection.Width;
                //rv.Height = (int) m_AdvFile.ImageSection.Height;
                //rv.BitPixCamera = m_AdvFile.ImageSection.BitsPerPixel;
                //rv.Array = new uint[Width * Height];
                //rv.CopyPixelsFrom(imageData.ImageData, imageData.Bpp);
                //displayBitmap = PixelmapFactory.ConstructBitmapFrom12BitPixelmap(rv);

                displayBitmap = rv.DisplayBitmap;

                return(rv);
            }
            else
            {
                displayBitmap = null;
                statusData    = null;
                return(null);
            }
        }
Beispiel #7
0
        private void PresentFile()
        {
            lblFileName.Text     = m_FileName;
            lblNumberFrames.Text = m_AdvFile.NumberOfFrames.ToString();
            m_IsAavFile          = m_AdvFile.AdvFileTags["FSTF-TYPE"] == "AAV";

            var bindingList = new List <AdvTagValuePair>();

            foreach (string key in m_AdvFile.AdvFileTags.Keys)
            {
                bindingList.Add(new AdvTagValuePair()
                {
                    Tag = key, Value = m_AdvFile.AdvFileTags[key]
                });
            }
            dgvFileTags.DataSource = bindingList;

            lvImageLayouts.Items.Clear();
            foreach (byte layoutId in m_AdvFile.ImageSection.ImageLayouts.Keys)
            {
                AdvImageLayout layout = m_AdvFile.ImageSection.ImageLayouts[layoutId];

                ListViewItem li = lvImageLayouts.Items.Add(layoutId.ToString());
                li.SubItems.Add(layout.BitsPerPixel.ToString());
                li.SubItems.Add(layout.IsDiffCorrLayout ? "yes" : "no");
                li.Tag = layout;
            }
            if (lvImageLayouts.Items.Count > 0)
            {
                lvImageLayouts.Items[0].Selected = true;
            }


            lblWidth.Text  = m_AdvFile.ImageSection.Width.ToString();
            lblHeight.Text = m_AdvFile.ImageSection.Height.ToString();
            lblBpp.Text    = m_AdvFile.ImageSection.BitsPerPixel.ToString();

            var imageTagsList = new List <AdvTagValuePair>();

            foreach (string key in m_AdvFile.ImageSection.ImageSerializationProperties.Keys)
            {
                imageTagsList.Add(new AdvTagValuePair()
                {
                    Tag = key, Value = m_AdvFile.ImageSection.ImageSerializationProperties[key]
                });
            }
            dgvImageTags.DataSource = imageTagsList;

            lvStatusTags.Items.Clear();
            int idx = 0;

            foreach (AdvTagDefinition tagDef in m_AdvFile.StatusSection.TagDefinitions)
            {
                ListViewItem li = lvStatusTags.Items.Add(idx.ToString());
                li.SubItems.Add(tagDef.Name);
                li.SubItems.Add(tagDef.Type.ToString());
                li.Tag = tagDef;

                idx++;
            }

            sbFrames.Maximum          = (int)m_AdvFile.NumberOfFrames - 1;
            nudCropFirstFrame.Maximum = (int)m_AdvFile.NumberOfFrames - 1;
            nudCropFirstFrame.Value   = 0;
            nudCropLastFrame.Maximum  = (int)m_AdvFile.NumberOfFrames - 1;
            nudCropLastFrame.Value    = nudCropLastFrame.Maximum;

            nudAviFirstFrame.Maximum = (int)m_AdvFile.NumberOfFrames - 1;
            nudAviFirstFrame.Value   = 0;
            nudAviLastFrame.Maximum  = (int)m_AdvFile.NumberOfFrames - 1;
            nudAviLastFrame.Value    = nudAviFirstFrame.Maximum;

            nudCsvFirstFrame.Maximum = (int)m_AdvFile.NumberOfFrames - 1;
            nudCsvFirstFrame.Value   = 0;
            nudCsvLastFrame.Maximum  = (int)m_AdvFile.NumberOfFrames - 1;
            nudCsvLastFrame.Value    = nudCsvFirstFrame.Maximum;

            LoadFrame(0);

            gbxAdvSplit.Text     = m_IsAavFile ? "AAV Crop" : "ADV Crop";
            gbxConvertToAVI.Text = m_IsAavFile ? "AAV to AVI" : "ADV to AVI";
            gbxConvertToCSV.Text = m_IsAavFile ? "AAV to CSV (No video frames exported)" : "ADV to CSV (No video frames exported)";
            btnCropADV.Text      = m_IsAavFile ? "Save AAV chunk as ..." : "Save ADV chunk as ...";

            cbxFrameRate.SelectedIndex  = 0;
            cbxAddedGamma.SelectedIndex = 0;

#if !WIN32
            gbxConvertToAVI.Visible = false;
#endif
        }