Re: Particle Effects And Bitmap Pixel Manipulation
Posted: 02 Mar 2017, 07:51
It's late but looking at the unity side involving texture2d I've come up with some code to test for tomorrow.
Code: Select all
private UnityEngine.Texture2D m_texture2d = null;
private Noesis.ImageBrush m_imageBrush = null;
/// <summary>
/// Important!
/// Texture has to be set as read only in order to manipulate pixels.
///
/// ---------------
/// Unity Inspector
/// ---------------
/// Texture Type: Advanced
/// Read / Write Enabled: Yes
///
/// </summary>
public void LoadGraphic()
{
m_texture2d =
(UnityEngine.Texture2D)UnityEngine.Resources.Load("Fire.png");
//ReadImageFromFile(@"D:\Work\Source Code\Unity\Marauders\Assets\Darren\Graphics\Raster\Texture\Fire.png");
m_imageBrush = new Noesis.ImageBrush();
m_imageBrush.ImageSource = (new Noesis.TextureSource(m_texture2d));
}
public void AlterPixels()
{
// TODO: Loop and change many pixels according to algorithm...
UnityEngine.Color color = new UnityEngine.Color(1.0f, 0.5f, 0.0f, 1.0f);
m_texture2d.SetPixel(0, 0, color);
// After looping, then apply changes.
m_texture2d.Apply();
}