New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create TextureModel from Memory Pointer #1403
Comments
Currently you can convert your raw data into color4 array and create the texture model from the color4 array. |
It seems like this is the answer I am looking for but I cant get it to work. I am trying to use a bitmap to create an image on a mesh. My first aproach was to save the bitmap as a png file and pass the filename to the TextureModel wich worked fine but when i try to do it with the same bitmap in memory it does not work. How do I Get the albedomap TextureModel form a bitmap in memory? A draft.
These commented lines work if I use them
|
You are compressing your data to a PNG, which is not the raw color data anymore. |
I have a bitmap and want to use it directly. My first attempt was to pass the stream but the MeshNode ends up blank/invisible. This was my first attempt: |
|
using (var stream = new MemoryStream()) |
ah. I thought that the bitmap was stored in the meshnode.Material eaven after the stream closed. The plan waas to return a meshNode and in another function add that to : ViewportViewModel.GroupModel.AddNode(meshNode); Are you saying that the stream needs to be open until the ViewPort gets the mesh? |
Yes, it needs to be wait until it gets converted to a texture map. There is a setting to allow helix toolkit to automatically dispose the stream once done with it. You just need to use |
Tackar :) |
Usually i use following code to load and display images from file:
But now I have a situation where I get the image data uncompressed. I have an IntPtr to memory location, width and heigt in pixel, the PixelFormat and the stride. Is it possible to create a TextureModel from that data?
I found following example on how to do it in SharpDX from a WriteableBitmapSource. But I cannot find a way to get from Texture2D to HelixToolkit TextureModel.
The text was updated successfully, but these errors were encountered: