Bitmap createRGB_bil() // create rgb from a bil file { this.Cursor = Cursors.WaitCursor; Bitmap bmp = new Bitmap(imgDat.Ncols, imgDat.Nrows, PixelFormat.Format24bppRgb); int res = (imgDat.Ncols) % 4; int stride = (imgDat.Ncols + res) * 3; byte[] byOut = new byte[stride * imgDat.Nrows]; Int32 ind = 0; red = imgTools.getOneBandBytes(Convert.ToInt16(cmbRed.SelectedItem)); green = imgTools.getOneBandBytes(Convert.ToInt16(cmbGreen.SelectedItem)); blue = imgTools.getOneBandBytes(Convert.ToInt16(cmbBlue.SelectedItem)); for (int i = 0; i < imgDat.Nrows; i++) { for (int j = 0; j < imgDat.Ncols; j++) { byte redb = red[i * imgDat.Ncols + j]; byte greenb = green[i * imgDat.Ncols + j]; byte blueb = blue[i * imgDat.Ncols + j]; byOut[ind] = blueb; ind++; byOut[ind] = greenb; ind++; byOut[ind] = redb; ind++; } ind += res; } bmp = imgTools.ByteArrayToBitmap(byOut, imgDat.Ncols, imgDat.Nrows); this.Cursor = Cursors.Default; return(bmp); }
public Bitmap createRGB_gwr(GeoImageData imgDat, byte[] red, byte[] green, byte[] blue) { Bitmap bmp = new Bitmap(imgDat.Ncols, imgDat.Nrows, PixelFormat.Format24bppRgb); int res = (imgDat.Ncols) % 4; //Math.DivRem(4 - res, 4, out res); int stride = (imgDat.Ncols + res) * 3; byte[] byOut = new byte[stride * imgDat.Nrows]; Int32 ind = 0; for (int i = 0; i < imgDat.Nrows; i++) { for (int j = 0; j < imgDat.Ncols; j++) { byte redb = red[i * imgDat.Ncols + j]; byte greenb = green[i * imgDat.Ncols + j]; byte blueb = blue[i * imgDat.Ncols + j]; byOut[ind] = blueb; ind++; byOut[ind] = greenb; ind++; byOut[ind] = redb; ind++; } ind += res; } GeoImageTools imgTools = new GeoImageTools(imgDat); bmp = imgTools.ByteArrayToBitmap(byOut, imgDat.Ncols, imgDat.Nrows); return(bmp); }
public Bitmap createRGB_gwr(Size ncolnrows, byte[] red, byte[] green, byte[] blue) { Bitmap bmp = new Bitmap(ncolnrows.Width, ncolnrows.Height, PixelFormat.Format24bppRgb); int res = (ncolnrows.Width) % 4; //Math.DivRem(4 - res, 4, out res); int stride = (ncolnrows.Width + res) * 3; byte[] byOut = new byte[stride * ncolnrows.Height]; Int32 ind = 0; for (int i = 0; i < ncolnrows.Height; i++) { ind += res; for (int j = 0; j < ncolnrows.Width; j++) { byte redb = red[i * ncolnrows.Width + j]; byte greenb = green[i * ncolnrows.Width + j]; byte blueb = blue[i * ncolnrows.Width + j]; byOut[ind] = blueb; ind++; byOut[ind] = greenb; ind++; byOut[ind] = redb; ind++; } } GeoImageTools imgTools = new GeoImageTools(); bmp = imgTools.ByteArrayToBitmap(byOut, ncolnrows.Width, ncolnrows.Height); return(bmp); }
public Bitmap getAnRGBBand(int whichBand) { string gwrFile = Path.GetDirectoryName(gida.FileName) + "\\" + Path.GetFileNameWithoutExtension(gida.FileName) + "\\" + whichBand + ".gwr"; byte[] byIn = File.ReadAllBytes(gwrFile); Bitmap bmp = new Bitmap(gida.Ncols, gida.Nrows, PixelFormat.Format24bppRgb); int res = (gida.Ncols) % 4; int Stride = (gida.Ncols + res) * 3; byte[] byOut = new byte[Stride * gida.Nrows]; Int32 ind = 0; byte redb = 0; byte greenb = 0; byte blueb = 0; for (int i = 0; i < gida.Nrows; i++) { for (int j = 0; j < gida.Ncols; j++) { if (whichBand == 0) { redb = byIn[i * gida.Ncols + j]; greenb = 0; blueb = 0; } if (whichBand == 1) { greenb = byIn[i * gida.Ncols + j]; redb = 0; blueb = 0; } if (whichBand == 2) { blueb = byIn[i * gida.Ncols + j]; redb = 0; greenb = 0; } byOut[ind] = blueb; ind++; byOut[ind] = greenb; ind++; byOut[ind] = redb; ind++; } ind += res; } GeoImageTools imgTools = new GeoImageTools(gida); bmp = imgTools.ByteArrayToBitmap(byOut, gida.Ncols, gida.Nrows); return(bmp); }