protected double regionWidth, regionHeight; //All lat long coordinates defining how large the 3d bitmap represents in actual space.

        #endregion Fields

        #region Constructors

        public SeismicCrossSectionGenerator()
        {
            bitmap3D = Bitmap3D.createBitmap3DFromSeismicDirectory();

            pixelFormat = bitmap3D.getPixelFormat();
            numxregions = (int)bitmap3D.getBitmap3dWidth();
            numyregions = (int)bitmap3D.getBitmap3dHeight();
            regionWidth = bitmap3D.getBitmap3dRegionWidth();
            regionHeight = bitmap3D.getBitmap3dRegionHeight();
            regionBottomLeftPoint = bitmap3D.getBitmap3dPointOffset();
        }
        public SeismicCrossSectionGenerator(Point botleftpoint, double regionw, double regionh, Bitmap3D createdBitmap3D)
        {
            this.bitmap3D = createdBitmap3D;

            pixelFormat = bitmap3D.getPixelFormat();
            numxregions = (int)bitmap3D.getBitmap3dWidth();
            numyregions = (int)bitmap3D.getBitmap3dHeight();
            regionBottomLeftPoint = botleftpoint;
            regionWidth = regionw;
            regionHeight = regionh;
        }
        public SeismicCrossSectionGenerator(Point botleftpoint, double regionw, double regionh, int numverticalregions, int numhorizontalregions, int depth, System.Windows.Media.PixelFormat pf)
        {
            pixelFormat = pf;
            regionBottomLeftPoint = botleftpoint;
            regionWidth = regionw;
            regionHeight = regionh;
            numxregions = numverticalregions;
            numyregions = numhorizontalregions;
            bitDepth = depth;

            bitmap3D = new Bitmap3D(numxregions, numyregions, bitDepth, pixelFormat);
        }
Example #4
0
        public static Bitmap3D createBitmap3DFromSeismicDirectory()
        {
            //Get info on the images
            //System.Drawing.Bitmap[] bitmaps = FileUtilities.getBitmapFromFolder();
            SeismicBitmapInfo[] bitmapInfos = FileUtilities.getBitmapsInfoFromDirectory();
            BitmapImage[] bitmaps = SeismicBitmapInfo.getBitmaps(bitmapInfos);
            if (bitmapInfos.Length == 0)
                return null;
            //System.Drawing.Size minSize = FileUtilities.getMinBitmapSize(bitmaps);
            Size minSize = FileUtilities.getMinBitmapImageSizeFromInfo(bitmapInfos);

            int bitDepth = (int)minSize.Height;
            int bitWidth = (int)minSize.Width;
            //int bitHeight = bitmaps.Length;
            int bitHeight = findHeightFromBitmaps(bitmapInfos);
            PixelFormat pf = bitmaps[0].Format;

            Bitmap3D seismicBitmap = new Bitmap3D(bitWidth, bitHeight, bitDepth, pf);

            //Fill in additional bitmap3d info from the bitmap infos
            seismicBitmap.initializeBitmapWithInfo(bitmapInfos);

            //add each line in order bottom up, this is already sorted by line number. fills bitmap bottom-up
            byte[][] imageBytes = new byte[bitmaps.Length][];
            int[] stride = new int[bitmaps.Length];

            for (int i = 0; i < bitmaps.Length; i++)
            {
                //Fills image specific variable - stride + fills image bytes with the image data
                //Change later when organizing lines.
                stride[i] = (int)(bitmaps[i].PixelWidth * pf.BitsPerPixel / 8);
                imageBytes[i] = new byte[(int)(bitmaps[i].PixelHeight * stride[i])];
                bitmaps[i].CopyPixels(imageBytes[i], stride[i], 0);
            }

            byte[] imagePixel = new byte[pf.BitsPerPixel / 8];
            int imagexoffset = 0, imageyoffset = 0;
            int imageselection = 0;
            int bitmapzoffset = 0;
            int bitmapyoffset = 0;

            //This is per pixel copying, which would be required for  different pixel formated images, unless you write some entire line pixel format converter. this works because of the conversion into color.
            //Color pixelColor = new Color();
            //for (int j = 0; j < bitHeight; j++)
            //{
            //    for (int i = 0; i < bitWidth; i++)
            //    {
            //        imagexoffset = i * pf.BitsPerPixel / 8;
            //        for (int k = 0; k < bitDepth; k++)
            //        {
            //            //Select which image
            //            imageselection = j % bitmaps.Length;

            //            imageyoffset = bitWidth * pf.BitsPerPixel / 8 * k;
            //            Array.Copy(imageBytes[imageselection], imagexoffset + imageyoffset, imagePixel, 0, pf.BitsPerPixel / 8);
            //            pixelColor = RawImageContainer.getColorFromPixel(imagePixel, pf);
            //            seismicBitmap.setPixel(i, j, k, pixelColor);
            //        }
            //   }
            //}

            //Per line copying - much faster. customize image selection variable for choosing which image to write to each line. currently uses modulus to make it alternate lines.
            //Wont work if there are more than one pixel format as you are array copying
            for (int j = 0; j < bitHeight; j++)
            {
                imageselection = seismicBitmap.selectImageIndexFromBitmapsAtHeight(bitmaps, j);
                bitmapyoffset = j * bitWidth * pf.BitsPerPixel / 8;
                for (int k = 0; k < bitDepth; k++)
                {
                    bitmapzoffset = k * bitWidth * bitHeight * pf.BitsPerPixel / 8;
                    imageyoffset = k * stride[imageselection];
                    Array.Copy(imageBytes[imageselection], imageyoffset, seismicBitmap.pixelData, bitmapzoffset + bitmapyoffset, bitWidth * pf.BitsPerPixel / 8);
                }

            }
            return seismicBitmap;
        }