I have created sort of a cross language Random Texture Generator using C# and Java to help design backgrounds for an iPhone app that I am designing. In short, my program first generates a random array of bytes to represent the texture in the Java portion, then the C# portion takes the bytes and creates a Bitmap which is saved to an image file (Jpeg,Png,etc). I have gotton my program to run perfectly except that when I save the Bitmap to a file it doesn’t save with an extension, So I can’t view the image after it is created. I have this line of code:
bitMap.Save("testImage", System.Drawing.Imaging.ImageFormat.Jpeg);
which should save the bitmap with a Jpeg extension, but it saves it with no extension. Could anyone help me with this conundrum?
If you’re saving the bitmap with a jpeg extension (.jpg or .jpeg), you need to match the file format to the file extension.
It seems you want to support multiple extensions. To do this, I’d use the following:
Where you create an extension based on the desired file format, then use that extension to save the file.