protected void WriteImageTexture()
    {
        //the size of the target data
        int i = XRes * YRes - 1;

        MapData <RGB24Pixel> imageData = m_imageMetaDate.GetRGB24ImageMap();
        Color colorElement             = Color.black; //for initialization

        //loop over the target arry(x and y)
        for (int y = 0; y < YRes; ++y)
        {
            for (int x = 0; x < XRes; ++x, i--)
            {
                int        index = x * m_factor + imageData.XRes * y * m_factor;
                RGB24Pixel pixel = imageData[index];
                colorElement.r = ((float)pixel.Blue) / 256.0f;
                colorElement.g = ((float)pixel.Green) / 256.0f;
                colorElement.b = ((float)pixel.Red) / 256.0f;

                m_mapPixels[i] = colorElement;
            }
        }
        m_mapTexture.SetPixels(m_mapPixels);
        m_mapTexture.Apply();
    }
예제 #2
0
    /// a method to write the image data to the texture.
    protected void WriteImageTexture()
    {
        // the size of the target data
        int i = XRes * YRes - 1;
        // the array which holds the image
        MapData <RGB24Pixel> imageData = m_metaData.GetRGB24ImageMap();
        Color colorElement             = Color.black; // just an initialization

        // loop over the target array (x and y).
        for (int y = 0; y < YRes; ++y)
        {
            for (int x = 0; x < XRes; ++x, i--)                         // the position is from end to start because of difference in coordinate systems
            {
                int ind = x * m_factor + imageData.XRes * y * m_factor; // this is the index of the current point in the original data
                // we transform the RGB24Pixel data (Received from the image) to a Color.
                RGB24Pixel pixel = imageData[ind];
                colorElement.r = ((float)pixel.Red) / 255.0f;
                colorElement.g = ((float)pixel.Green) / 255.0f;
                colorElement.b = ((float)pixel.Blue) / 255.0f;
                m_mapPixels[i] = colorElement;
            }
        }
        m_mapTexture.SetPixels(m_mapPixels);
        m_mapTexture.Apply();
    }