void recoverBands(string minmax) // minmax = minx; miny; maxx; maxy; minindex; maxindex { GeoImageTools gt = new GeoImageTools(gimda); GeoImageData gdOut = new GeoImageData(); gdOut = gimda; int widorig = gimda.Ncols; int hgtorig = gimda.Nrows; byte[] byin = new byte[widorig * hgtorig]; int maxindex = Convert.ToInt16(minmax.Split(';')[5]); int minindex = Convert.ToInt16(minmax.Split(';')[4]); int a = Math.Abs(Convert.ToInt16(shifts[minindex].Split(';')[0])); // get minx value from the shifts list int b = Math.Abs(Convert.ToInt16(shifts[maxindex].Split(';')[0])); // get maxx value from the shifts list int newwid = widorig - (a + b); int c = Math.Abs(Convert.ToInt16(shifts[minindex].Split(';')[1])); // get miny value from the shifts list int d = Math.Abs(Convert.ToInt16(shifts[maxindex].Split(';')[1])); // get maxy value from the shifts list int newhgt = hgtorig - (c + d); gdOut.Ncols = newwid; gdOut.Nrows = newhgt; gdOut.Nbits = 8; Size commonSize = new Size(newwid, newhgt); string fn = Path.GetDirectoryName(gimda.FileName) + "\\" + Path.GetFileNameWithoutExtension(gimda.FileName) + "_aligned.gwh"; GeoImageTools gtsave = new GeoImageTools(gdOut); gtsave.saveHeader2Giwer(fn); gdOut.FileName = fn; gtsave.saveHeader2Giwer(fn); for (int i = 0; i < lstFiles.Items.Count; i++) { int px = Math.Abs(Convert.ToInt16(shifts[i].Split(';')[0])); int py = Math.Abs(Convert.ToInt16(shifts[i].Split(';')[1])); //int px = Convert.ToInt16(shifts[maxindex].Split(';')[0]) - Convert.ToInt16(shifts[i].Split(';')[0]); //int py = Convert.ToInt16(shifts[maxindex].Split(';')[1]) - Convert.ToInt16(shifts[i].Split(';')[1]); Point startp = new Point(px, py); string fname = currentFolder + "\\" + lstFiles.Items[i].ToString().Split('_')[1] + ".gwr"; byin = gtsave.readGwrFile(fname); byte[] byOut = ClipImage(byin, startp, commonSize, widorig, hgtorig); string dirname = Path.GetDirectoryName(gdOut.FileName) + "\\" + Path.GetFileNameWithoutExtension(gdOut.FileName); gt.saveGivenBand2GiwerFormat(dirname, byOut, i, ""); } }
private void EditHeader_FormClosed(object sender, FormClosedEventArgs e) { GeoImageTools gtool = new GeoImageTools(gimData); gtool.saveHeader2Giwer(gimData.FileName); }