Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Lunaria · Feb 04, 2015 at 03:10 PM · texture2dimagecapture

How to save Texture2D to BMP?

Hello, Developers!

I'm doing project with capturing from webcam and printing image that captured by webcam.

Since there is no way to connect directly to printer and to print in Unity/C#, I divided this project to Unity/C# and C++.

So, I take Unity/C# part that is to capture image and save it in computer, my partner takes C++ part which is to open the saved image, and to print that image.

When we merged our works, I thought that is completely worked, but there is some problem. That is saving BMP.

In Unity, (as I know) there is no way to save image to BMP format.

Yes, there is to PNG, JPG. But C++ code is based in BMP. So, I converted it as below.

         ...
         Texture2D snap = new Texture2D(tex.width, tex.height,TextureFormat.RGB565, false);
 
         System.IO.File.WriteAllBytes(_SavePath + "Image" + ".png", snap.EncodeToPNG());
 
         byte[] saveBmp = snap.EncodeToPNG();
         System.IO.File.WriteAllBytes (_SavePath + "Image" + ".bmp", saveBmp); // the problem is here
         ...

Since Bitmap is composed of byte arrays, I thought it was right. But the C++ codes doesn't recognized that image as BMP. Of cource, it saved as .bmp, but it looks its REAL CONTENT isn't BMP but PNG format. So our project stoped here.

Is there a way to save Texture2D to BMP?

Thanks for reading 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
Best Answer

Answer by Graham-Dunnett · Feb 04, 2015 at 03:11 PM

No, Unity cannot create BMP files. If you need this, you will have to write code that can convert the PNG into a BMP.

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 Lunaria · Feb 23, 2015 at 09:11 AM 0
Share

Thanks Graham. There's no way to make directly B$$anonymous$$P, so I made it PNG and converted it to B$$anonymous$$P.

Sometimes, too perfect is too troublesome.

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

2 People are following this question.

avatar image avatar image

Related Questions

Scaling / Resizing an Image (Texture2D) 6 Answers

Image is not loading into Texture 0 Answers

Stop Texture2D Compression 0 Answers

Get multiple images from online server and download them to android app 1 Answer

Is there a technique that really works that allows you to change an image by modifying the Texture2D you have associated with it? 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