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 uryokesh · Nov 25, 2015 at 08:48 PM · runtimeruntime-generationbitmap

Creating bitmap texture2d during runtime

Hey All,

I have a need that my image will be downloaded to the application during runtime outside of the Application.dataPath (Assets folder) in bmp format. Using which I need to create my texture2D during run time. I am able to do this if the image is a png or jpg but not for a bitmap image. I am restricted to the fact that this image is going to be of bitmap format.

For JPG or Png I am able to create runtime texture2D using the following code

         CreateRunTimeTexture(string fileName)
         {
             byte[] pngBytes = System.IO.File.ReadAllBytes(fileName);
             Texture2D pngTexture = new Texture2D(74, 74, TextureFormat.RGB24, false);
             pngTexture.LoadImage(pngBytes);
         }

Since UnityEditor is able to handle bitmap images I believe what am trying to do is possible. Any help is much appreciated.

Code example pointed above is to show how am doing for png/jpg. If bitmap needs to be done through someother fashion thats is fine. Currently am not able to process the bitmap bytes properly to achieve the result I am looking for.

One hack suggested to me was to use a program during runtime to convert bmp to png and then load them in to texture and then delete the png. I am able to do this but if bmp could be directly loaded it would be great.

Comment
Add comment · Show 2
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 gjf · Nov 24, 2015 at 08:28 PM 0
Share

LoadImage only reads png/jpg

avatar image uryokesh gjf · Nov 24, 2015 at 09:40 PM 0
Share

Sorry for not being clear. Code example is to show how am currently doing. Even if not with LoadImage if there is another way to accomplish what am trying to do would be great. Google search as well as searching in unity forums for this is not fruitful till now. Think am missing something. Unity Editor is able to handle bitmap so assu$$anonymous$$g they are formating the bitmap bytes in some fashion while reading to get this right. Either unity people or people who have done this before might be able to point some fundamental thing which am missing while doing this.

0 Replies

· Add your reply
  • Sort: 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Modifying an heightmap at runtime 2 Answers

Gradual Terrain Smoothing from a Flat Area (at Runtime) 0 Answers

what is the best way to implement minigames into my own full blown unity game. 0 Answers

How to create road or buildings during running the game 2 Answers

How to refresh rigidbody colliders modified at runtime 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