Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by BigKnockDown · Apr 29, 2020 at 07:55 AM · imagewindowswindows store appwrite databytes

How do I write an Texture2D image to disk on WSA App ?

Hi Folks,

I have been trying to write an image(Texture2D) on a new file on disk on WSA Platform.

By following the Microsoft's documentation just as an sample and using a Plugin for File Picker I have been able to save a text file and also been able to write some text into it. https://docs.microsoft.com/en-us/windows/uwp/files/quickstart-reading-and-writing-files


That works fine. Now my main target is to write an image on a file (either a new file or an already existing one)

 fileData = screenShot.EncodeToPNG();
     Windows.Storage.StorageFolder storageFolder = Windows.Storage.KnownFolders.PicturesLibrary;
             string byteConvertedtoSting = fileData.ToString();
             Windows.Storage.StorageFile sampleFile = await storageFolder.CreateFileAsync(fileName, Windows.Storage.CreationCollisionOption.ReplaceExisting);
             Windows.Storage.StorageFile sampleFile1 = await storageFolder.GetFileAsync(fileName);
             var buffer = Windows.Security.Cryptography.CryptographicBuffer.CreateFromByteArray(fileData);
             await Windows.Storage.FileIO.WriteBufferAsync(sampleFile1, buffer);


By using this code I am able to create a .png file on disk, but unable to writes the Image bytes on the file. The file always shows the size of 0kb , as its simply empty.

Am I missing something in this or is ther any other way to do this ?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by dajohnso · Apr 29, 2020 at 07:21 PM

not 100% sure but it looks to me like you are trying to write data as a string and thats not going to work. Strings are a series of characters and behind the scene they terminate at the first 0 (null). You cant convert a BYTE series of data to characters so you must write them to the file as a series (blocks) of BYTEs

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image BigKnockDown · Apr 30, 2020 at 07:11 AM 0
Share

Actually I am using bytes to write the file, if you see the first line

  fileData = screenShot.EncodeToPNG();


I am using this fileData (bytes) to write on the file. I think this line of code Confused you, I am sorry about that

  string byteConvertedtoSting = fileData.ToString();

I forgot to remove this line while asking the question, this string is not used anywhere in the code.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

134 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Failing Builds 0 Answers

Convert System.IO to UnityEngine.Windows 1 Answer

Microsoft Surface Touch screen keyboard 2 Answers

Set maximum resolution in Windows 8.1 store app 0 Answers

Exception: "¥øú мãγ ʼnοţ ċâŀľ Ŵåïŧ₣οяЛεжţ₣řåмéΓĕǻđγ άġάĩņ üηţïľ уōц рřеšэⁿť ŷőΰŕ θĺðэşŧ õůţ-šťαήďíπģ ƒřämë" 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges