- Home /
Create JPG to HDD from Image In Assets-Folder
Merry Xmas folks,
I am working on a level editor and therefore I have certain Images to load from the Install-Directory [Standalone].
Each level has a preview-image that can be created during editing that is then stored in the Install-Directory. If it has no Image, a "NoImageAvailable"-Image is displaying.
However, if no level exists, the leveleditor-Script creates an example-level.
The example-level should have a pre-maked preview-image that represent the level-content. So an image that is in the Assets-Folder should be used.
How can I create an image to the Install-Directory from this Asset-Image?
I do not know if this approach will be working:
var exampleImage : Texture2D = Resources.Load("Levels/Example.jpg") as Texture2D;
var bytes = exampleImage.EncodeToJPG();
var fileImage = new File.Open(Application.dataPath+"/Resources/Levels/Example.jpg",FileMode.Create);
var binary = new BinaryWriter(fileImage);
binary.Write(bytes);
fileImage.Close();
Somehow it gives a NullReferenceExeption when initializing bytes although the exampleImage exists.
Your answer
Follow this Question
Related Questions
Access path of stored asset 0 Answers
How can I unload a single resource? 2 Answers
Create image-file from resources image 1 Answer
few questions about using www for getting bunch of images... 0 Answers
Edit FontSettings from script 0 Answers