0

I want to load an image file .tif (that image has many classes of colors to indicate the height) into my picture box, when I use load image 2D as normal, it is displayed as a black image.

private static Bitmap ResizeImage(Bitmap image, Size newSize)
{
    Bitmap newImage = new Bitmap(newSize.Width, newSize.Height);
    using (Graphics GFX = Graphics.FromImage((Bitmap)newImage))
    {
        GFX.DrawImage(image, new Rectangle(Point.Empty, newSize));
    }

    return newImage;
}

private void loadImage_Click(object sender, EventArgs e)
{
    OpenFileDialog opf = new OpenFileDialog();
    opf.Title = "Select Image";
    opf.Filter = "Image File (*.jpg; *.TIF; *.jpeg)| *.jpg; *.TIF; *.jpeg ";
    if (opf.ShowDialog()==DialogResult.OK)
    {
        Bitmap image = new Bitmap(opf.FileName);
        Image Image = ResizeImage(image, mapViewer.Size);
        mapViewer.Image = Image;
        Origin = Image;
        width = Origin.Width;
        height = Origin.Height;
    }        
}
CSDev
  • 3,177
  • 6
  • 19
  • 37
hieupro9x
  • 11
  • 1

0 Answers0