Exemple #1
0
        private void BttnMinus_Click(object sender, EventArgs e)
        {
            byte[] clipedImage;
            imageStartIndex.X -= sizeClipedImage.Width / 4;
            imageStartIndex.Y -= sizeClipedImage.Height / 4;
            Int32 newwid = (int)(sizeClipedImage.Width * 1.2F);
            Int32 newhgt = (Int32)(sizeClipedImage.Height * 1.2F);

            if (newwid > gimda.Ncols)
            {
                newwid = gimda.Ncols;
            }
            if (newhgt > gimda.Nrows)
            {
                newhgt = gimda.Nrows;
            }
            sizeClipedImage = new Size((int)(newwid), (int)(newhgt));
            if (imageStartIndex.X < 0)
            {
                imageStartIndex.X = 0;
            }
            if (imageStartIndex.Y < 0)
            {
                imageStartIndex.Y = 0;
            }
            if (imageStartIndex.X > gimda.Ncols - sizeClipedImage.Width)
            {
                imageStartIndex.X = gimda.Ncols - sizeClipedImage.Width;
            }
            if (imageStartIndex.Y > gimda.Nrows - sizeClipedImage.Height)
            {
                imageStartIndex.Y = gimda.Nrows - sizeClipedImage.Height;
            }
            if (!flagRGB)
            {
                clipedImage = ClipImage(imageIn, imageStartIndex, sizeClipedImage, gimda.Ncols, gimda.Nrows);
                GeoImageTools gt = new GeoImageTools(gimda);
                pb.Image    = gt.convertOneBandBytesto8bitBitmap(clipedImage, sizeClipedImage.Width, sizeClipedImage.Height, colorPal);
                actualImage = clipedImage;
                spectrum.Hide();
                tsbttnSpectrum.Checked = false;
                bttnPlus.Checked       = true;
            }

            else
            {
                ZoomOutImageRGB(imageStartIndex, sizeClipedImage, gimda.Ncols, gimda.Nrows);
                GeoMultiBandMethods gmb = new GeoMultiBandMethods();
                pb.Image = gmb.createRGB_gwr(sizeClipedImage, actualiminRed, actualiminGreen, actualiminBlue);
            }
            width  = sizeClipedImage.Width;
            height = sizeClipedImage.Height;
        }
Exemple #2
0
        public void DrawImageDDM(GeoImageData gida, byte[] image, float[,] elevation, int[] colp)  // drawing 8bits color palette image to picture box, which contains elevation based grey scale
        {
            elev = elevation;
            Clear(gida);
            this.Enabled = true;
            flagRGB      = false;
            gimda        = gida;
            GeoImageTools gt = new GeoImageTools(gimda);

            width            = gimda.Ncols;
            height           = gimda.Nrows;
            imageAspect      = (float)width / height;
            imageIn          = image;
            actualImage      = image;
            pb.Image         = gt.convertOneBandBytesto8bitBitmap(image, width, height, colp);
            colorPal         = colp;
            bttnPlus.Checked = true;
            bttnPan.Checked  = false;
            pb.Cursor        = Cursors.Default;
        }
Exemple #3
0
        public void DrawImage(GeoImageData gida, byte[] image, Int32[] colp) //  drawing 8bits color palette image to picture box
        {
            Clear(gida);
            this.Enabled = true;
            flagRGB      = false;
            gimda        = gida;
            GeoImageTools gt = new GeoImageTools(gimda);

            width       = gimda.Ncols;
            height      = gimda.Nrows;
            imageAspect = (float)width / height;
            imageIn     = image;
            //imIn2D = Onedim2dim(imageIn, width, height);
            actualImage      = image;
            pb.Image         = gt.convertOneBandBytesto8bitBitmap(image, width, height, colp);
            colorPal         = colp;
            bttnPlus.Checked = true;
            bttnPan.Checked  = false;
            pb.Cursor        = Cursors.Default;
        }
Exemple #4
0
 private void Pb_MouseUp(object sender, MouseEventArgs e)
 {
     //if (tsbttnSpectrum.Checked) return;
     byte[] clipedImage;
     if (tsbttnSpectrum.Checked)
     {
         Point loc = TranslateZoomMousePosition(e.Location, pb.Image);
         Point cur = new Point(imageStartIndex.X + loc.X, imageStartIndex.Y + loc.Y);
         if (((cur.X < 0) || (cur.Y < 0)) || ((cur.X > gimda.Ncols - 1) || (cur.Y > gimda.Nrows - 1)))
         {
             return;
         }
         Int32 bytePos = width * cur.Y + cur.X;
         spec = new Point[gimda.Nbands];
         createSpectrum(bytePos);
         spectrum.displaySpectrum(spec, gimda.Wavelength);
         spectrum.showSpectrumAsTable(spec, gimda.Wavelength);
         this.Focus();
         drawRectangleBool = false;
         return;
     }
     if (bttnPlus.Checked)   // if zoom in mode is active
     {
         drawRectangleBool = false;
         startPosImage     = TranslateZoomMousePosition(new Point(startx, starty), pb.Image); // compute start position in the image
         endPosImage       = TranslateZoomMousePosition(e.Location, pb.Image);                // compute end position in the image
         if (startPosImage.X == endPosImage.X || startPosImage.Y == endPosImage.Y)
         {
             return;
         }
         Int32 tmp = 0;;
         if (startPosImage.X > endPosImage.X)
         {
             tmp             = startPosImage.X;
             startPosImage.X = endPosImage.X;
             endPosImage.X   = tmp;
         }
         tmp = 0;
         if (startPosImage.Y > endPosImage.Y)
         {
             tmp             = startPosImage.Y;
             startPosImage.Y = endPosImage.Y;
             endPosImage.Y   = tmp;
         }
         float clipedImageAspect = (int)((float)(startPosImage.X - endPosImage.X) / (float)(startPosImage.Y - endPosImage.Y));
         if (clipedImageAspect >= controlAspect)
         {
             sizeClipedImage = new Size((int)(float)((endPosImage.Y - startPosImage.Y) * controlAspect), endPosImage.Y - startPosImage.Y);
         }
         else
         {
             sizeClipedImage = new Size((int)(endPosImage.X - startPosImage.X), (int)(float)((endPosImage.X - startPosImage.X) / controlAspect + 0.5F));
         }
         sizeClipedImage.Width = 20 * ((sizeClipedImage.Width + 10) / 20);
         if (startPosImage.X + sizeClipedImage.Width > width)
         {
             startPosImage.X = width - sizeClipedImage.Width;
         }
         if (startPosImage.Y + sizeClipedImage.Height > height)
         {
             startPosImage.Y = height - sizeClipedImage.Height;
         }
         if (!flagRGB)  // if we are drawing a single band image
         {
             if (sizeClipedImage.Width <= 0 || sizeClipedImage.Height <= 0)
             {
                 MessageBox.Show("Too small window to display"); return;
             }
             clipedImage = ClipImage(actualImage, startPosImage, sizeClipedImage, width, height);
             GeoImageTools gt = new GeoImageTools(gimda);
             pb.Image    = gt.convertOneBandBytesto8bitBitmap(clipedImage, sizeClipedImage.Width, sizeClipedImage.Height, colorPal);
             actualImage = clipedImage;
         }
         else
         {
             //actualiminRed = ClipImage(actualiminRed, startPosImage, sizeClipedImage, width, height);
             //actualiminGreen = ClipImage(actualiminGreen, startPosImage, sizeClipedImage, width, height);
             //actualiminBlue = ClipImage(actualiminBlue, startPosImage, sizeClipedImage, width, height);
             //GeoMultiBandMethods gmb = new GeoMultiBandMethods();
             //pb.Image = gmb.createRGB_gwr(sizeClipedImage, actualiminRed, actualiminGreen, actualiminBlue);
         }
         width           = sizeClipedImage.Width;
         height          = sizeClipedImage.Height;
         imageStartIndex = new Point(imageStartIndex.X + startPosImage.X, imageStartIndex.Y + startPosImage.Y);
         bttnPan.Enabled = true;
     }
     if (bttnPan.Checked)  // if pan mode is active
     {
         sizeClipedImage.Width = 20 * ((sizeClipedImage.Width + 10) / 20);
         if ((width == gimda.Ncols) && (height == gimda.Nrows))
         {
             return;
         }
         drawRectangleBool = false;
         Point loc = TranslateZoomMousePosition(e.Location, pb.Image);
         Point cur = new Point(imageStartIndex.X + loc.X, imageStartIndex.Y + loc.Y);
         //lb1.Text = "Pan point in image: (X:" + cur.X + " Y:" + cur.Y + ")";
         imageStartIndex.X = cur.X - sizeClipedImage.Width / 2;
         if (imageStartIndex.X < 0)
         {
             imageStartIndex.X = 0;
         }
         if (imageStartIndex.X + sizeClipedImage.Width > gimda.Ncols)
         {
             imageStartIndex.X = gimda.Ncols - sizeClipedImage.Width;
         }
         imageStartIndex.Y = cur.Y - sizeClipedImage.Height / 2;
         if (imageStartIndex.Y < 0)
         {
             imageStartIndex.Y = 0;
         }
         if (imageStartIndex.Y + sizeClipedImage.Height > gimda.Nrows)
         {
             imageStartIndex.Y = gimda.Nrows - sizeClipedImage.Height;
         }
         if (!flagRGB) // if we are drawing a single band image
         {
             clipedImage = ClipImage(imageIn, imageStartIndex, sizeClipedImage, gimda.Ncols, gimda.Nrows);
             GeoImageTools gt = new GeoImageTools(gimda);
             pb.Image    = gt.convertOneBandBytesto8bitBitmap(clipedImage, sizeClipedImage.Width, sizeClipedImage.Height, colorPal);
             actualImage = clipedImage;
         }
         else// in case of RGB image
         {
             actualiminRed   = ClipImage(iminRed, imageStartIndex, sizeClipedImage, gimda.Ncols, gimda.Nrows);
             actualiminGreen = ClipImage(iminGreen, imageStartIndex, sizeClipedImage, gimda.Ncols, gimda.Nrows);
             actualiminBlue  = ClipImage(iminBlue, imageStartIndex, sizeClipedImage, gimda.Ncols, gimda.Nrows);
             GeoMultiBandMethods gmb = new GeoMultiBandMethods();
             pb.Image = gmb.createRGB_gwr(sizeClipedImage, actualiminRed, actualiminGreen, actualiminBlue);
         }
     }
 }