I am developing a plugin for MapInfo and I have BMP image with all the prop and I have rectbounds. I have done through GDAL using the below solution. But I am not getting proper output which I am expecting. I am getting some extra white patches in my TAB tab after converstion. I believe this is happening because of GDAL.

This is my code:

            Bitmap bmp = CreateChartTIF(path);


            String wktProj = null;
            String tmpPath = @"E:\@@MapInfo_1\tmp.bmp";
            int a = Convert.ToInt16(rectBounds.Left);
            int b = Convert.ToInt16(rectBounds.Top);

            bmp.Save(tmpPath, ImageFormat.Bmp);
            System.IO.MemoryStream mem = new System.IO.MemoryStream();

            String[] options = null;
            OSGeo.GDAL.Driver srcDrv = Gdal.GetDriverByName("GTiff");
            Dataset srcDs = Gdal.Open(tmpPath, Access.GA_ReadOnly);
            Dataset dstDs = srcDrv.CreateCopy(@"E:\@@MapInfo_1\Output\2-0.tif", srcDs, 0, options, null, null);

            Osr.GetWellKnownGeogCSAsWKT("WGS84", out wktProj);

            double minx = rectBounds.Left;
            double miny = rectBounds.Bottom;

            double maxx = rectBounds.Right;
            double maxy = rectBounds.Top;

            double mapWidth = Math.Abs(minx - maxx);
            double mapHeight = Math.Abs(maxy - miny);

            double pixel1 = mapWidth / bmp.Width;
            double pixel2 = mapHeight / bmp.Height;

            //Top Left x, w-r pixel resln, 0, Top Letf y, 0, n-s pixel resln
            double[] geoTransfo = new double[] { minx, pixel1, 0, maxy, 0, pixel2 * (-1) }



            RasterProcessing.Convert(@"E:\@@MapInfo_1\Output\2-0.tif", "E:\\@@MapInfo_1\\Jonathan_Test.mrr", "MI_MRR");

Please find the screenshot below :

Screenshot of MapInfo

Any idea or any sample code? Is there any way to remove GDAL dependency and do this conversion using MapXtreme?

  • How do you know the rectBounds?
    – user30184
    Commented Aug 20, 2019 at 6:43
  • @user30184 my client has provided me the rectbonds of all the charts. Which are correct as this is working in ArcsGIS , Mechai and others.
    – Piyush
    Commented Aug 21, 2019 at 4:29

2 Answers 2


MapInfo .tab files are just text files; it is quite easy to create them yourself.

A .tab file for a registered image looks like this:

!version 300
!charset WindowsLatin1

Definition Table
  File "test.png"
  Type "RASTER"
  (10000,7500) (0,0) Label "top left",
  (20000,7500) (256,0) Label "top right",
  (10000,0) (0,192) Label "bottom left"
  CoordSys Earth Projection 8, 104, "m", -123, 0, 0.9996, 500000, 0
  Units "m"
  • CoordSys is the projection (here: WGS84 / UTM zone 10 north); look the numbers up in the mapinfow.prj file, or create a test .tab file with the correct projection.
    (With a lat/lon projection, you have Units "degree".)
  • The six pairs of numbers specify how to map image pixel coordinates to map coordinates. The first pair in each line are the X/Y map coordinates (usually, Y is bottom-to-top), the second pair are the pixel coordinates (Y top-to-bottom). Here, I have put the registration points at three image corners; the image size is 256×192 pixels, and the map coordinates are left:10000, right:20000, bottom:0, top:7500.
  • Thanks for the suggestion. I have changed driver ID from MI_MRR to MI_GeoTiff_IMG and my problem solved. Now there is no white patches.
    – Piyush
    Commented Aug 21, 2019 at 5:33
  • I have one more question why my map is changing when I am loading the charts. sometimes its height is getting big and sometime width. Have any idea ? How to control this
    – Piyush
    Commented Aug 21, 2019 at 5:34
  • That would be a different question.
    – CL.
    Commented Aug 21, 2019 at 6:13
  • I know that. But if you can help in this here itself
    – Piyush
    Commented Aug 21, 2019 at 6:24
  • 1
    Stack Exchange is not a forum; questions and answers are more useful for other people if they are actually entered as questions and answers. Please add MI_GeoTiff_IMG as an actual answer. Please read the tour, and any appropriate help pages.
    – CL.
    Commented Aug 21, 2019 at 7:39

I have solved this issue by changing the driver string which is :

RasterProcessing.Convert(@"E:\@@MapInfo_1\Output\2-0.tif", "E:\\@@MapInfo_1\\Jonathan_Test.tif", "MI_GeoTiff_IMG");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.