Exemplo n.º 1
0
        public void _ExportAdobeConverted(oMatrix input, string filename)
        {
            int         width   = input.Width();
            int         height  = input.Height();
            List <byte> rawdata = new List <byte>();

            for (int yyy = 0; yyy < height; yyy++)
            {
                for (int xxx = 0; xxx < width; xxx++)
                {
                    rawdata.Add(Convert.ToByte((Convert.ToInt32(input.GetValue(xxx, yyy))) % 256));
                    rawdata.Add(Convert.ToByte((Convert.ToInt32(input.GetValue(xxx, yyy))) / 256));
                }
            }

            byte[] output = rawdata.ToArray();

            using (BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open)))
            {
                int    filelength = (int)(new System.IO.FileInfo(filename).Length);
                int    datalength = rawdata.Count;
                int    start_addr = filelength - datalength;
                byte[] bytebuffer = reader.ReadBytes(filelength);
                Console.WriteLine();
                for (int i = start_addr; i < filelength; i++)
                {
                    bytebuffer[i] = output[i - start_addr];
                }
                Console.WriteLine();
                _byteArrayWriter(bytebuffer, filename, "_corrected");
                Console.WriteLine();
            }
        }
Exemplo n.º 2
0
        public void _ExportRawDataTiff(oMatrix input, string filename)
        {
            int width  = input.Width();
            int height = input.Height();

            using (Tiff output = Tiff.Open(@filename, "w"))
            {
                output.SetField(TiffTag.IMAGEWIDTH, width);
                output.SetField(TiffTag.IMAGELENGTH, height);
                output.SetField(TiffTag.SAMPLESPERPIXEL, 1);
                output.SetField(TiffTag.BITSPERSAMPLE, 16);
                output.SetField(TiffTag.ORIENTATION, BitMiracle.LibTiff.Classic.Orientation.TOPLEFT);
                output.SetField(TiffTag.XRESOLUTION, 72);
                output.SetField(TiffTag.YRESOLUTION, 72);
                output.SetField(TiffTag.RESOLUTIONUNIT, ResUnit.CENTIMETER);
                output.SetField(TiffTag.PLANARCONFIG, PlanarConfig.CONTIG);
                output.SetField(TiffTag.PHOTOMETRIC, Photometric.MINISBLACK);
                output.SetField(TiffTag.COMPRESSION, Compression.LZW);
                output.SetField(TiffTag.ROWSPERSTRIP, height);
                output.SetField(TiffTag.FILLORDER, FillOrder.MSB2LSB);
                byte[] bytebuffer = new byte[width * 16 / 8];
                double rawValue;
                for (int yyy = 0; yyy < height; yyy++)
                {
                    for (int xxx = 0; xxx < width; xxx++)
                    {
                        rawValue                   = input.GetValue(xxx, yyy);
                        bytebuffer[xxx << 1]       = (byte)(rawValue % 256);
                        bytebuffer[(xxx << 1) + 1] = (byte)(rawValue / 256);
                    }
                    output.WriteScanline(bytebuffer, yyy);
                }
            }
        }
Exemplo n.º 3
0
        public void _ExportFPM(oMatrix input, string filename)
        {
            StringBuilder sb = new StringBuilder();
            int           temp;
            int           height = input.Height();
            int           width  = input.Width();

            for (int yyy = 0; yyy < height; yyy++)
            {
                for (int xxx = 0; xxx < width; xxx++)
                {
                    temp = input.GetValue(xxx, yyy);
                    if (temp <= 0)
                    {
                        sb.Append(xxx + " \t " + yyy + "\n");
                    }
                }
            }
            System.IO.File.WriteAllText(@filename, sb.ToString());
        }