Load image file which is changed the filename extension

Hi @Jesse,

can it bee that your sample program is targetting 64bit Windows but the Visual Studio configuration setting is AnyCPU and the Prefer32Bit option is checked? In that case you will get all the problems mentioned in several articles here regarding a mix of 32bit and 64bit runtimes such as here or here.

This code here works fine having a x64 configuration or having the Prefer32Bit option disabled:

private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                string ext = "bmp";
                using (var image = Stemmer.Cvb.Image.FromFile("C:\\cvb\\tutorial\\clara." + ext))
                {
                    Console.WriteLine("Writing *." + ext);
                    image.Save("C:\\cvb\\Myclara." + ext);
                    ext = "png";
                    Console.WriteLine("Writing *." + ext);
                    image.Save("C:\\cvb\\Myclara." + ext);
                    ext = "tif";
                    Console.WriteLine("Writing *." + ext);
                    image.Save("C:\\cvb\\Myclara." + ext);
                    ext = "jpeg";
                    Console.WriteLine("Writing *." + ext);
                    image.Save("C:\\cvb\\Myclara." + ext);
                    ext = "jpg";
                    Console.WriteLine("Writing *." + ext);
                    image.Save("C:\\cvb\\Myclara." + ext);
                }
                Console.WriteLine("Finished");
            }
            catch (IOException ex)
            {
                Console.WriteLine(ex);
            }
        }

In more detail: Bitmaps and TIFs (and all of its high-bit versions) are written by the CVCImg.DLL. Other formats such as PNG, TGA, JPEG, JPEG2000 etc. are implemented in the CVCFile.DLL which makes use of OpenSource libraries. The loading of the CVCFile.DLL fails in case of the 32/64 bit mismatch.

kind regards,
Martin

1 Like