Setting Pixel value in Q16 HDRI 7.4.5
Posted: 2018-06-27T01:29:58-07:00
Sorry if I am asking a question that has been asked before - I googled a lot and couldn't find anything on this.
I am trying to create some 32bpc images procedurally (for game development purposes). I tried few different approaches but it seems that no matter what pixel value I am setting, the resulting image is always black. My understanding of pixel collection is that it returns array of all channels (RGBA) which I can directly access and set value per channel. Sounds easy peasy but like I mentioned, resulting image is black.
I am trying to create some 32bpc images procedurally (for game development purposes). I tried few different approaches but it seems that no matter what pixel value I am setting, the resulting image is always black. My understanding of pixel collection is that it returns array of all channels (RGBA) which I can directly access and set value per channel. Sounds easy peasy but like I mentioned, resulting image is black.
Code: Select all
MagickColor startCol = new MagickColor();
startCol.R = 10f;
startCol.G = 2f;
startCol.B = 0.5f;
startCol.A = 1.0f;
MagickImage img = new MagickImage(startCol, 4, 4);
img.ColorSpace = ColorSpace.sRGB;
img.Format = MagickFormat.Tiff;
IPixelCollection pixels = img.GetPixels();
float[] colChannels= new float[pixels.Channels];
Console.WriteLine("colChannels length " + colChannels.Length); //returns 3
for (int i = 0; i < col.Length; i++)
{
colChannels[i] = 100f;
}
pixels.SetPixel(1, 1, colChannels);
Console.WriteLine(pixels.GetValue(1, 1)[0]); //returns 100.0f
Console.WriteLine(pixels.GetPixel(1, 1).ToColor().ToColor()); //returns RGBA 0;0;0;0
img.Write("asd.tiff"); //resulting image is black with alpha=0