Ejemplo n.º 1
0
        /**
         * Reads the ibw. base file and extracts the raw data
         * @param file_name file path of the base .ibw file
         * @return true if successful
         **/
        private bool readSliverIBWFile(string file_name)
        {
            IntPtr ptr;
            int    num_layers = NativeCalls.GetNumberOfLayers(file_name);

            if (!button_baseload.Enabled)
            {
                if (base_dimensions[2] != num_layers)
                {
                    return(false);
                }
                for (int i = 0; i < num_layers; ++i)
                {
                    ptr = NativeCalls.GetLayerName(file_name, i);
                    string name = Marshal.PtrToStringAnsi(ptr);
                    NativeCalls.ReleaseMemory(ptr);
                    if (dropdown_imageLayer.Items.IndexOf(name) != i)
                    {
                        return(false);
                    }
                }

                sliver_dimensions = new int[3];
                ptr = NativeCalls.GetDimensions(file_name);
                Marshal.Copy(ptr, sliver_dimensions, 0, 3);
                NativeCalls.ReleaseMemory(ptr);

                if (base_dimensions[0] < sliver_dimensions[0] || base_dimensions[1] < sliver_dimensions[1])
                {
                    sliver_dimensions = null;
                    return(false);
                }
                if (!(base_dimensions[0] == sliver_dimensions[0] ^ base_dimensions[1] == sliver_dimensions[1]))
                {
                    sliver_dimensions = null;
                    return(false);
                }

                int xyMult  = sliver_dimensions[0] * sliver_dimensions[1];
                int dimMult = xyMult * sliver_dimensions[2];
                sliver_data = new float[dimMult];
                ptr         = NativeCalls.GetRawData(file_name, ( uint )dimMult);
                Marshal.Copy(ptr, sliver_data, 0, dimMult);
                NativeCalls.ReleaseMemory(ptr);
                return(true);
            }
            else
            {
                dropdown_imageLayer.Items.Clear();
                checkedList_layers.Items.Clear();
                for (int i = 0; i < num_layers; ++i)
                {
                    ptr = NativeCalls.GetLayerName(file_name, i);
                    string name = Marshal.PtrToStringAnsi(ptr);
                    NativeCalls.ReleaseMemory(ptr);
                    dropdown_imageLayer.Items.Insert(i, name);
                    checkedList_layers.Items.Insert(i, name);
                }

                sliver_dimensions = new int[3];
                ptr = NativeCalls.GetDimensions(file_name);
                Marshal.Copy(ptr, sliver_dimensions, 0, 3);
                NativeCalls.ReleaseMemory(ptr);
                int xyMult  = sliver_dimensions[0] * sliver_dimensions[1];
                int dimMult = xyMult * sliver_dimensions[2];
                sliver_data = new float[dimMult];
                ptr         = NativeCalls.GetRawData(file_name, ( uint )dimMult);
                Marshal.Copy(ptr, sliver_data, 0, dimMult);
                NativeCalls.ReleaseMemory(ptr);
                return(true);
            }
        }
Ejemplo n.º 2
0
        /**
         * Output .ibw file of the base image with selected layers corrected
         **/
        private void outputIBWBase()
        {
            int dimMult = base_dimensions[0] * base_dimensions[1] * base_dimensions[2];

            NativeCalls.SetRawData(base_name + ".ibw", (uint)dimMult, base_data);
        }