How to display .tif images via script?
I am currently working on opening different image files within unity. My script looks within folders for the images and then renders them to a Raw Image. PNG & JPEG images are easy to open using WWW;
public RawImage image;
OpenPNG("C:/Users/EJ/Pictures/FileBrowserFiles/dog.png");
public void OpenPNG(string path)
{
Debug.Log("Button surely was clicked: " + path );
WWW fileImg = new WWW("file:///" + path);
image.texture = fileImg .texture
}
However WWW only works with PNGs and JPEGs (as stated by unity docs) and I am currently trying to get .tif files to open in a similar way and I have hit many walls. This script does reach the tif files but is presented with a red question mark (as stated it would in the docs). I am having no luck in showing these images. Does anyone have any suggestions or solutions to this?
Answer by kstreicher · Aug 05, 2018 at 07:40 PM
Looking for a platform independent solution myself. On windows you can use System.Drawing to convert the tif.
var img = System.Drawing.Image.FromFile(path.tif);
img.Save(path.jpg,ImageFormat.Jpeg);
Your answer
Follow this Question
Related Questions
How to Download file (Texture) in runtime and use it in script? 0 Answers
How to make a PNG Image Sequence into an Animated Texture? 0 Answers
AudioSource not working. Empty Exception 1 Answer
Associating File Types with a Unity App 1 Answer
Can unity ignore file formats such as png, jpg, or gif? 0 Answers